2017 © Pedro PelĂĄez
 

library consignor-shipment-server-php-sdk

A PHP SDK for Consignor

image

loevgaard/consignor-shipment-server-php-sdk

A PHP SDK for Consignor

  • Tuesday, February 27, 2018
  • by loevgaard
  • Repository
  • 1 Watchers
  • 0 Stars
  • 90 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 70 % Grown

The README.md

Consignor Shipment Server PHP SDK

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score, (*1)

A library for making requests to the Consignor Shipment Server API., (*2)

Install

Via Composer, (*3)

$ composer require loevgaard/consignor-shipment-server-php-sdk

Usage

Here is the example also used on Consignors own page. It submits a shipment and saves the labels as PDF's., (*4)

<?php
require_once 'vendor/autoload.php';

$actor = '63';
$key = 'sample';
$env = \Loevgaard\Consignor\ShipmentServer\Client\Client::ENV_DEV;
$client = new \Loevgaard\Consignor\ShipmentServer\Client\Client($actor, $key, [], null, null, $env);

$data = [
    'Kind' => 1,
    'ActorCSID' => $actor,
    'ProdConceptID' => 1032,

    'Addresses' => [
        [
            'Kind' => 2,
            'Name1' => 'Test sender',
            'Street1' => 'Test Address',
            'PostCode' => '0580',
            'City' => 'Oslo',
            'CountryCode' => 'NO'],
        [
            'Kind' => 1,
            'Name1' => 'Ola Testmann',
            'Street1' => 'Test Address 1',
            'PostCode' => '0580',
            'City' => 'Oslo',
            'CountryCode' => 'NO'
        ]
    ],

    'Lines' => [
        [
            'PkgWeight' => 5000,
            'Pkgs' => [
                [
                    'ItemNo' => 1
                ]
            ]
        ]
    ]
];

$options = [
    'Labels' => 'PDF'
];

$request = new \Loevgaard\Consignor\ShipmentServer\Request\SubmitShipmentRequest($data, $options);

/** @var \Loevgaard\Consignor\ShipmentServer\Response\SubmitShippingResponse $response */
$response = $client->doRequest($request);

if ($response->wasSuccessful()) {
    echo "The request was successful, labels saved in: ".getcwd()."\n";
    $response->saveLabels('label-', getcwd());
} else {
    echo "The request was not successful\n";
    print_r($response->getErrors());
}

Framework integration

There is a Symfony bundle available that integrates this SDK: - Consignor Shipment Server Bundle, (*5)

Testing

$ composer test

License

The MIT License (MIT). Please see License File for more information., (*6)

The Versions