Git Product home page Git Product logo

poczta-polska-e-nadawca-python's Introduction

poczta-polska-e-nadawca-python

Short and quick class easing use of Poczta Polska e-nadawca WSDL API. It exposes service methods and factory types directly on instance.

Installation

pip install  poczta_polska_enadawca

Setup and usage with Django

Define following variables in your project settings:

  • POCZTA_POLSKA_API_USERNAME
  • POCZTA_POLSKA_API_PASSWORD
  • POCZTA_POLSKA_API_SANDBOX_USERNAME
  • POCZTA_POLSKA_API_SANDBOX_PASSWORD

After that - use as follows:

from poczta_polska_enadawca.api import PocztaPolskaAPI


PocztaInstance = PocztaPolskaAPI()

and you can call:

PocztaInstance.hello('Poczta API')

Setup and usage rest of the world :)

from poczta_polska_enadawca.api import PocztaPolskaAPI
from poczta_polska_enadawca.settings import PocztaPolskaSettingsObject


PocztaPolskaSettings = PocztaPolskaSettingsObject()
PocztaPolskaSettingsObject.POCZTA_POLSKA_API_USERNAME = 'foo'
PocztaPolskaSettingsObject.POCZTA_POLSKA_API_PASSWORD = 'bar'
PocztaPolskaSettingsObject.POCZTA_POLSKA_API_SANDBOX_USERNAME = 'foo'
PocztaPolskaSettingsObject.POCZTA_POLSKA_API_SANDBOX_PASSWORD = 'bar'

PocztaInstance = PocztaPolskaAPI(initZeep=False) #we're not executing default init
PocztaInstance.set_config(PocztaPolskaSettings) #provide the object with settings defined above
PocztaInstance.init_zeep() #initialize zeep

That should be working at this moment.

Where is the factory and service ?!

If you insist they're avaliable as .service and .factory on instance.

BUT

Factory is exposed directly as dictionary on the API instance. It's avaliable after execution of init_zeep.

PocztaInstance['adresType']
PocztaInstance['przesylkaPoleconaKrajowaType']
PocztaInstance['przesylkaEPOType']

Service methods are also avaliable DIRECTLY on instance. They're rewired after execution of init_zeep. WARNING ! Example below does not work it only shows few simple calls.

PocztaInstance = PocztaPolskaAPI() #default init, you might need the fancy one few lines above

PocztaInstance.hello("Python")

adresType = PocztaInstance['adresType']
adresType.nazwa = 'foo'
adresType.ulica = 'bar'

przesylkaPoleconaKrajowaType = PocztaInstance['przesylkaPoleconaKrajowaType']
przesylkaPoleconaKrajowaType.adres = adresType

PocztaInstance.clearEnvelope()
PocztaInstance.addShipment(przesylkaPoleconaKrajowaType)
PocztaInstance.sendEnvelope()

I want testing Enviroment, Labs Endpoints ...

Class init uses following key arguments: PocztaPolskaAPI(useTest=False, useLabs=False, initZeep=True)

  • useTest (default -> False) - run the calls against sandbox enviroment -> https://en-testwebapi.poczta-polska.pl
  • useLabs (default -> False) - run the calls against labs endpoints
  • initZeep (default -> True) - initialize zeep on init.

I need to debug zeep ...

PocztaInstance.enable_zeep_debug()

Few examples of init:

If you need the test enviroment:

PocztaInstance = PocztaPolskaAPI(useTest=True)

If you need the labs test enviroment:

PocztaInstance = PocztaPolskaAPI(useTest=True, useLabs=False)

poczta-polska-e-nadawca-python's People

Contributors

haloween avatar

Watchers

Tadeusz Kurpiel 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.