diff --git a/fedex/services/document_service.py b/fedex/services/document_service.py new file mode 100644 index 0000000..8b4419d --- /dev/null +++ b/fedex/services/document_service.py @@ -0,0 +1,85 @@ +""" +Document Service Module + +This package contains the shipping methods defined by Fedex's +DocumentService WSDL file. Each is encapsulated in a class for +easy access. For more details on each, refer to the respective class's +documentation. +""" + +import datetime +from ..base_service import FedexBaseService + + +class FedexDocumentServiceRequest(FedexBaseService): + """ + This class allows you to submit the document. + You will need to populate the data structures in self.UploadDocumentsRequest, + then send the request. + """ + + def __init__(self, config_obj, *args, **kwargs): + """ + The optional keyword args detailed on L{FedexBaseService} + apply here as well. + @type config_obj: L{FedexConfig} + @param config_obj: A valid FedexConfig object. + """ + + self._config_obj = config_obj + + # Holds version info for the VersionId SOAP object. + self._version_info = {'service_id': 'cdus', 'major': '11', + 'intermediate': '0', 'minor': '0'} + + self.UploadDocumentsRequest = None + """@ivar: Holds the UploadDocumentsRequest WSDL object including the shipper, recipient and shipt time.""" + super(FedexDocumentServiceRequest, self).__init__( + self._config_obj, 'UploadDocumentService_v11.wsdl', *args, **kwargs) + """@ivar: Holds the express region code from the config object.""" + + def _prepare_wsdl_objects(self): + """ + This is the data that will be used to create your shipment. Create + the data structure and get it ready for the WSDL request. + """ + self.UploadDocumentsRequest = self.client.factory.create('UploadDocumentsRequest') + self.OriginCountryCode =None + self.DestinationCountryCode =None + self.Usage ='ELECTRONIC_TRADE_DOCUMENTS'#Default Usage + self.Documents = [] + self.UploadDocumentsRequest.Documents = [] + self.logger.debug(self.UploadDocumentsRequest) + + def _assemble_and_send_request(self): + """ + Fires off the Fedex request. + + @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), + WHICH RESIDES ON FedexBaseService AND IS INHERITED. + """ + + # Fire off the query. + return self.client.service.uploadDocuments( + WebAuthenticationDetail=self.WebAuthenticationDetail, + ClientDetail=self.ClientDetail, + TransactionDetail=self.TransactionDetail, + Version=self.VersionId, + Documents=self.Documents, + Usage = self.Usage, + OriginCountryCode = self.OriginCountryCode, + DestinationCountryCode = self.DestinationCountryCode, + ) + def get_document(self, line_number,customer_reference, + document_type , file_name, document_content, expiration_date =None + ): + document_item = self.client.factory.create('UploadDocumentDetail') + document_item.LineNumber = line_number + document_item.CustomerReference = customer_reference + document_item.DocumentType = document_type + document_item.FileName = file_name + document_item.DocumentContent = document_content + document_item.ExpirationDate = expiration_date + return document_item + def add_documents(self, document_item): + self.Documents.append(document_item) diff --git a/fedex/wsdl/UploadDocumentService_v11.wsdl b/fedex/wsdl/UploadDocumentService_v11.wsdl new file mode 100644 index 0000000..0e38e90 --- /dev/null +++ b/fedex/wsdl/UploadDocumentService_v11.wsdl @@ -0,0 +1,506 @@ + + + + + + + + + + Descriptive data for the client submitting a transaction. + + + + + The FedEx account number associated with this transaction. + + + + + This number is assigned by FedEx and identifies the unique device from which the request is originating + + + + + Only used in transactions which require identification of the FedEx Office integrator. + + + + + The language to be used for human-readable Notification.localizedMessages in responses to the request containing this ClientDetail object. Different requests from the same client may contain different Localization data. (Contrast with TransactionDetail.localization, which governs data payload language/translation.) + + + + + + + + + + + + + + + + + + + Lists the documents that are not accepted by FedEx for this shipment. + + + + + + + Specifies the usage or intent of the document in the current context. + + + + + + + + + This identifies some of the document types recognized by Enterprise Document Management Service. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Identifies the representation of human-readable text. + + + + + Two-letter code for language (e.g. EN, FR, etc.) + + + + + Two-letter code for the region (e.g. us, ca, etc..). + + + + + + + The descriptive data regarding the result of the submitted transaction. + + + + + The severity of this notification. This can indicate success or failure or some other information about the request. The values that can be returned are SUCCESS - Your transaction succeeded with no other applicable information. NOTE - Additional information that may be of interest to you about your transaction. WARNING - Additional information that you need to know about your transaction that you may need to take action on. ERROR - Information about an error that occurred while processing your transaction. FAILURE - FedEx was unable to process your transaction at this time due to a system failure. Please try again later + + + + + Indicates the source of this notification. Combined with the Code it uniquely identifies this notification + + + + + A code that represents this notification. Combined with the Source it uniquely identifies this notification. + + + + + Human-readable text that explains this notification. + + + + + The translated message. The language and locale specified in the ClientDetail. Localization are used to determine the representation. Currently only supported in a TrackReply. + + + + + A collection of name/value pairs that provide specific data to help the client determine the nature of an error (or warning, etc.) without having to parse the message string. + + + + + + + + + Identifies the type of data contained in Value (e.g. SERVICE_TYPE, PACKAGE_SEQUENCE, etc..). + + + + + The value of the parameter (e.g. PRIORITY_OVERNIGHT, 2, etc..). + + + + + + + + + + + + + + + + + + The tracking number field should be provided when uploading documents after the shipment has been processed or confirmed. This is only applicable if the shipment has been processed with the POST_SHIPMENT_UPLOAD_REQUESTED ETD attribute. + + + + + + + This identifies the document types that can be required. This can also indicate when either a COMMERCIAL_INVOICE or a PRO_FORMA_INVOICE is required through the COMMERCIAL_OR_PRO_FORMA_INVOICE option. + + + + + + + + + + + + + + + + + + + + + + Free form text to be echoed back in the reply. Used to match requests and replies. + + + + + Governs data payload language/translations (contrasted with ClientDetail.localization, which governs Notification.localizedMessage language selection). + + + + + + + + + + + + + + Specifies the date until which the document is available + + + + + + + Specifies the application that is responsible for managing the document id. + + + + + + + + + + + + + + + + + + + + + Distinct value for reason status was assigned. + + + + + Human-readable explanation of document status. + + + + + + + + + Each of these values identifies a specific reason why a document or reference could not be uploaded or associated with a shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + For an upload making use of the POST_SHIPMENT_UPLOAD option, this will indicate information about the required documents necessary for package movement. + + + + + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + + + + + + + + Specifies the intent or the usage of the documents being uploaded. This provides details about how the documents are relevant to the current transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + + + + + + + Used in authentication of the sender's identity. + + + + + This was renamed from cspCredential. + + + + + Credential used to authenticate a specific software application. This value is provided by FedEx after registration. + + + + + + + Two part authentication string used for the sender's identity + + + + + Identifying part of authentication credential. This value is provided by FedEx after registration + + + + + Secret part of authentication key. This value is provided by FedEx after registration. + + + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Identifies a system or sub-system which performs an operation. + + + + + Identifies the service business level. + + + + + Identifies the service interface level. + + + + + Identifies the service code level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fedex/wsdl/test_server_wsdl/UploadDocumentService_v11.wsdl b/fedex/wsdl/test_server_wsdl/UploadDocumentService_v11.wsdl new file mode 100644 index 0000000..678edb5 --- /dev/null +++ b/fedex/wsdl/test_server_wsdl/UploadDocumentService_v11.wsdl @@ -0,0 +1,506 @@ + + + + + + + + + + Descriptive data for the client submitting a transaction. + + + + + The FedEx account number associated with this transaction. + + + + + This number is assigned by FedEx and identifies the unique device from which the request is originating + + + + + Only used in transactions which require identification of the FedEx Office integrator. + + + + + The language to be used for human-readable Notification.localizedMessages in responses to the request containing this ClientDetail object. Different requests from the same client may contain different Localization data. (Contrast with TransactionDetail.localization, which governs data payload language/translation.) + + + + + + + + + + + + + + + + + + + Lists the documents that are not accepted by FedEx for this shipment. + + + + + + + Specifies the usage or intent of the document in the current context. + + + + + + + + + This identifies some of the document types recognized by Enterprise Document Management Service. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Identifies the representation of human-readable text. + + + + + Two-letter code for language (e.g. EN, FR, etc.) + + + + + Two-letter code for the region (e.g. us, ca, etc..). + + + + + + + The descriptive data regarding the result of the submitted transaction. + + + + + The severity of this notification. This can indicate success or failure or some other information about the request. The values that can be returned are SUCCESS - Your transaction succeeded with no other applicable information. NOTE - Additional information that may be of interest to you about your transaction. WARNING - Additional information that you need to know about your transaction that you may need to take action on. ERROR - Information about an error that occurred while processing your transaction. FAILURE - FedEx was unable to process your transaction at this time due to a system failure. Please try again later + + + + + Indicates the source of this notification. Combined with the Code it uniquely identifies this notification + + + + + A code that represents this notification. Combined with the Source it uniquely identifies this notification. + + + + + Human-readable text that explains this notification. + + + + + The translated message. The language and locale specified in the ClientDetail. Localization are used to determine the representation. Currently only supported in a TrackReply. + + + + + A collection of name/value pairs that provide specific data to help the client determine the nature of an error (or warning, etc.) without having to parse the message string. + + + + + + + + + Identifies the type of data contained in Value (e.g. SERVICE_TYPE, PACKAGE_SEQUENCE, etc..). + + + + + The value of the parameter (e.g. PRIORITY_OVERNIGHT, 2, etc..). + + + + + + + + + + + + + + + + + + The tracking number field should be provided when uploading documents after the shipment has been processed or confirmed. This is only applicable if the shipment has been processed with the POST_SHIPMENT_UPLOAD_REQUESTED ETD attribute. + + + + + + + This identifies the document types that can be required. This can also indicate when either a COMMERCIAL_INVOICE or a PRO_FORMA_INVOICE is required through the COMMERCIAL_OR_PRO_FORMA_INVOICE option. + + + + + + + + + + + + + + + + + + + + + + Free form text to be echoed back in the reply. Used to match requests and replies. + + + + + Governs data payload language/translations (contrasted with ClientDetail.localization, which governs Notification.localizedMessage language selection). + + + + + + + + + + + + + + Specifies the date until which the document is available + + + + + + + Specifies the application that is responsible for managing the document id. + + + + + + + + + + + + + + + + + + + + + Distinct value for reason status was assigned. + + + + + Human-readable explanation of document status. + + + + + + + + + Each of these values identifies a specific reason why a document or reference could not be uploaded or associated with a shipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + For an upload making use of the POST_SHIPMENT_UPLOAD option, this will indicate information about the required documents necessary for package movement. + + + + + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + + + + + + + + Specifies the intent or the usage of the documents being uploaded. This provides details about how the documents are relevant to the current transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). + + + + + + + + + + + Used in authentication of the sender's identity. + + + + + This was renamed from cspCredential. + + + + + Credential used to authenticate a specific software application. This value is provided by FedEx after registration. + + + + + + + Two part authentication string used for the sender's identity + + + + + Identifying part of authentication credential. This value is provided by FedEx after registration + + + + + Secret part of authentication key. This value is provided by FedEx after registration. + + + + + + + Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). + + + + + Identifies a system or sub-system which performs an operation. + + + + + Identifies the service business level. + + + + + Identifies the service interface level. + + + + + Identifies the service code level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +