Package fedex :: Package services :: Module availability_commitment_service
[hide private]
[frames] | no frames]

Source Code for Module fedex.services.availability_commitment_service

  1  """ 
  2  Service Availability and Commitment Module 
  3   
  4  This package contains the shipping methods defined by Fedex's  
  5  ValidationAvailabilityAndCommitmentService WSDL file. Each is encapsulated in a class for 
  6  easy access. For more details on each, refer to the respective class's  
  7  documentation. 
  8  """ 
  9   
 10  import datetime 
 11  from ..base_service import FedexBaseService 
 12   
 13   
14 -class FedexAvailabilityCommitmentRequest(FedexBaseService):
15 """ 16 This class allows you validate service availability 17 """ 18
19 - def __init__(self, config_obj, *args, **kwargs):
20 """ 21 @type config_obj: L{FedexConfig} 22 @param config_obj: A valid FedexConfig object. 23 """ 24 25 self._config_obj = config_obj 26 # Holds version info for the VersionId SOAP object. 27 self._version_info = { 28 'service_id': 'vacs', 29 'major': '4', 30 'intermediate': '0', 31 'minor': '0' 32 } 33 34 self.CarrierCode = None 35 """ivar: Carrier Code Default to Fedex (FDXE), or can bbe FDXG.""" 36 37 self.Origin = None 38 """@ivar: Holds Origin Address WSDL object.""" 39 40 self.Destination = None 41 """@ivar: Holds Destination Address WSDL object.""" 42 43 self.ShipDate = None 44 """@ivar: Ship Date date WSDL object.""" 45 46 self.Service = None 47 """@ivar: Service type, if set to None will get all available service information.""" 48 49 self.Packaging = None 50 """@ivar: Type of packaging to narrow down available shipping options or defaults to YOUR_PACKAGING.""" 51 52 # Call the parent FedexBaseService class for basic setup work. 53 # Shortened the name of the wsdl, otherwise suds did not load it properly. 54 # Suds throws the following error when using the long file name from FedEx: 55 # 56 # File "/Library/Python/2.7/site-packages/suds/wsdl.py", line 878, in resolve 57 # raise Exception("binding '%s', not-found" % p.binding) 58 # Exception: binding 'ns:ValidationAvailabilityAndCommitmentServiceSoapBinding', not-found 59 60 super(FedexAvailabilityCommitmentRequest, self).__init__( 61 self._config_obj, 'AvailabilityAndCommitmentService_v4.wsdl', *args, **kwargs)
62
63 - def _prepare_wsdl_objects(self):
64 """ 65 Create the data structure and get it ready for the WSDL request. 66 """ 67 self.CarrierCode = 'FDXE' 68 self.Origin = self.Destination = self.client.factory.create('Address') 69 self.ShipDate = datetime.date.today().isoformat() 70 self.Service = None 71 self.Packaging = 'YOUR_PACKAGING'
72
74 """ 75 Fires off the Fedex request. 76 77 @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), 78 WHICH RESIDES ON FedexBaseService AND IS INHERITED. 79 """ 80 81 # We get an exception like this when specifying an IntegratorId: 82 # suds.TypeNotFound: Type not found: 'IntegratorId' 83 # Setting it to None does not seem to appease it. 84 del self.ClientDetail.IntegratorId 85 self.logger.debug(self.WebAuthenticationDetail) 86 self.logger.debug(self.ClientDetail) 87 self.logger.debug(self.TransactionDetail) 88 self.logger.debug(self.VersionId) 89 # Fire off the query. 90 return self.client.service.serviceAvailability( 91 WebAuthenticationDetail=self.WebAuthenticationDetail, 92 ClientDetail=self.ClientDetail, 93 TransactionDetail=self.TransactionDetail, 94 Version=self.VersionId, 95 Origin=self.Origin, 96 Destination=self.Destination, 97 ShipDate=self.ShipDate, 98 CarrierCode=self.CarrierCode, 99 Service=self.Service, 100 Packaging=self.Packaging)
101