1+ """
2+ The L{base_service} module contains classes that form the low level foundations
3+ of the Web Service API. Things that many different kinds of requests have in
4+ common may be found here.
5+
6+ In particular, the L{FedexBaseService} class handles most of the basic,
7+ repetetive setup work that most requests do.
8+ """
19import os
210import logging
311from suds .client import Client
412
513class FedexBaseService (object ):
14+ """
15+ This class is the master class for all Fedex request objects. It gets all
16+ of the common SOAP objects created via suds and populates them with
17+ values from a L{FedexConfig} object, along with keyword arguments
18+ via L{__init__}.
19+
20+ @note: This object should never be used directly, use one of the included
21+ sub-classes.
22+ """
623 def __init__ (self , config_obj , wsdl_name , * args , ** kwargs ):
24+ """
25+ This constructor should only be called by children of the class. As is
26+ such, only the optional keyword arguments caught by C{**kwargs} will
27+ be documented.
28+
29+ @type customer_transaction_id: L{str}
30+ @keyword customer_transaction_id: A user-specified identifier to
31+ differentiate this transaction from others. This value will be
32+ returned with the response from Fedex.
33+ @type carrier_code: L{str}
34+ @keyword carrier_code: The carrier code to use for this query. In most
35+ cases, this will be FDXE (Fedex Express). Must be one of the
36+ following four-letter codes:
37+ - FDXC (Fedex Cargo)
38+ - FDXE (Fedex Express)
39+ - FDXG (Fedex Ground)
40+ - FXCC (Fedex Custom Critical)
41+ - FXFR (Fedex Freight)
42+ - FXSP (Fedex Smartpost)
43+ """
744 self .config_obj = config_obj
845 self .wsdl_path = os .path .join (config_obj .wsdl_path , wsdl_name )
946 self .client = Client ('file://%s' % self .wsdl_path )
1047 self .logger = logging .getLogger ('fedex' )
48+ self .response = None
49+ """@ivar: The response from Fedex. You will want to pick what you
50+ want out here here. This object does have a __str__() method,
51+ you'll want to print or log it to see what possible values
52+ you can pull."""
1153
1254 self .logger .debug (self .client )
13- self .set_web_authentication_detail ()
14- self .set_client_detail ()
15- self .set_version_id ()
16- self .set_carrier_code_type (* args , ** kwargs )
17- self .set_transaction_detail (* args , ** kwargs )
55+ self .__set_web_authentication_detail ()
56+ self .__set_client_detail ()
57+ self .__set_version_id ()
58+ self .__set_carrier_code_type (* args , ** kwargs )
59+ self .__set_transaction_detail (* args , ** kwargs )
1860
19- def set_web_authentication_detail (self ):
61+ def __set_web_authentication_detail (self ):
2062 """
2163 Sets up the WebAuthenticationDetail node. This is required for all
2264 requests.
@@ -32,7 +74,7 @@ def set_web_authentication_detail(self):
3274 self .logger .debug (WebAuthenticationDetail )
3375 self .WebAuthenticationDetail = WebAuthenticationDetail
3476
35- def set_client_detail (self ):
77+ def __set_client_detail (self ):
3678 """
3779 Sets up the ClientDetail node, which is required for all shipping
3880 related requests.
@@ -44,7 +86,7 @@ def set_client_detail(self):
4486 self .logger .debug (ClientDetail )
4587 self .ClientDetail = ClientDetail
4688
47- def set_transaction_detail (self , * args , ** kwargs ):
89+ def __set_transaction_detail (self , * args , ** kwargs ):
4890 """
4991 Checks kwargs for 'customer_transaction_id' and sets it if present.
5092 """
@@ -57,7 +99,7 @@ def set_transaction_detail(self, *args, **kwargs):
5799 else :
58100 self .TransactionDetail = None
59101
60- def set_carrier_code_type (self , * args , ** kwargs ):
102+ def __set_carrier_code_type (self , * args , ** kwargs ):
61103 """
62104 Checks kwargs for 'carrier_code' and sets it if present.
63105 """
@@ -70,22 +112,22 @@ def set_carrier_code_type(self, *args, **kwargs):
70112 else :
71113 self .CarrierCodeType = None
72114
73- def set_version_id (self ):
115+ def __set_version_id (self ):
74116 """
75117 Pulles the versioning info for the request from the child request.
76118 """
77119 VersionId = self .client .factory .create ('VersionId' )
78- VersionId .ServiceId = self .version_info ['service_id' ]
79- VersionId .Major = self .version_info ['major' ]
80- VersionId .Intermediate = self .version_info ['intermediate' ]
81- VersionId .Minor = self .version_info ['minor' ]
120+ VersionId .ServiceId = self ._version_info ['service_id' ]
121+ VersionId .Major = self ._version_info ['major' ]
122+ VersionId .Intermediate = self ._version_info ['intermediate' ]
123+ VersionId .Minor = self ._version_info ['minor' ]
82124 self .logger .debug (VersionId )
83125 self .VersionId = VersionId
84126
85127 def send_request (self ):
86128 """
87129 Sends the assembled request on the child object.
88130 """
89- self .response = self .assemble_and_send_request ()
131+ self .response = self ._assemble_and_send_request ()
90132 self .logger .info ("== FEDEX QUERY RESULT ==" )
91133 self .logger .info (self .response )
0 commit comments