GithubHelp home page GithubHelp logo

michalpulpan / pplmyapi Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 4.17 MB

PPL API wrapper written in Python. Helps with data transfer to and from PPL (Professional Parcel Logistic)

License: MIT License

Python 99.85% Shell 0.15%
dhl ppl python rest soap wrapper-library

pplmyapi's Introduction

📦📦 pplmyapi (Python PPL myAPI wrapper)

Czech PPL (Professional Parcel Logistic) API wrapper written in Python. Helps you to communicate with PPL myAPI without worring about fetching access tokens and constructing your own requests. All (hopefully) done for you in the background.

Install it from PyPI

pip install pplmyapi

Usage

This is still a work in progress, so the API might change in the future. However, the basic usage is as follows:

  1. Create a PPL instance with your credentials
  2. obtain a RESTConnector instance from the PPL instance.
  3. use the RESTConnector instance to communicate with the PPL REST API (myAPI2)

Send a package

# Create Package instance with all the required data and 6 packages in the set
package = Package(
    reference_id="123456789",
    package_product_type=Product.PPL_PARCEL_CZ_PRIVATE_COD,
    note = "test",
    recipient=Recipient(
        name="John Doe",
        city="Hradec Králové",
        street="Hlavní 1",
        zip_code="50001",
        phone="123456789",
        email="[email protected]",
        country = 'CZ'
    ),
    sender=Sender(
        name="Test s.r.o.",
        street="Testovací 55/36",
        city="Praha",
        zip_code="11000",
        country="CZ",
    ),
    payment_info=PaymentInfo(
        cod_price=100,
        cod_currency='CZK',
        cod_vs='123456789',
        insurance_price=100,
        insurance_currency='CZK',
        specific_symbol='123456',
        bank_account='123456789',
        bank_code='0300'
    ),
    weighted_package_info=WeightedPackageInfo(
        weight=10.22,
    ),
    package_set=(
        PackageSet(
            total_packages = 6,
        )
    ),
    flags=[
        PackageFlag(
            code=Flag.CL,
            value=True
        )
    ],
)
# create packages
packages = [package]

# create rest_connector
rest_con = ppl.connector()

# create rest_action
response = rest_con.post_shipments(
    packages=packages,
    file_path = './out_test',
    file_name = 'test_010223.pdf',
)

Response from the API is a dictionary containing the following keys:

  • labels: base64 encoded labels from the API (all together)
  • packages: list of Package instances (initionaly passed to the post_shipments function) with extended shipment_number attribute, label_base64 attribute (with single label) and extended package_set attribute (with related_packages attribute containing list of Package instances related to the current package with the same reference_id attribute but different shipment_number attribute)

Get label for a package

# TODO

Development

If you're keen on contributing to this project, you can do so by forking this repository and creating a pull request. Please make sure to follow the PEP8 style guide.

pplmyapi's People

Contributors

michalpulpan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.