Correos Seguimiento 0.3.0 | Coderz Repository

correos-seguimiento 0.3.0

Last updated:

0 purchases

correos-seguimiento 0.3.0 Image
correos-seguimiento 0.3.0 Images

Free

Languages

Categories

Add to Cart

Description:

correosseguimiento 0.3.0

:warning: WORK IN PROGRESS :warning:
This library is a Python wrapper for accessing Seguimiento Correos JSON API.
Operations

The API will provide all the necessary data for tracking a shipment. With this module you can check if the parcel is already delivered or relabeled and get the new tracking code.

More info about the API in docs.
Installation
$ pip install correos-seguimiento

Usage
Check if shipment is delivered
>>> from correos_seguimiento.services.shipment import TrackingShipment
>>>
>>> shipment = TrackingShipment("XXX", "XXX", "PQXXX10721392610108021C").build()
>>> shipment.is_delivered()
False
>>> shipment.is_delivered()
True

Check if shipment is relabeled and get the new tracking code
>>> from correos_seguimiento.services.shipment import TrackingShipment
>>>
>>> shipment = TrackingShipment("XXX", "XXX", "PQXXX10721392610108021C").build()
>>> shipment.is_delivered()
False
>>> shipment.is_relabeled()
True
>>> shipment.get_relabeled_shipment_code()
"PY53VM9100000810108640T"

Check if shipment is returned
>>> from correos_seguimiento.services.shipment import TrackingShipment
>>>
>>> shipment = TrackingShipment("XXX", "XXX", "PQXXX10721392610108021C").build()
>>> shipment.is_returned()
False
>>> shipment.is_returned()
True

Development
Setup environment

Install pyenv

curl https://pyenv.run | bash


Build the Python version

pyenv install 3.7.13


Create a virtualenv

pyenv virtualenv 3.7.13 correos-seguimiento


Install dependencies

pyenv exec pip install -r requirements.txt


Install pre-commit hooks

pyenv exec pre-commit install

Test the HTTP request
We 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 the Configuration Environment section
Execute the tests using pytest command:
If you are writing a new test that is making requests, you should run:

$ pytest --record-mode=once path/to/your/test


You 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/test


Add the new cassetes to the commit and push them.
The CI uses the cassetes to emulate the HTTP response in the test.

Run test suite
$ tox

Formatting
We use Black as formatter.
First to commit, tun the black command:
$ black .
All done! ✨ 🍰 ✨
29 files left unchanged.

Darker
Black is a great formatter, but to mantain your code without execute the black command avery time, you can configure your IDE to use darker to format only the changed or added code when you save the file.
Release process
Update CHANGELOG.md following this steps:

Add any entries missing from merged merge requests.
Duplicate the [Unreleased] header.
Replace the second Unreleased with 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 setup.py matching the version you specified in the CHANGELOG.
Open a merge request with these changes for the team to approve
Merge it, add a git tag on that merge commit and push it.
Once the pipeline has successfully passed, your package had been published.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.