2017 © Pedro Peláez
 

library cidr

Courier Integration Done Right!

image

captain-courier/cidr

Courier Integration Done Right!

  • Wednesday, October 2, 2013
  • by joseph
  • Repository
  • 2 Watchers
  • 2 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Cidr's goals are simpe, make working with couriers easy., (*1)

Cidr will be able to: - provide the cheapest quotes from couriers - create/view/delete/track shipment requests with minimum customization for a particular courier - get shipping labels, (*2)

Current features: - create shipments with couriers ParcelForce and P4D, (*3)

install

Cidr source can be downloaded from github, or can be added as a dependency through Composer by adding the following your composer.json:, (*4)

{
    ....
    "require": {
        ....
        "captain-courier/cidr": "*"
    }

}

setup

create a file res/credentials.yml in the project directory. It will look something like this:, (*5)

ParcelForce:
    username: <insert here>
    password: <insert here>
P4D:
    username: <insert here>
    apiKey: <insert here>

Where you would replace <insert here> with your username/password/apiKey. If you don't need one of the couriers, don't add it to the credentials.yml file. For example if you only needed ParcelForce then the credentials.yml file would look like:, (*6)

ParcelForce:
    username: <insert here>
    password: <insert here>

Whilsts testing Cidr it is recommended to use test credentials instead of production credentials. P4D provide test credentials without signing up, just goto http://www.p4d.co.uk/v2/api., (*7)

testing

Cidr uses Travis for testing, available here. Cidr can be tested locally by running:, (*8)

phpunit --configuration=phpunit.xml src/

usage

An example below for creating a shipment with ParcelForce:, (*9)

use Cidr\Cidr;
use Cidr\CidrRequest;
use Cidr\CidrResponse;


// creates a new Cidr object
// the cidr object provides capabilities, which are objects that can only 
// perform 1 task for 1 courier such as creating a consignment for ParcelForce.
$cidr = new Cidr();
$capability = $cidr->getCapability("ParcelForce", "CreateConsignment");
$request = new CidrRequest(...);

// submits the request to the courier[s] and returns a Cidr\CidrResponse object.
// response has a context properties which is different depending on the status of the response.
$response = $capability->submitCidrRequest($request);

// checks the request was successful, and prints out the assigned consignment number.
// if the request failed, it prints out the response context to get an idea why it has failed.
if (CidrResponse::STATUS_SUCCESS === $response->getStatus()) {
    // gets the consignment number assigned for the created shipment
    $consignmentNumber = $response->getResponseContext();
    print "consignment number is '${consignmentNumber}'\n";
    exit(0);
} else {
  print "request failed\n";
  print_r($response->getResponseContext());
  exit(1);
}



The Versions

02/10 2013

dev-develop

dev-develop http://captaincourier.org

Courier Integration Done Right!

  Sources   Download

AGPL-3.0

The Requires

  • php >=5.5.0

 

The Development Requires

by Avatar joseph
by Peter

shipping tracking integration courier parcels

23/09 2013

dev-experimental

dev-experimental http://captaincourier.org

Courier Integration Done Right!

  Sources   Download

AGPL-3.0

The Requires

  • php >=5.5.0

 

The Development Requires

by Avatar joseph
by Peter

shipping tracking integration courier parcels

18/09 2013

dev-master

9999999-dev http://captaincourier.org

Courier Integration Done Right!

  Sources   Download

AGPL-3.0

The Requires

  • php >=5.5.0

 

The Development Requires

by Avatar joseph
by Peter

shipping tracking integration courier parcels

04/09 2013

0.1.0

0.1.0.0 http://captaincourier.org

Courier Integration Done Right!

  Sources   Download

AGPL-3.0

The Requires

  • php >=5.5.0

 

The Development Requires

by Avatar joseph
by Peter

shipping tracking integration courier parcels