{ "info": { "author": "SMACH Team", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "pyDHL\n===\n\nPython module to work with DHL REST Webservice integration.\n\n\n## pyDHL as module\n```\nimport pyDHL\n```\nBy running it as a module pyDHL will expose the following resources.\n\n### Package\n\nInputs:\n* `weight` (Mandatory): Package weight\n* `length` (Mandatory): Package length\n* `width` (Mandatory): Package width\n* `height` (Mandatory): Package height\n* `price` (Optional): Package price\n* `description` (Optional): Package description\n* `reference` (Optional): Package reference\n\n```\nfrom pyDHL import Package\n\npackage = Package(\n weight=,\n length=,\n width=,\n height=\n )]\n```\n\n### Person\n\nA person is a combination of a Contact and Address information. This class is used for both sender and recipient of the the package.\n\n> Rate request just needs shipment's Address.\n\n#### Address\nInputs:\n\n * `street_lines` (Mandatory): Person's address first line\n * `city` (Mandatory): Person's city\n * `postal_code` (Mandatory): Person's postal code\n * `country` (Mandatory): Person's country, Must oblige to the DHL's country codes.\n * `street_lines2` (Optional): Person's address second line. `'N/A'` by default.\n * `street_lines3` (Optional): Person's address third line.\n\n\n#### Contact\nInputs:\n* `name` (Mandatory): Person's name\n* `phone` (Mandatory): Person's phone\n* `email` (Optional): Person's email. `'null'` by default\n* `company` (Optional): Person's company. `name` by default\n\n### Shipment\nMandatory inputs:\n* `packages`: A list of Package\n* `sender` and `recipient`: Persons (or Address in rate request)\n\nIn order to build a correct Shipment, please refer to the documentation. Some parameters are set by default and others such as `SERVICE_TYPE` are set following\na set of conditions and properties of the Shipment itself.\n\n### Requests\nAll requests will have as input a valid Shipment object or a dict or dict-like structure.\n\nIn order to send requests to DHL Webservices you must first set credentials:\n```\nfrom pyDHL import requests\n\ncredentials = {\n 'account': # your account number\n 'username': # your username\n 'password': # your password\n}\n\nrequests.set_credentials(credentials)\n```\n\nOptionally it is possible to set the 'sandbox' environment for testing purposes.\n```\nrequests.set_sandbox([True|False]) # use DHL's sandbox endpoints\n```\n\nThe result of every request is either the JSON response of the DHL endpoint or, if the requests was wrong, a JSON-like object if twith `error` and `message` keys describing the error. \nEvery requests will update the shipment object given by input if the request was successful.\n\n\n#### Rate Request\nRate Request will return DHL\u2019s product capabilities (products, services and estimated delivery time) and prices (where applicable) for a certain set of input data.\n\n* Input: Shipment\n* Output: JSON response. DHL Rate Request\n\n```\nfrom pyDHL.requests import rate\n\n# create a valid shipment\nresponse = rate(shipment)\n```\n\n\n#### Shipment Request\nThe key elements in the response of the Shipment Request will be a base64 encoded PDF label and the Shipment and Piece identification numbers, which you can use for tracking on the DHL web site.\n\n* Input: Shipment\n* Output: JSON response. DHL Shipment Request\n\n```\nfrom pyDHL.requests import shipment\n\n# create a valid shipment\nresponse = shipment(shipment)\n```\n\n\n#### Update Request\nThe updateShipment request allows for additional pieces to be added to a previously created shipment that has not been picked up by DHL Express/had a scan against it.\n\n* Input: Shipment\n* Output: JSON response. DHL Update Request\n\n```\nfrom pyDHL.requests import update\n\n# create a valid shipment\nresponse = update(shipment)\n```\n\n\n#### Tracking Request\nThe resulting response will provide tracking events at both the Shipment and/or Piece events corresponding to the DHL Waybill(s) submitted.\n\n* Input: Shipment\n* Output: JSON response. DHL Tracking Request\n\n```\nfrom pyDHL.requests import tracking\n\n# create a valid shipment\nresponse = tracking(shipment.id, level=[TRACKING_LAST|TRACKING_ALL])\n```\n\n## pyDHL's Command Line interface\n\nUse pyDHL as a command line program to set up a quick shipment\n```\npyDHL