Code Monkey home page Code Monkey logo

czech-post-api's Introduction

Czech post API client in PHP (Parsing podani online)

Build Status Donate

Czech post API client in PHP (Parsing podani online) with custom Label generator

Requirements

  • PHP 5.4 or higher

Installation

Install salamek/czech-post-api using Composer

$ composer require salamek/czech-post-api

or if you want master branch code:

$ composer require salamek/czech-post-api:dev-master

Usage

Create Packages

Creates package/s on Ceska posta

$username = 'my_api_username';
$password = 'my_api_password';
$cookieJar = __DIR__.'/cookieJar.txt';

$czechPostApi = new Salamek\CzechPostApi\Api($username, $password, $cookieJar);

$sender = new Salamek\CzechPostApi\Model\Sender('C9569', 'Olomouc', 'My Compamy s.r.o.', 'My Address', '77900', '[email protected]', '+420123456789', 'http://www.example.cz', Country::CZ);
$recipient = new Salamek\CzechPostApi\Model\Recipient('Olomouc', 'Adam Schubert', 'My Address', '77900', '[email protected]', '+420123456789', 'http://www.salamek.cz', Country::CZ, 'My Compamy a.s.');

$myPackageIdFromNumberSeries = 115;
$weight = 3.15;
$insurance = 100;
$package = new Salamek\CzechPostApi\Model\Package($myPackageIdFromNumberSeries, Product::PACKAGE_TO_HAND, $sender, $recipient, null, null, $insurance, [], 'Package desc', 1, 1, null);

try
{
    $czechPostApi->createPackages([$package]);
}
catch (\Exception $e)
{
    echo $e->getMessage() . PHP_EOL;
}

Get Labels

Returns PDF with label/s for print on paper, two decompositions are supported, LabelDecomposition::FULL (one A4 Label per page) or LabelDecomposition::QUARTER (one label per 1/4 of A4 page)

$sender = new Salamek\CzechPostApi\Model\Sender('Olomouc', 'My Compamy s.r.o.', 'My Address', '77900', '[email protected]', '+420123456789', 'http://www.example.cz', Country::CZ);
$recipient = new Salamek\CzechPostApi\Model\Recipient('Olomouc', 'Adam Schubert', 'My Address', '77900', '[email protected]', '+420123456789', 'http://www.salamek.cz', Country::CZ, 'My Compamy a.s.');

$myPackageIdFromNumberSeries = 115;
$weight = 3.15;
$insurance = 100;
$package = new Salamek\CzechPostApi\Model\Package($myPackageIdFromNumberSeries, Product::PACKAGE_TO_HAND, $sender, $recipient, null, null, $insurance, [], 'Package desc', 1, 1, null);


$rawPdf = Label::generateLabels([$package]);
file_put_contents($package->getPackageNumber() . '.pdf', $rawPdf);

czech-post-api's People

Contributors

salamek avatar jamesthecode avatar

Watchers

James Cloos 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.