awd-studio/nova-poshta

v0.3.0 2017-10-20 07:34 UTC

README

Build Status Latest Stable Version Total Downloads License

PHP SDK for Nova Poshta API (alpha)

Integrate your PHP apps with Nova Poshta post company API

This open-source library allows you to integrate Nova Poshta API into your apps.

About Nova Poshta company:

Today Nova Poshta is a leader in express delivery owing to its innovation approach and hard work on efficiency improvement. By anticipating Client needs, the company constantly comes up with new products and services.

Nova Poshta’s business isn’t solely about parcels and cargoes delivery. We pride ourselves in e-commerce market development and deployment of complex technological solutions helping businesses to expand on the international scale.

Nova Poshta puts into your service:

  • Over 2500 depots all over Ukraine
  • Over 2500 vehicles
  • 36 cutting-edge sorting stations
  • Over 16 000 qualified employees
  • More than 60 million shipments a year
  • Over 350 cash desks carrying out money transfers
  • Modern logistics complex of 4000 sq. m.
  • Transparent fees and loyalty programs
  • Dedicated customer service and support
  • Track and Trace

More information.

Features

  • Track packages
  • Getting branch-offices
  • Getting common dictionaries
  • Counting delivery cost (future)
  • Determine the date of delivery (future)
  • Contingency (TTN) management (future)

Requirements

  • PHP v5.5 or higher (PHP 7+ is recommended)
  • Composer package manager
  • An API token
  • Guzzle or PHP_CURL libraries for sending HTTP-requests (optional - you can define yourself HTTP-driver)

Install

composer require awd-studio/nova-poshta

Usage

Authorize:

<?php

use NovaPoshta\Settings\Settings;

$key      = 'myAuthKeyHash';
$settings = Settings::getInstance()->auth($key);

Track:

<?php

use NovaPoshta\Settings\Settings;
use NovaPoshta\Models\TrackingDocument;

$key      = 'myAuthKeyHash';
$settings = Settings::getInstance()->auth($key);

$trackNum = '01234567890123'; // Valid track number
$status   = TrackingDocument::track($settings, $trackNum);

Get branch-offices:

<?php

use NovaPoshta\Settings\Settings;
use NovaPoshta\Models\Address;

$key      = 'myAuthKeyHash';
$settings = Settings::getInstance()->auth($key);

/**
 * Optional parameters.
 * 
 * @see https://devcenter.novaposhta.ua/docs/services/556d7ccaa0fe4f08e8f7ce43/operations/556d8211a0fe4f08e8f7ce45
 */
$options = [
  'BicycleParking'     => '1',
  'TypeOfWarehouseRef' =>'9a68df70-0267-42a8-bb5c-37f427e36ee4',
  'PostFinance'        => '1',
  'CityName'           =>'Київ',
  'CityRef'            => '20982d74-9b6c-11e2-a57a-d4ae527baec3',
];

// Or set city REF for quick searching:
// $options = [
//   'SettlementRef' => 'e71629ab-4b33-11e4-ab6d-005056801329'
// ];

$address = Address::getBranches($settings, $options);

Common dictionaries:

<?php

use NovaPoshta\Settings\Settings;
use NovaPoshta\Models\Common;

$key      = 'myAuthKeyHash';
$settings = Settings::getInstance()->auth($key);

$recipientCityRef = '8d5a980d-391c-11dd-90d9-001a92567626';

$common   = new Common($settings);
$response = $common->getCargoTypes();
// Or
$response = $common->getPalletsList();
// Or
$response = $common->getMessageCodeText();
// Or
$response = $common->getTimeIntervals($recipientCityRef);

See details. All methods implements.