|
| 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 availabile 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.') |
0 commit comments