def availabiltiy_commitment(self, credentials, from_address_doc,
                             to_address_doc, from_country_doc,
                             to_country_doc):
     from fedex.services.availability_commitment_service import FedexAvailabilityCommitmentRequest
     avc_request = FedexAvailabilityCommitmentRequest(credentials)
     avc_request.Origin.PostalCode = str(from_address_doc.pincode)[0:10]
     avc_request.Origin.CountryCode = from_country_doc.code
     avc_request.Destination.PostalCode = str(to_address_doc.pincode)[0:10]
     avc_request.Destination.CountryCode = to_country_doc.code
     avc_request.ShipDate = datetime.date.today().isoformat()
     avc_request.send_request()
     for option in avc_request.response.Options:
         frappe.msgprint("Ship Option:")
         if hasattr(option, 'Service'):
             frappe.msgprint("Service {}".format(option.Service))
         if hasattr(option, 'DeliveryDate'):
             frappe.msgprint("DeliveryDate {}".format(option.DeliveryDate))
         if hasattr(option, 'DeliveryDay'):
             frappe.msgprint("DeliveryDay {}".format(option.DeliveryDay))
         #if hasattr(option, 'DestinationStationId'):
         #	frappe.msgprint("DestinationStationId {}".format(option.DestinationStationId))
         #if hasattr(option, 'DestinationAirportId'):
         #	frappe.msgprint("DestinationAirportId {}".format(option.DestinationAirportId))
         if hasattr(option, 'TransitTime'):
             frappe.msgprint("TransitTime {}".format(option.TransitTime))
         frappe.msgprint("")
	def availabiltiy_commitment(self, credentials, from_address_doc, to_address_doc, from_country_doc, to_country_doc):
		from fedex.services.availability_commitment_service import FedexAvailabilityCommitmentRequest
		avc_request = FedexAvailabilityCommitmentRequest(credentials)
		avc_request.Origin.PostalCode = str(from_address_doc.pincode)[0:10]
		avc_request.Origin.CountryCode = from_country_doc.code
		avc_request.Destination.PostalCode = str(to_address_doc.pincode)[0:10]
		avc_request.Destination.CountryCode = to_country_doc.code
		avc_request.ShipDate = datetime.date.today().isoformat()
		avc_request.send_request()
		for option in avc_request.response.Options:
			frappe.msgprint("Ship Option:")
			if hasattr(option, 'Service'):
				frappe.msgprint("Service {}".format(option.Service))
			if hasattr(option, 'DeliveryDate'):
				frappe.msgprint("DeliveryDate {}".format(option.DeliveryDate))
			if hasattr(option, 'DeliveryDay'):
				frappe.msgprint("DeliveryDay {}".format(option.DeliveryDay))
			#if hasattr(option, 'DestinationStationId'):
			#	frappe.msgprint("DestinationStationId {}".format(option.DestinationStationId))
			#if hasattr(option, 'DestinationAirportId'):
			#	frappe.msgprint("DestinationAirportId {}".format(option.DestinationAirportId))
			if hasattr(option, 'TransitTime'):
				frappe.msgprint("TransitTime {}".format(option.TransitTime))
			frappe.msgprint("")
Exemple #3
0
avc_request = FedexAvailabilityCommitmentRequest(
    CONFIG_OBJ, customer_transaction_id=customer_transaction_id)

# Specify the origin postal code and country code. These fields are required.
avc_request.Origin.PostalCode = '29631'
avc_request.Origin.CountryCode = 'US'

# Specify the destination postal code and country code. These fields are required.
avc_request.Destination.PostalCode = '27577'
avc_request.Destination.CountryCode = 'US'

# Can be set to FEDEX_TUBE, YOUR_PACKAGING, FEDEX_BOX etc.. Defaults to YOUR_PACKAGING if not set.
# avc_request.Packaging = 'FEDEX_ENVELOPE'

# Can be set to the expected date. Defaults to today if not set.
avc_request.ShipDate = datetime.date.today().isoformat()

# Can be set to PRIORITY_OVERNIGHT, FEDEX_2_DAY, STANDARD_OVERNIGHT etc.. Defaults to showing all options if not set.
# avc_request.Service = 'FEDEX_2_DAY'

# Fires off the request, sets the 'response' attribute on the object.
avc_request.send_request()

# If you'd like to see some documentation on the ship service WSDL, un-comment this line.
print(avc_request.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can change.
# print(avc_request.Origin)
# print(avc_request.Destination)
# print(avc_request.ShipDate)
customer_transaction_id = "*** AvailabilityAndCommitment Request v4 using Python ***"  # Optional transaction_id
avc_request = FedexAvailabilityCommitmentRequest(CONFIG_OBJ, customer_transaction_id=customer_transaction_id)

# Specify the origin postal code and country code. These fields are required.
avc_request.Origin.PostalCode = '29631'
avc_request.Origin.CountryCode = 'US'

# Specify the destination postal code and country code. These fields are required.
avc_request.Destination.PostalCode = '27577'
avc_request.Destination.CountryCode = 'US'

# Can be set to FEDEX_TUBE, YOUR_PACKAGING, FEDEX_BOX etc.. Defaults to YOUR_PACKAGING if not set.
# avc_request.Packaging = 'FEDEX_ENVELOPE'

# Can be set to the expected date. Defaults to today if not set.
avc_request.ShipDate = datetime.date.today().isoformat()

# Can be set to PRIORITY_OVERNIGHT, FEDEX_2_DAY, STANDARD_OVERNIGHT etc.. Defaults to showing all options if not set.
# avc_request.Service = 'FEDEX_2_DAY'

# Fires off the request, sets the 'response' attribute on the object.
avc_request.send_request()

# If you'd like to see some documentation on the ship service WSDL, un-comment this line.
print(avc_request.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can change.
# print(avc_request.Origin)
# print(avc_request.Destination)
# print(avc_request.ShipDate)