Giter Site home page Giter Site logo

parcel-pro-php-api-client's Introduction

Parcel Pro API client

Installing

composer require wedesignit/parcel-pro-php-api-client

Creating the connector

$client = new \WeDesignIt\ParcelPro\Client($userId, $apiKey);
$parcelPro = new \WeDesignIt\ParcelPro\ParcelPro($client);

After this, the $parcelPro class can return Endpoints which can be called.

The endpoint methods can either be called with plain arrays or the fluent Resource classes can be used.

Usage examples

Always: Setting up

This applies to every following example and should be prepended to every example.

$client = new \WeDesignIt\ParcelPro\Client(
    '<your login ID>'
    '<your API key>'
);
$parcelPro = new \WeDesignIt\ParcelPro\ParcelPro($client);

Check if API key is valid

$parcelPro->apiKey()->isValid();

Retrieving the shipment types

$parcelPro->shipmentType()->list();

Response example (from the docs):

[
    [
        "Id" => 8,
        "Type" => "DFY",
        "Code" => "00",
        "Label" => "DFY",
        "Carrier_Id" => 2,
        "Carrier" => "DHL",
        "CarrierNaam" => "DHL",
        "CarrierLabel" => "",
        "CarrierKlantcode" => "1234567",
        "Buitenland" => 1,
        "Benelux" => 1,
        "EU" => null,
        "Worldwide" => null,
        "Land" => null,
        "Tolplichtig" => null,
        "InleverenOpServicePoint" => 1,
        "ServicePoint" => 1,
        "HandtekeningVoorOntvangst" => 1,
        "NietBijBuren" => 1,
        "AvondLevering" => null,
        "ZaterdagLevering" => null1,
        "1100Levering" => null,
        "VerhoogdAansprakelijk" => 1,
        "Rembours" => null,
        "MiniPallet" => null,
        "Pallet" => null,
        "Collo" => null
    ],
    [
        "Id" => 9,
        "Type" => "PostNL",
        "Code" => "3085",
        "Label" => "Standaard Pakket",
        "Carrier_Id" => 3,
        "Carrier" => "PostNL",
        "CarrierNaam" => "PostNL",
        "CarrierLabel" => "",
        "CarrierKlantcode" => "7654321",
        "Buitenland" => 0,
        "Benelux" => 0,
        "EU" => null,
        "Worldwide" => null,
        "Land" => null,
        "Tolplichtig" => null,
        "InleverenOpServicePoint" => null,
        "ServicePoint" => 1,
        "HandtekeningVoorOntvangst" => 1,
        "NietBijBuren" => 1,
        "AvondLevering" => null,
        "ZaterdagLevering" => null1,
        "1100Levering" => null,
        "VerhoogdAansprakelijk" => 1,
        "Rembours" => null,
        "MiniPallet" => null,
        "Pallet" => null,
        "Collo" => null
        ]
]

Which will then return a boolean value.

Sending a shipment

$shipment = [
    'Carrier'            => 'Carrier name',
    'Type'               => 'Shipment type',
    'Referentie'         => 'E.g. your order number',
    'Zaterdaglevering'   => '1',
    'NaamAfzender'       => 'Michael Scott',
    'StraatAfzender'     => 'Street',
    'NummerAfzender'     => '11',
    'ToevoegingAfzender' => 'A',
    'PostcodeAfzender'   => '1000 AB',
    'PlaatsAfzender'     => 'Scranton',
    'LandAfzender'       => 'NL',
    'Naam'               => 'Dwight Schrute',
    'Straat'             => 'Street'
    'Nummer'             => '11',
    'Toevoeging'         => 'A',
    'Postcode'           => '1000 AB',
    'Plaats'             => 'Scranton',
    'Land'               => 'NL',
    'Email'              => '[email protected]',
    'AantalPakketten'    => 1,
    'Gewicht'            => 1,
    'Opmerking'          => 'Thanks to the world\'s #1 boss',
];

$parcelPro->shipment()->create($shipment);

If you like a more object-oriented approach you can also use the Shipment Resource class (and its subclasses).

Retrieving a shipping label

If needed for printing. Note you already get a label URL back from the shipment create call which you can also present to your users to directly access the label.

// for PDF version
$label = $parcelPro->shippingLabel()->get($shipmentId);
// for HTML version
$pdf = false;
$label = $parcelPro->shippingLabel()->get($shipmentId, $pdf);

parcel-pro-php-api-client's People

Contributors

pvankouteren avatar

Watchers

 avatar  avatar

Forkers

storewire

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.