|
9 | 9 | """ |
10 | 10 | import logging |
11 | 11 | import binascii |
| 12 | +from example_config import CONFIG_OBJ |
12 | 13 | from fedex.services.ship_service import FedexProcessShipmentRequest |
13 | | -from fedex.config import FedexConfig |
14 | 14 |
|
15 | 15 | # Set this to the INFO level to see the response from Fedex printed in stdout. |
16 | | -logging.basicConfig(level=logging.ERROR) |
17 | | - |
18 | | -# FedexConfig objects should generally only be instantiated once and re-used |
19 | | -# amongst different queries. They hold static data like account number. |
20 | | -config_obj = FedexConfig(key='ZyNQQFdcxUATOx9L', |
21 | | - password='GtngmKzs4Dk4RYmrlAjrLykwi', |
22 | | - account_number='510087780', |
23 | | - meter_number='118501898', |
24 | | - use_test_server=True) |
| 16 | +logging.basicConfig(level=logging.INFO) |
25 | 17 |
|
26 | 18 | # This is the object that will be handling our tracking request. |
27 | | -shipment = FedexProcessShipmentRequest(config_obj) |
| 19 | +# We're using the FedexConfig object from example_config.py in this dir. |
| 20 | +shipment = FedexProcessShipmentRequest(CONFIG_OBJ) |
28 | 21 |
|
29 | 22 | # This is very generalized, top-level information. |
30 | 23 | # REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER or STATION |
|
43 | 36 | shipment.RequestedShipment.PackageDetail = 'INDIVIDUAL_PACKAGES' |
44 | 37 |
|
45 | 38 | # Shipper contact info. |
46 | | -shipment.ShipperContact.PersonName = 'Sender Name' |
47 | | -shipment.ShipperContact.CompanyName = 'Some Company' |
48 | | -shipment.ShipperContact.PhoneNumber = '9012638716' |
| 39 | +shipment.RequestedShipment.Shipper.Contact.PersonName = 'Sender Name' |
| 40 | +shipment.RequestedShipment.Shipper.Contact.CompanyName = 'Some Company' |
| 41 | +shipment.RequestedShipment.Shipper.Contact.PhoneNumber = '9012638716' |
49 | 42 |
|
50 | 43 | # Shipper address. |
51 | | -shipment.ShipperAddress.StreetLines = ['Address Line 1'] |
52 | | -shipment.ShipperAddress.City = 'Herndon' |
53 | | -shipment.ShipperAddress.StateOrProvinceCode = 'VA' |
54 | | -shipment.ShipperAddress.PostalCode = '20171' |
55 | | -shipment.ShipperAddress.CountryCode = 'US' |
56 | | -shipment.ShipperAddress.Residential = True |
| 44 | +shipment.RequestedShipment.Shipper.Address.StreetLines = ['Address Line 1'] |
| 45 | +shipment.RequestedShipment.Shipper.Address.City = 'Herndon' |
| 46 | +shipment.RequestedShipment.Shipper.Address.StateOrProvinceCode = 'VA' |
| 47 | +shipment.RequestedShipment.Shipper.Address.PostalCode = '20171' |
| 48 | +shipment.RequestedShipment.Shipper.Address.CountryCode = 'US' |
| 49 | +shipment.RequestedShipment.Shipper.Address.Residential = True |
57 | 50 |
|
58 | 51 | # Recipient contact info. |
59 | | -shipment.RecipientContact.PersonName = 'Recipient Name' |
60 | | -shipment.RecipientContact.CompanyName = 'Recipient Company' |
61 | | -shipment.RecipientContact.PhoneNumber = '9012637906' |
| 52 | +shipment.RequestedShipment.Recipient.Contact.PersonName = 'Recipient Name' |
| 53 | +shipment.RequestedShipment.Recipient.Contact.CompanyName = 'Recipient Company' |
| 54 | +shipment.RequestedShipment.Recipient.Contact.PhoneNumber = '9012637906' |
62 | 55 |
|
63 | 56 | # Recipient address |
64 | | -shipment.RecipientAddress.StreetLines = ['Address Line 1'] |
65 | | -shipment.RecipientAddress.City = 'Herndon' |
66 | | -shipment.RecipientAddress.StateOrProvinceCode = 'VA' |
67 | | -shipment.RecipientAddress.PostalCode = '20171' |
68 | | -shipment.RecipientAddress.CountryCode = 'US' |
| 57 | +shipment.RequestedShipment.Recipient.Address.StreetLines = ['Address Line 1'] |
| 58 | +shipment.RequestedShipment.Recipient.Address.City = 'Herndon' |
| 59 | +shipment.RequestedShipment.Recipient.Address.StateOrProvinceCode = 'VA' |
| 60 | +shipment.RequestedShipment.Recipient.Address.PostalCode = '20171' |
| 61 | +shipment.RequestedShipment.Recipient.Address.CountryCode = 'US' |
69 | 62 | # This is needed to ensure an accurate rate quote with the response. |
70 | | -shipment.RecipientAddress.Residential = True |
| 63 | +shipment.RequestedShipment.Recipient.Address.Residential = True |
71 | 64 |
|
72 | 65 | # Who pays for the shipment? |
73 | 66 | # RECIPIENT, SENDER or THIRD_PARTY |
74 | | -shipment.ShippingChargesPayment.PaymentType = 'SENDER' |
| 67 | +shipment.RequestedShipment.ShippingChargesPayment.PaymentType = 'SENDER' |
75 | 68 |
|
76 | 69 | # Specifies the label type to be returned. |
77 | 70 | # LABEL_DATA_ONLY or COMMON2D |
78 | | -shipment.LabelSpecification.LabelFormatType = 'COMMON2D' |
| 71 | +shipment.RequestedShipment.LabelSpecification.LabelFormatType = 'COMMON2D' |
79 | 72 |
|
80 | 73 | # Specifies which format the label file will be sent to you in. |
81 | 74 | # DPL, EPL2, PDF, PNG, ZPLII |
82 | | -shipment.LabelSpecification.ImageType = 'PNG' |
| 75 | +shipment.RequestedShipment.LabelSpecification.ImageType = 'PNG' |
83 | 76 |
|
84 | 77 | # To use doctab stocks, you must change ImageType above to one of the |
85 | 78 | # label printer formats (ZPLII, EPL2, DPL). |
86 | 79 | # See documentation for paper types, there quite a few. |
87 | | -shipment.LabelSpecification.LabelStockType = 'PAPER_4X6' |
| 80 | +shipment.RequestedShipment.LabelSpecification.LabelStockType = 'PAPER_4X6' |
88 | 81 |
|
89 | 82 | # This indicates if the top or bottom of the label comes out of the |
90 | 83 | # printer first. |
91 | 84 | # BOTTOM_EDGE_OF_TEXT_FIRST or TOP_EDGE_OF_TEXT_FIRST |
92 | | -shipment.LabelSpecification.LabelPrintingOrientation = 'BOTTOM_EDGE_OF_TEXT_FIRST' |
| 85 | +shipment.RequestedShipment.LabelSpecification.LabelPrintingOrientation = 'BOTTOM_EDGE_OF_TEXT_FIRST' |
93 | 86 |
|
94 | 87 | package1_weight = shipment.create_wsdl_object_of_type('Weight') |
95 | 88 | # Weight, in pounds. |
|
125 | 118 | # This will show the reply to your shipment being sent. You can access the |
126 | 119 | # attributes through the response attribute on the request object. This is |
127 | 120 | # good to un-comment to see the variables returned by the Fedex reply. |
128 | | -#print shipment.response |
| 121 | +print shipment.response |
129 | 122 |
|
130 | 123 | # Here is the overall end result of the query. |
131 | 124 | print "HighestSeverity:", shipment.response.HighestSeverity |
|
0 commit comments