Giter Site home page Giter Site logo

sdk's Introduction

Latest Unstable Version

MyParcel SDK



Please, star this repository if you use this repository. โญ

Installation

This SDK uses composer.

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

For more information on how to use/install composer, please visit: https://github.com/composer/composer

To install the MyParcel SDK into your project, simply

$ composer require myparcelnl/sdk

Installation without composer

If you don't have experience with composer, it is possible to use the SDK without using composer.

You can download the zip on the projects releases page.

  1. Download the package zip (SDKvx.x.x.zip).
  2. Unzip the contents of the zip, and upload the vendor directory to your server.
  3. In your project, require the file vendor/autoload.php
  4. You can now use the SDK in your project

Requirements

The MyParcel SDK works on php versions 5.6 and 7.0 Also the php curl extension needs to be installed.

Quick start and examples

$myParcelAPI = new MyParcelAPI();

$consignment = (new MyParcelConsignmentRepository())
    ->setApiKey('api_key_from_MyParcel_backoffice')
    ->setCountry('NL')
    ->setPerson('Piet Hier')
    ->setCompany('Piet BV')
    ->setFullStreet('Plein 1945 55b')
    ->setPostalCode('2231JE')
    ->setCity('Amsterdam')
    ->setEmail('[email protected]');
    
$myParcelAPI
    ->addConsignment($consignment)
    ->setPdfOfLabels()
    ->downloadPdfOfLabels();

Testing

Please run vendor/bin/phpunit --bootstrap vendor/autoload.php tests/ to test the application

Available Methods

$myParcelAPI = new MyParcelAPI();

$consignment = (new MyParcelConsignmentRepository())
    ->setApiKey('api_key_from_MyParcel_backoffice')
    ->setCountry('NL')
    ->setPerson('Piet Hier')
    ->setCompany('Piet BV')
    ->setFullStreet('Plein 1945 55b')
    ->setPostalCode('2231JE')
    ->setPackageType(1)
    ->setCity('Amsterdam')
    ->setEmail('[email protected]')
    ->setPhone('+31 (0)634213465')
    ->setLargeFormat(false)
    ->setOnlyRecipient(false)
    ->setSignature(false)
    ->setReturn(false)
    ->setInsurance(false)
    ->setLabelDescription('Order 10034');
    
$myParcelAPI
    ->addConsignment($consignment)

Create concept

$myParcelAPI->createConcepts();

Download labels

$myParcelAPI->setPdfOfLabels();
$myParcelAPI->downloadPdfOfLabels();

Get label link

$myParcelAPI
    ->setLinkOfLabels()
    ->getLinkOfLabels()

Save MyParcel id

After setPdfOfLabels(), setLinkOfLabels() and createConcepts() you can save the api id to your database. With this id you can easily retrieve the latest status.

$consignment->getApiId();

Get barcode

The barcode is available after setPdfOfLabels() and setLinkOfLabels()

$consignment->getBarcode();

Get status

After setPdfOfLabels(), setLinkOfLabels() and createConcepts() you can get the status.

$consignment->getStatus();

Multiple shipments

To create multiple consignments or get one pdf with multiple consignments, set multiple consignments. It's faster and cleaner.

$myParcelAPI = new MyParcelAPI();

foreach ($yourShipments as $shipment) {
    (...) // Set $consignment
    $myParcelAPI
        ->addConsignment($consignment)
}

Later on

In a new request, you can get al the data again.

$consignment = (new MyParcelConsignmentRepository())
    ->setApiKey('api_key_from_MyParcel_backoffice')
    ->setApiId(205670);

$myParcelAPI
    ->addConsignment($consignment)
    ->setLatestData();

$consignment = $myParcelAPI
    ->getOneConsignment();

$status = $consignment->getStatus();
$barcode = $consignment->getBarcode();

Contribute

  1. Check for open issues or open a new issue to start a discussion around a bug or feature.
  2. Fork the repository on GitHub to start making your changes.
  3. Write one or more tests for the new feature or that expose the bug.
  4. Make code changes to implement the feature or fix the bug.
  5. Send a pull request to get your changes merged and published.

sdk's People

Watchers

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