GithubHelp home page GithubHelp logo

php-sdk's Introduction

Parcelshops

$clientBuilder = new ClientBuilder();
$client = $clientBuilder->buildAuthenticatedByPassword('admin', 'admin');


// get list of all parcelshops
$response = $client->getParcelshop()->list(['longitude' => 52.992, 'latitude' => 6.565, 'countryIso' => 'nl', 'limit' => 2]);

// get parcelshop by id
$response = $client->getParcelshop()->get('NL10566');

Shipment

$clientBuilder = new ClientBuilder();
$client = $clientBuilder->buildAuthenticatedByPassword('admin', 'admin');

// create shipment with data array
$response = $client->getShipment()->create([
    'printOptions' => [
        'printerLanguage' => 'PDF',
        'paperFormat' => 'A4'
    ],
    'createLabel' => true,
    'shipments' => [[
        'orderId' => "oasdsadsd",
        'sendingDepot' => "0522",
        'sender' => [
            'companyname' => 'DPD',
            'name1' => "John Do",
            'street' => "John Do Street 9",
            'country' => "NL",
            'postalcode' => "1101BM",
            'city' => "Amsterdam",
            'phone' => "06234234324",
            'email' => "[email protected]",
            'commercialAddress' => true,
        ],
        'receiver' => [
            'name1' => "Jane Do",
            'street' => "Jane Do Street",
            'country' => "NL",
            'postalcode' => "1101BM",
            'city' => "Amsterdam",
            'phone' => "06134233434",
            'commercialAddress' => false
        ],
        'product' => [
            'productCode' => 'CL',
        ],
        "parcels" => [[
            'customerReferences' => ['sadsadsadasdsd'],
            'volume' => '000010000',
            'weight' => 100,
        ]],
    ]]
]);

// create shipmment with objects
private function getPrintOptions(ShipmentRequest $request)
{
    return ObjectFactory::create(PrintOptions::class, [
        'printerLanguage' => 'PDF',
        'paperFormat' => 'A4',
    ]);
}

private function getSender(ShipmentRequest $request)
{
    $sender = ObjectFactory::create(Sender::class, [
        'companyname' => 'John Do - B.V.',
        'name1' => 'John Do',
        'street' => 'John Do Street',
        'housenumber' => '9',
        'postalcode' => '1101BM',
        'city' => 'Hoofddorp',
        'country' => 'NL',
        'email' => '[email protected]',
        'phoneNumber' => '061232323',
        'faxNumber' => '',
        'comment' => '',
        'globalLocationNumber' => 0,
        'commercialAddress' => true,
        'floor' => '',
        'building' => '',
        'department' => '',
        'doorcode' => '',
        'vatnumber' => '',
        'eorinumber' => 'string'
    ]);
    
    return $sender;
}

private function getReceiver(ShipmentRequest $request)
{
    $receiver = ObjectFactory::create(Receiver::class, [
        'name1' => 'Jane Do',
        'street' => 'John Do Street',
        'housenumber' => '9',
        'postalcode' => '1101BM',
        'city' => 'Amsterdam',
        'country' => 'NL',
        'email' => '[email protected]',
        'phoneNumber' => '061232323',
        'commercialAddress' => false,
    ]);
    
    return $receiver;
}

private function getParcels(ShipmentRequest $request)
{
    $parcels[] = ObjectFactory::create(Parcel::class, [
    //            'parcelLabelNumber'    => '100',
        'customerReferences' => ['sadsadsadasdsd'],
        'volume' => '000010000',
        'weight' => 100,
    ]);
    
    return $parcels;
}

private function getShipments(ShipmentRequest $request)
{
    $shipments[] = ObjectFactory::create(ShipmentOrder\Shipment::class, [
        'orderId' => 'jiasjdsoidj',
        'sendingDepot' => '0522',
        'sender' => $this->getSender($request),
        'receiver' => $this->getReceiver($request),
        'product' => [
            'productCode' => 'CL',
        ],
        'parcels' => $this->getParcels($request)
    ]);
    
    return $shipments;
}

$printOptions = $this->getPrintOptions($request);
$shipments = $this->getShipments($request);

$shipmentOrder = ObjectFactory::create(ShipmentOrder::class, [
    'printOptions' => $printOptions,
    'createLabel' => true,
    'shipments' => $shipments
]);

php-sdk's People

Contributors

dpdplugin avatar doenietzomoeilijk 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.