Skip to content

Commit 2cec015

Browse files
authored
Merge pull request #127 from christopherpryer/master
Example scripts updates.
2 parents 3e44ed7 + c1e98ca commit 2cec015

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ doc_src/_sources/*
1414
doc_src/_static/*
1515
doc_src/*.html
1616
doc_src/_build/*
17+
/venv
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import logging
2+
import sys
3+
4+
from example_config import CONFIG_OBJ
5+
from fedex.services.availability_commitment_service import FedexAvailabilityCommitmentRequest
6+
from fedex.tools.conversion import sobject_to_dict
7+
8+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
9+
10+
avc_request = FedexAvailabilityCommitmentRequest(CONFIG_OBJ)
11+
12+
# .StateOrProvinceCode available as well
13+
avc_request.Origin.PostalCode = '60634'
14+
avc_request.Origin.CountryCode = 'US'
15+
avc_request.Destination.PostalCode = '19106'
16+
avc_request.Destination.CountryCode = 'US'
17+
avc_request.Service = 'FEDEX_GROUND'
18+
19+
avc_request.send_request()
20+
response_dict = sobject_to_dict(avc_request.response)
21+
22+
# output display formatting
23+
origin_str = '%s, %s' % (
24+
avc_request.Origin.PostalCode,
25+
avc_request.Origin.CountryCode)
26+
destination_str = '%s, %s' % (
27+
avc_request.Destination.PostalCode,
28+
avc_request.Destination.CountryCode)
29+
30+
logging.info('origin: %s' % origin_str)
31+
logging.info('destination: %s' % destination_str)
32+
for option in response_dict['Options']:
33+
if option['Service'] == 'FEDEX_GROUND':
34+
logging.info('TransitTime: %s' % option['TransitTime'])
35+
else:
36+
logging.warning('No Fedex Ground Service found.')

examples/rate_request.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@
4141
rate_request.RequestedShipment.PackagingType = 'YOUR_PACKAGING'
4242

4343
# Shipper's address
44+
rate_request.RequestedShipment.Shipper.Address.StateOrProvinceCode = 'SC'
4445
rate_request.RequestedShipment.Shipper.Address.PostalCode = '29631'
4546
rate_request.RequestedShipment.Shipper.Address.CountryCode = 'US'
4647
rate_request.RequestedShipment.Shipper.Address.Residential = False
4748

4849
# Recipient address
50+
rate_request.RequestedShipment.Recipient.Address.StateOrProvinceCode = 'NC'
4951
rate_request.RequestedShipment.Recipient.Address.PostalCode = '27577'
5052
rate_request.RequestedShipment.Recipient.Address.CountryCode = 'US'
5153
# This is needed to ensure an accurate rate quote with the response.

0 commit comments

Comments
 (0)