Skip to main content

pipeline status coverage report

⚠️ WORK IN PROGRESS ⚠️

This library is a Python wrapper for accessing PreregistroEnvio Correos SOAP API.

You can find the complete documentation of the API here.

Operations

  • PreRegistroEnvio - 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-preregistro

Configuration Environment

Usage

Create PreRegistroEnvio shipment

Create a preregistroenvio annd save a file with the shipment number in the name and the PDF label as content:

>>> from correos_preregistro.services.shipment import PreRegistrationShipment
>>> 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()

Development

Setup environment

  1. Install pyenv
curl https://pyenv.run | bash
  1. Build the Python version
pyenv install  3.7.13
  1. Create a virtualenv
pyenv virtualenv 3.7.13 correos-preregistro
  1. Install dependencies
pyenv exec pip install -r requirements.txt
  1. Install pre-commit hooks
pyenv exec pre-commit install

Install the package locally in development mode

When 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.

pip install -e .

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:

  1. Add any entries missing from merged merge requests.
  2. Duplicate the [Unreleased] header.
  3. 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:

  1. Update the __version__ var in __init__.py matching the version you specified in the CHANGELOG.
  2. Open a merge request with these changes for the team to approve
  3. Merge it, add a git tag on that merge commit and push it.
  4. Once the pipeline has successfully passed, your package had been published.

Metadata

Release files for correos-preregistro 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for correos-preregistro 0.0.10
File Size Uploaded Provenance Actions
correos_preregistro-0.0.10.tar.gz 196.4 kB Without provenance Details for correos_preregistro-0.0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for correos-preregistro 0.0.10
File Interpreter ABI Platform Actions
correos_preregistro-0.0.10-py2.py3-none-any.whl Python 2, Python 3 none any Details for correos_preregistro-0.0.10-py2.py3-none-any.whl

Total release size: 206.4 kB

Release files / correos_preregistro-0.0.10.tar.gz

Download URL correos_preregistro-0.0.10.tar.gz
Size 196.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6638bf1fe5abebaa00362cc9c886412a87745416a5325d17e67090d1e31a0902
BLAKE2b-256 checksum
How to use checksums
c51bcead55f30a9d196a2489a2fa90e100a8b3392c0660acbdd24f204b6da3a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / correos_preregistro-0.0.10-py2.py3-none-any.whl

Download URL correos_preregistro-0.0.10-py2.py3-none-any.whl
Size 10.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7e7c4c5b95aa141c90aaae89acfd1857727cd6cf24b087b33b5d9f7341aafd3f
BLAKE2b-256 checksum
How to use checksums
ddc818764ad5d61159785e91c369372db826866401dd0bf23ee4f9b01b897cc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for correos-preregistro 0.0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page