-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathexpress.py
More file actions
executable file
·80 lines (64 loc) · 3.17 KB
/
express.py
File metadata and controls
executable file
·80 lines (64 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
"""
This module prints three FedEx Express shipping labels for the label
certification process. See your FedEx Label Developer Tool Kit documentation
for more details.
"""
import logging
from cert_config import CONFIG_OBJ, SHIPPER_CONTACT_INFO, SHIPPER_ADDRESS, LABEL_SPECIFICATION
from cert_config import transfer_config_dict
from cert_config import LabelPrinterClass
from fedex.services.ship_service import FedexProcessShipmentRequest
logging.basicConfig(level=logging.INFO)
shipment = FedexProcessShipmentRequest(CONFIG_OBJ)
shipment.RequestedShipment.DropoffType = 'REGULAR_PICKUP'
shipment.RequestedShipment.ServiceType = 'PRIORITY_OVERNIGHT'
shipment.RequestedShipment.PackagingType = 'YOUR_PACKAGING'
# Shipper contact info.
transfer_config_dict(shipment.RequestedShipment.Shipper.Contact,
SHIPPER_CONTACT_INFO)
# Shipper address.
transfer_config_dict(shipment.RequestedShipment.Shipper.Address,
SHIPPER_ADDRESS)
# Recipient contact info.
shipment.RequestedShipment.Recipient.Contact.PersonName = 'Recipient Name'
shipment.RequestedShipment.Recipient.Contact.CompanyName = 'Recipient Company'
shipment.RequestedShipment.Recipient.Contact.PhoneNumber = '9012637906'
# Recipient address
shipment.RequestedShipment.Recipient.Address.StreetLines = ['Address Line 1']
shipment.RequestedShipment.Recipient.Address.City = 'Herndon'
shipment.RequestedShipment.Recipient.Address.StateOrProvinceCode = 'VA'
shipment.RequestedShipment.Recipient.Address.PostalCode = '20171'
shipment.RequestedShipment.Recipient.Address.CountryCode = 'US'
shipment.RequestedShipment.ShippingChargesPayment.PaymentType = 'SENDER'
# Senders account information
shipment.RequestedShipment.ShippingChargesPayment.Payor.ResponsibleParty.AccountNumber = CONFIG_OBJ.account_number
# Label config.
transfer_config_dict(shipment.RequestedShipment.LabelSpecification,
LABEL_SPECIFICATION)
package1_weight = shipment.create_wsdl_object_of_type('Weight')
package1_weight.Value = 1.0
package1_weight.Units = "LB"
package1 = shipment.create_wsdl_object_of_type('RequestedPackageLineItem')
package1.Weight = package1_weight
shipment.add_package(package1)
if __name__ == "__main__":
shipment.send_request()
device = LabelPrinterClass(shipment)
device.print_label()
shipment.RequestedShipment.Recipient.Address.StreetLines = ['456 Peach St']
shipment.RequestedShipment.Recipient.Address.City = 'Atlanta'
shipment.RequestedShipment.Recipient.Address.StateOrProvinceCode = 'GA'
shipment.RequestedShipment.Recipient.Address.PostalCode = '30303'
shipment.RequestedShipment.Recipient.Address.CountryCode = 'US'
shipment.send_request()
device = LabelPrinterClass(shipment)
device.print_label()
shipment.RequestedShipment.Recipient.Address.StreetLines = ['987 Main St']
shipment.RequestedShipment.Recipient.Address.City = 'Boston'
shipment.RequestedShipment.Recipient.Address.StateOrProvinceCode = 'MA'
shipment.RequestedShipment.Recipient.Address.PostalCode = '02115'
shipment.RequestedShipment.Recipient.Address.CountryCode = 'US'
shipment.send_request()
device = LabelPrinterClass(shipment)
device.print_label()