{ "info": { "author": "Mateus Interciso", "author_email": "minterciso@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Brazilian Post Office Module\n\nThis module is to help whoever needs a API to query the brazilian post office to know:\n1. When the package will arrive\n2. How much will it cost\n3. Possibility to query different shipping methods\n\n# Installation\n\nTo install this module simply add it via pip\n\n pip install pyBRPost\n\nIt requires some extra modules:\n\n pip install requests xmltodict\n\n# Usage\n\nTo use this module all you need is to configure the package information and execute the get_fare()\nmethod. Here's a simple test:\n\n from br_posts import fare, options\n\n tst = fare.Fare()\n tst.requestServices = [\n options.Service.SEDEX_10_RETAIL,\n options.Service.SEDEX_12,\n options.Service.SEDEX_CASH,\n options.Service.SEDEX_RETAIL,\n options.Service.SEDEX_TODAY_RETAIL,\n options.Service.PAC_CASH,\n options.Service.PAC_RETAIL\n ]\n tst.dimensions['weight'] = 0.875\n tst.dimensions['length'] = 16\n tst.dimensions['width'] = 11\n tst.dimensions['height'] = 10\n tst.dimensions['diameter'] = 10\n tst.cepDestination = '09571000'\n tst.cepOrigin = '24738791'\n tst.value = 2500.75\n tst.packageFormat = options.ObjectType.BOX\n tst.extras['receiving_warning'] = True\n try:\n fare_return = tst.get_fare()\n except Exception as error:\n print(error)\n exit(-1)\n for ret in fare_return:\n print('Service: {serv}'.format(serv=ret['service']))\n error_code = ret['error_code']\n if error_code != 0:\n print('Error ({code}): {desc}'.format(code=error_code, desc=ret['error_msg']))\n else:\n print('Time: {time} day{mult}'.format(time=ret['delivery_time'], mult='s' if ret['delivery_time'] > 1 else ''))\n print('Value: R$ {val}'.format(val=ret['value']))\n print('Deliver on saturday? {sat}'.format(sat=ret['delivery_saturday']))\n print('Delivery on: {delivery_date}'.format(\n delivery_date=tst.get_estimated_delivery_day(add_days=1,\n travel_days=ret['delivery_time'],\n deliver_on_saturday=ret['delivery_saturday']).strftime('%d/%m/%Y')))\n print('')\n\nThis is a little big, so let's drill down this example in 3 easy steps:\n\n## Import\n\n from br_posts import fare, options\n\nThose are the basic imports, there's also a 'ship.errors' import that you can use to capture\nthe exceptions.\n\nThe 'ship.options' file contains the enum classes Service and ObjectType that, are responsible to configure\nthe methods to send the package, and the format of the package.\n\nThose are the options you have for the Service enum:\n* SEDEX_RETAIL - Common Sedex type\n* SEDEX_TO_CHARGE - Sedex to be charged on the receiver\n* SEDEX_10_RETAIL - Sedex 10\n* SEDEX_TODAY_RETAIL - Sedex on the same day\n* SEDEX_CASH - Sedex payment on cash\n* SEDEX_PAYMENT_ON_DELIVERY - Sedex payment on delivery\n* SEDEX_12 - Sedex 12 \n* PAC_RETAIL - Common PAC\n* PAC_CASH - PAC on cash\n* PAC_PAYMENT_ON_DELIVERY - PAC with payment on delivery\n\nAnd those are the options you have for the ObjectType enum:\n* BOX - Most common of Sedex for big products\n* ROLL - Can be sometimes referred as \"prism\"\n* LETTER - Anything that can be sent as ane Envelope\n\nYou can find more of those options on the [Correios site](http://correios.com.br/).\n\n## Setup\n\nAfter importing, you need to instantiate a 'ship.fare.Fare' object, and create the initial setup:\n\n tst = fare.Fare()\n tst.requestServices = [\n options.Service.SEDEX_10_RETAIL,\n options.Service.SEDEX_12,\n options.Service.SEDEX_CASH,\n options.Service.SEDEX_RETAIL,\n options.Service.SEDEX_TODAY_RETAIL,\n options.Service.PAC_CASH,\n options.Service.PAC_RETAIL\n ]\n tst.dimensions['weight'] = 0.875\n tst.dimensions['length'] = 16\n tst.dimensions['width'] = 11\n tst.dimensions['height'] = 10\n tst.dimensions['diameter'] = 10\n tst.cepDestination = '09571000'\n tst.cepOrigin = '24738791'\n tst.value = 2500.75\n tst.packageFormat = options.ObjectType.BOX\n tst.extras['receiving_warning'] = True\n\nOf all those options, only those are mandatory:\n* requestService\n* dimenstions\n* cepDestination\n* cepOrigin\n* packageFormat\n\nIf some of those are missing, or wrong, there's 2 possible exceptions that will be thrown when\nexecuting the get_fare() method:\n* InvalidParameterError\n* MissingParametersError\n\n## Getting the fare\n\nAfter importing and setting up the information to query, you should call the get_fare() method:\n\n try:\n fare_return = tst.get_fare()\n except Exception as error:\n print(error)\n exit(-1)\n\nThis method will POST the Correios API with the setup you created before, if there's anything wrong\nwith the setup it'll raise an exception. If everything works out smoothly, it'll return a list\nwith all the results (usually one for 'requestService'), and you can easily read them as a dictionary:\n\n for ret in fare_return:\n print('Service: {serv}'.format(serv=ret['service']))\n error_code = ret['error_code']\n if error_code != 0:\n print('Error ({code}): {desc}'.format(code=error_code, desc=ret['error_msg']))\n else:\n print('Time: {time} day{mult}'.format(time=ret['delivery_time'], mult='s' if ret['delivery_time'] > 1 else ''))\n print('Value: R$ {val}'.format(val=ret['value']))\n print('Deliver on saturday? {sat}'.format(sat=ret['delivery_saturday']))\n\nThere's one \"gift\" inside this package that has **nothing** to do with the Correios API, an \nestimated delivery method, that you can call to get a possible date on the delivery: \n\n print('Delivery on: {delivery_date}'.format(\n delivery_date=tst.get_estimated_delivery_day(add_days=1,\n travel_days=ret['delivery_time'],\n deliver_on_saturday=ret['delivery_saturday']).strftime('%d/%m/%Y')))\n print('')\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/minterciso/pyBRPost", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "pyBRPost", "package_url": "https://pypi.org/project/pyBRPost/", "platform": "", "project_url": "https://pypi.org/project/pyBRPost/", "project_urls": { "Homepage": "https://github.com/minterciso/pyBRPost" }, "release_url": "https://pypi.org/project/pyBRPost/1.0.1/", "requires_dist": [ "requests (>=2.21.0)", "xmltodict (>=0.12)" ], "requires_python": "", "summary": "Python module to query Brazilian Post Office regarding shipping methods", "version": "1.0.1" }, "last_serial": 5105491, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "bf7b895bee1db1147267d729ee7b1b53", "sha256": "e6864b0c946f63d31a3a900678aba2790af63166cd977b3e69199cd2862442ee" }, "downloads": -1, "filename": "pyBRPost-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "bf7b895bee1db1147267d729ee7b1b53", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7152, "upload_time": "2019-04-05T20:06:58", "url": "https://files.pythonhosted.org/packages/57/bc/f0f9a2c477f7745558231668c39de88b01c887dfa66d368d4b03e4c0ef36/pyBRPost-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dd1d594a19274c9887899b7c97569802", "sha256": "d68661c8f0600965539e2959aff91d45038566deb913e9a38e06dff5e6affcf5" }, "downloads": -1, "filename": "pyBRPost-1.0.0.tar.gz", "has_sig": false, "md5_digest": "dd1d594a19274c9887899b7c97569802", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5683, "upload_time": "2019-04-05T20:07:01", "url": "https://files.pythonhosted.org/packages/aa/1f/74eb8474e1ed683d2c7f5ddfd2d055a25cfe3f9f2c4547e7f815fd8dfa6c/pyBRPost-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "94ef3902ff2ef9a0c3bacf2258a8658b", "sha256": "0d71c7f70dec3d39d19da3280a294133d7002ee7162175cfe8c8d4edd88136b0" }, "downloads": -1, "filename": "pyBRPost-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "94ef3902ff2ef9a0c3bacf2258a8658b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7175, "upload_time": "2019-04-05T20:17:09", "url": "https://files.pythonhosted.org/packages/89/19/7795c3ae8855294723a540f2231fb9d26cf89058c13201935f9333b3eeb7/pyBRPost-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6b680343137a439e30d94ac0a10ebe5b", "sha256": "ba3c2144d8b0bde68109643662183b4e95c2df1a1f1f6d33d15f9a9dcd3373cd" }, "downloads": -1, "filename": "pyBRPost-1.0.1.tar.gz", "has_sig": false, "md5_digest": "6b680343137a439e30d94ac0a10ebe5b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5719, "upload_time": "2019-04-05T20:17:11", "url": "https://files.pythonhosted.org/packages/51/f5/d1436a41d55929aa475fa07fc14284b3f9c4a5d9cc47ffccd30ca1e1ea4b/pyBRPost-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "94ef3902ff2ef9a0c3bacf2258a8658b", "sha256": "0d71c7f70dec3d39d19da3280a294133d7002ee7162175cfe8c8d4edd88136b0" }, "downloads": -1, "filename": "pyBRPost-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "94ef3902ff2ef9a0c3bacf2258a8658b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7175, "upload_time": "2019-04-05T20:17:09", "url": "https://files.pythonhosted.org/packages/89/19/7795c3ae8855294723a540f2231fb9d26cf89058c13201935f9333b3eeb7/pyBRPost-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6b680343137a439e30d94ac0a10ebe5b", "sha256": "ba3c2144d8b0bde68109643662183b4e95c2df1a1f1f6d33d15f9a9dcd3373cd" }, "downloads": -1, "filename": "pyBRPost-1.0.1.tar.gz", "has_sig": false, "md5_digest": "6b680343137a439e30d94ac0a10ebe5b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5719, "upload_time": "2019-04-05T20:17:11", "url": "https://files.pythonhosted.org/packages/51/f5/d1436a41d55929aa475fa07fc14284b3f9c4a5d9cc47ffccd30ca1e1ea4b/pyBRPost-1.0.1.tar.gz" } ] }