Giter VIP home page Giter VIP logo

bringapi's Introduction

Bring API PHP

Bring API PHP is a library to contact Bring API for prices, booking, reports and so on. I did not find anything that i could use for my project with PHP and Bring API. So i needed a good library that was reusable. This is used in production of a large Norwegian wholesaler.

Install

Composer (recommended)

Can be installed directly with Composer.

Run the following command in correct directory.

$ composer require crakter/bringapi

Requirements

  • PHP version 7.0.0 or higher
  • PHP extension php_simplexml enabled (enabled by default in 5.1.2 and above)

Supported Apis

  • Shipping Guide API
    • Get estimated prices
    • Get Estimated delivery time
    • Get Estimated shipment prices, delivery time and more
  • Booking API
    • List customer names
    • Book Shipments
    • Order pickups
  • Tracking API
    • Track shipments (also logged in)
    • Download Signature
  • Reports API
    • List available customers
    • List available reports for a customer
    • Generate a report
    • Check the status of a report
    • List invoice numbers
  • Postal Code API
    • Lookup postal code

Basic usage

Tracking as logged in

If you remove the authorizationModule you can track like normal user.

use Crakter\BringApi\Entity\TrackingEntity;
use Crakter\BringApi\Clients\Authorization;
use Crakter\BringApi\Clients\Tracking\TrackingEndpoint;

$trackingEntity = (new TrackingEntity)->set(['q' => 'TESTPACKAGE-AT-PICKUPPOINT']); // Can be used like this
//$trackingEntity = (new TrackingEntity)->setQ('TESTPACKAGE-AT-PICKUPPOINT'); // Can also be used like this
/* And like this
$trackingEntity = (new TrackingEntity);
$trackingEntity->q = 'TESTPACKAGE-AT-PICKUPPOINT';
*/
$authorizationModule = (new Authorization)
    ->setApiKey('1234abc-abcd-1234-5678-abcd1234abcd')
    ->setClientId('[email protected]')
    ->setClientUrl('http://example.com');

$tracking = (new TrackingEndpoint)
    ->setAuthorizationModule($authorizationModule)
    ->setApiEntity($trackingEntity)
    ->send();
print_r($tracking->toArray());

Advanced Usage

Look in the examples folder or you can generate the documents using Sami (composer dev-dependency).

For people running Linux

vendor/bin/sami.php -n render SamiConfig.php

For people running Windows

"vendor/bin/sami.php.bat" -n render SamiConfig.php

You will now find the documents in the docs/build folder.

Running examples

For the tests to be able to run the Bring UID, Bring API Key and Customer number has to be set in the environment

For people running Linux

export BRING_UID="[email protected]" && export BRING_API_KEY="1234abc-abcd-1234-5678-abcd1234abcd" && export BRING_CUSTOMER_NUMBER="	PARCELS_NORWAY-10001123123"

For people running Windows

setx BRING_UID [email protected]
setx BRING_API_KEY 1234abc-abcd-1234-5678-abcd1234abcd
setx BRING_CUSTOMER_NUMBER PARCELS_NORWAY-10001123123

Go into a new command prompt and run the examples. Some examples can be passed with arguments like postalcodes.

cd examples/
php BookAndPickupShipment.php
php PostalCode.php <numberOfPostalCode>
php ShippingGuideAll.php <fromPostalCode> <toPostalCode>
php Tracking.php <query>
php Reports.php <reportId>

Contribute

Contributions are very welcomed.

Please follow PSR-2 coding standard. You can run php-cs-fixer to fix the problems in the code.

License

MIT

bringapi's People

Contributors

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