{"id":20859088,"url":"https://github.com/andersinno/smartship","last_synced_at":"2025-05-12T08:32:04.626Z","repository":{"id":32926632,"uuid":"73353769","full_name":"andersinno/smartship","owner":"andersinno","description":":snake: Python lib for Posti Smartship :package:","archived":false,"fork":false,"pushed_at":"2022-11-30T12:53:25.000Z","size":85,"stargazers_count":2,"open_issues_count":2,"forks_count":4,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-08-11T09:53:24.428Z","etag":null,"topics":["integration","python","python-library","python3","smartship"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andersinno.png","metadata":{"files":{"readme":"README.rst","changelog":"ChangeLog.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-10T06:33:37.000Z","updated_at":"2022-11-30T12:40:13.000Z","dependencies_parsed_at":"2023-01-14T22:42:22.510Z","dependency_job_id":null,"html_url":"https://github.com/andersinno/smartship","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersinno%2Fsmartship","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersinno%2Fsmartship/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersinno%2Fsmartship/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersinno%2Fsmartship/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andersinno","download_url":"https://codeload.github.com/andersinno/smartship/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225130741,"owners_count":17425506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["integration","python","python-library","python3","smartship"],"created_at":"2024-11-18T04:48:36.091Z","updated_at":"2024-11-18T04:48:36.689Z","avatar_url":"https://github.com/andersinno.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"SmartShip API\n=============\n\nPython library to interact with the Posti SmartShip / Unifaun Online API.\n\nTODO\n----\n\n* Docs\n* Implement remaining attributes in Shipment as per schema\n* Add logging where necessary\n\nCompatibility\n-------------\n\n* Python 2.7+ or Python 3.4+\n\nUsage\n-----\n\nCreating shipments\n~~~~~~~~~~~~~~~~~~\n\nThis API supports the Smartship Shipments api for creating shipments and\nthen downloading the generated PDF's.\n\nCarriers\n''''''''\n\nThere are methods for certain carriers like Posti to cover more common use\ncases. To create a shipment for the Posti carrier, for example:\n\n.. code:: python\n\n    from smartship.carriers.posti import create_shipment\n    receiver = {\n        \"name\": \"Anders Innovations\",\n        \"city\": \"Helsinki\",\n        \"country\": \"FI\",\n        \"address1\": \"Iso Roobertinkatu 20-22\",\n        \"zipcode\": \"00120\"\n    }\n    sender = {\n        \"quickId\": \"1\",\n    }\n    agent = {\n        \"quickId\": \"2\",\n    }\n    shipment = create_shipment(\n        \"12345\",  # Posti customer number\n        \"PO2102\",  # Service ID\n        receiver,\n        sender,\n        [{\"copies\": 1}],  # Parcels\n        agent=agent,  # Optional pickup point\n        pdf_config=pdf_config,  # Optional custom PDF config\n     )\n\nSee more documentation in ``smartship.carriers.posti`` module.\n\nPDF Config\n''''''''''\n\nIf you want to pass a custom ``pdf_config``, it should have the following structure:\n\n.. code:: python\n\n    {\n    \"target1Media\": \"laser-a5\",\n    \"target1YOffset\": 0,\n    \"target1XOffset\": 0\n    }\n\nWith ``\"target1Media\"`` being one of the following options::\n\n    \"laser-a5\"\n    \"laser-2a5\"\n    \"laser-ste\"\n    \"thermo-se\"\n    \"thermo-225\"\n\nYou can customize the offset with ``\"target1YOffset\"`` and ``\"target1XOffset\"`` parameters.\n\nClient\n~~~~~~\n\nTo send shipments and use other API resources, you need a client.\nInitialize the client as follows with username and secret tokens.  Create\nyour API tokens in the `Unifaun Online portal\n\u003chttps://www.unifaunonline.com/\u003e`_.\n\n.. code:: python\n\n    from smartship import Client\n    client = Client(\"username\", \"secret\")\n\nSending shipments\n'''''''''''''''''\n\nSend a shipment as follows:\n\n.. code:: python\n\n    response = client.send_shipment(shipment)\n\nResponse will be a special ``ShipmentResponse`` wrapping a ``HttpResponse`` object with response code and\nJSON content in ``response.data``.\n\nStatus codes:\n\n* 201 - Shipment was created OK\n* 422 - Validation error with the data. Raises a ``ShipmentResponseError``.\n\nFor errors see ``error.response.json()`` for details from Unifaun Online API.\n\nShipment address PDF slips\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nOnce you have the response retrieve associated PDF data as follows:\n\n.. code:: python\n\n    data = response.get_pdfs(client)  # Client needed in case of additional fetching\n    pdf_data = data[0][0]  # Simplest case with a single shipment with a single parcel\n\nAgents\n~~~~~~\n\nRetrieve a list of agents (pickup points) as follows:\n\n.. code:: python\n\n    agents = client.get_agents(\"FI\", \"ITELLASP\", \"Iso Roobertinkatu 20-22\", \"00120\")\n\nResponse will be an ``Agents`` object that can be iterated over for individual agent data.\n\nLocations\n~~~~~~~~~\n\nAs the above agents method is a paid service we also provide an interface to the Posti location service API.\n\n.. code:: python\n\n    from smartship.carriers.posti import get_locations\n    locations = get_locations(country_code=\"FI\", zipcode=\"00120\")\n\nResponse will be a ``Locations`` object that can be iterated over for individual location data.\n\nAdvanced usage\n~~~~~~~~~~~~~~\n\nSee full Smartship `API documentation\n\u003chttps://smartship.unifaun.com/rs-docs/\u003e`_ for a full list of attributes\nthat shipments can be given.  All of these are supported when using\n``smartship.shipments.Shipment`` directly.  Import the relevant objects\nfrom ``smartship.objects`` and pass them to the ``Shipment`` object.\n\nDevelopment\n-----------\n\nRequirements\n~~~~~~~~~~~~\n\nInstall the requirements to a virtual environment with::\n\n    pip install -U setuptools pip  # These should be up to date\n    pip install -r requirements-dev.txt\n\nTests\n~~~~~\n\nTo test in the current virtual environment, run::\n\n    py.test\n\nTo check the coding style, run::\n\n    flake8\n\nTo test all supported environments, run::\n\n    tox\n\nBuilding documentation\n~~~~~~~~~~~~~~~~~~~~~~\n\nBuild the documentation with::\n\n    sphinx-build -b html docs docs/_build\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersinno%2Fsmartship","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandersinno%2Fsmartship","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersinno%2Fsmartship/lists"}