Package: correos-preregistro
:warning: WORK IN PROGRESS :warning:This library is a Python wrapper for accessing PreregistroEnvio Correos SOAP API.You can find the complete documentation of the APIhere.OperationsPreRegistroEnvio - Customers will provide all the necessary data for pre-registering a shipment and will receive in return the pre-registered shipment code and label with which to label the shipment in the format that they requested (XML or base64 encoded PDF format)Installation$ pip install correos-preregistroConfiguration EnvironmentUsageCreate PreRegistroEnvio shipmentCreate a preregistroenvio annd save a file with the shipment number in the name and the PDF label as content:>>>fromcorreos_preregistro.services.shipmentimportPreRegistrationShipment>>>user="utest">>>password="ptest">>>client=RawClient(user,password)>>>receiver=Receiver(...name="Emilio Jose",...surname="Marti Gomez",...address="Cami del corrar, 51, Baix B",...city="Moralla",...state="Valencia",...zip="03015",...phone="666555444",...email="emilio.jose@marti.com",...lang="CA",...sms_phone="666555444",...)>>>sender=Sender(...name="SomConnexio",...nif="F66380676",...address="C/ de les Moreres, 119",...city="El Prat de Llobregat",...state="Barcelona",...zip="08820",...phone="931311728",...email="serveis@somconnexio.coop",...lang="CA",...)>>>package=Package(...weight=1,...postage_type="FP",...product_code="S0132",...delivery_modality="ST",...weight_type="R",)>>>shipment=PreRegistrationShipment.create(...client=client,...code="XXX1",...receiver=receiver,...sender=sender,...package=package,...)>>>shipment.shipment_code"PQXXX10721392610108021C">>>label_file_name="shipment_label_{}.pdf".format(shipment.shipment_code)>>>f=open(shipment.get_pdf_label(),"wb")>>>f.write(pdf_label)>>>f.close()DevelopmentSetup environmentInstallpyenvcurlhttps://pyenv.run|bashBuild the Python versionpyenvinstall3.7.13Create a virtualenvpyenvvirtualenv3.7.13correos-preregistroInstall dependenciespyenvexecpipinstall-rrequirements.txtInstall pre-commit hookspyenvexecpre-commitinstallInstall the package locally in development modeWhen we are using this package in other projects, we need to install it to use as import in the other files. Install the package in development mode helps us to modify the package and use the new version in live in the other project.pipinstall-e.Test the HTTP requestWe are using the HTTP recording plugin of Pytest:pytest-recording.With VRC we can catch the HTTP responses and then, execute the tests using them.To add a new test:Expose the needed envvars. Look for them at theConfiguration Environment sectionExecute the tests usingpytestcommand:If you are writing a new test that is making requests, you should run:$ pytest --record-mode=once path/to/your/testYou might need to record requests for an specific tests. In that case make sure to only run the tests affected and run$ pytest --record-mode=rewrite path/to/your/testAdd the newcassetesto the commit and push them.The CI uses the cassetes to emulate the HTTP response in the test.Run test suite$ toxFormattingWe useBlackas formatter.
First to commit, tun theblackcommand:$ black .
All done! ✨ 🍰 ✨
29 files left unchanged.DarkerBlack is a great formatter, but to mantain your code without execute theblackcommand avery time, you can configure your IDE to usedarkerto format only the changed or added code when you save the file.Release processUpdate CHANGELOG.md following this steps:Add any entries missing from merged merge requests.Duplicate the[Unreleased]header.Replace the secondUnreleasedwith a version number followed by the current date. Copy the exact format from previous releases.Then, you can release and publish the package to PyPi:Update the__version__var in__init__.pymatching the version you specified in the CHANGELOG.Open a merge request with these changes for the team to approveMerge it, add a git tag on that merge commit and push it.Once the pipeline has successfully passed, your package had been published.