Implementation of create shipment service
With this implementation, we add a service that you can call to create a shipment in Correos and return an object with a label_file
that is a PDF file in base64 and the shipment code. Example of usage:
from correos_preregistro.services.shipment import PreRegistrationShipment
from correos_preregistro.client import RawClient
from correos_preregistro.resources import Receiver, Sender, Package
user = "trest_user"
password = "test_password"
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",
)
sender = Sender(
name="SomConnexio",
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",
)
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.shipment_code
'PQXXX10721396360103015R'
shipment.label_file
'4MDAyMCAwMDAwMCBuIAowMDAwMDgwMjkyIDAwMDAwIG4gCjAwMDAwODA1NTQgMDAwMDAgbi .... 4MDAyMCAwMDAwMCBuIAowMDAwMDgwMjkyIDAwMDAwIG4gCjAwMDAwODA1NTQgMDAwMDAgbi'
TODO
-
Fix usage of etree or Zeep libraries. -
Add tests (services and resources). -
Logging??
Edited by Daniel Palomar