2017 © Pedro PelĂĄez
 

library sendworks-php

PHP Client bindings for Sendworks Shipping API

image

sendworks/sendworks-php

PHP Client bindings for Sendworks Shipping API

  • Monday, August 8, 2016
  • by troelskn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

sendworks-php

Sendworks API wrapper for PHP, (*1)

This library wraps the Sendworks REST API in an object-oriented PHP interface. For a full specification of the REST API, please have a look at https://sendworks.com/documentation/, (*2)

Usage

You can use the library by cloning this repository into a subfolder of your application and include the file include_all.php., (*3)

Alternatively, you can use Composer to load the library. Just type:, (*4)

composer require sendworks/sendworks-php

Getting started

To use, first create a connection instance, using your api key:, (*5)

<?php
require '/path/to/sendworks-php/include_all.php';
// Replace this with your actual api key
$api_key = 'YOUR_KEY_HERE';
// Connect to sandbox
$sendworks = new Sendworks\Connection($api_key, 'api.sandbox.sendworks.com');

This connects you to the test environment (sandbox). The sandbox is similar to the production setup, but nothing you do will actually be sent to the carriers and labels won't be valid., (*6)

You should replace YOUR_KEY_HERE with your actual api key., (*7)

You can now use the connection to get a quote:, (*8)

$recipient = new Sendworks\Address(['post_code' => 2860, 'country_code' => 'DK']);
$order = new Sendworks\Order(['subtotal' => '200 DKK']);
var_dump($sendworks->products->select($recipient, $order));

And to create a shipment:, (*9)

$recipient = new Sendworks\Address([
  'name' => 'Lorem von Ipsum',
  'street1' => 'Mars Alle 1',
  'post_code' => 2860,
  'city' => 'SĂžborg',
  'country_code' => 'DK',
  'email' => 'tkn@sendworks.com',
  'phone' => '12345678',
]);
$parcel = new Sendworks\Parcel([]);
$products = $sendworks->products->select($recipient);
$shipment = new Sendworks\Shipment(['recipient' => $recipient, 'parcels' => [$parcel], 'product' => $products[0]]);
$shipment->shipment_reference = "TEST:" . time();
$shipment = $sendworks->shipments->save($shipment);
$shipment = $sendworks->shipments->buy($shipment);
var_dump($shipment);

See also examples.php., (*10)

The Versions

08/08 2016

dev-master

9999999-dev

PHP Client bindings for Sendworks Shipping API

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

by Troels Knak-Nielsen

08/08 2016

v1.0.4

1.0.4.0

PHP Client bindings for Sendworks Shipping API

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

by Troels Knak-Nielsen

14/06 2016

v1.0.3

1.0.3.0

PHP Client bindings for Sendworks Shipping API

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

by Troels Knak-Nielsen

14/06 2016

v1.0.2

1.0.2.0

PHP Client bindings for Sendworks Shipping API

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

by Troels Knak-Nielsen

04/05 2016

v1.0.1

1.0.1.0

PHP Client bindings for Sendworks Shipping API

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

by Troels Knak-Nielsen

03/05 2016

v1.0.0

1.0.0.0

PHP Client bindings for Sendworks Shipping API

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

by Troels Knak-Nielsen