2017 © Pedro Peláez
 

library postmates-api

Postmates API Client for PHP

image

aglipanci/postmates-api

Postmates API Client for PHP

  • Thursday, May 4, 2017
  • by aglipanci
  • Repository
  • 1 Watchers
  • 11 Stars
  • 63 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 12 Versions
  • 47 % Grown

The README.md

PHP API Client for Postmates

Build Status, (*1)

A PHP client for consuming the Postmates API., (*2)

Install

Via Composer, (*3)

``` bash $ composer require aglipanci/postmates-api, (*4)


> Note that the minimum required version of PHP is 5.6 ## Usage ### Create client ```php $client = new Postmates\PostmatesClient([ 'customer_id' => 'some_customer_id', 'api_key' => 'production_or_test_api_key' ]);

Retrieve an API Key here after creating a developer account., (*5)

Get a Delivery Quote

$delivery_quote = new Postmates\Resources\DeliveryQuote($client);
$delivery_quote->getQuote('501-525 Brannan St, San Francisco, CA 94107', '6 Colin P Kelly Jr St, San Francisco, CA 94107');

https://postmates.com/developer/docs/endpoints#get_quote, (*6)

Get Delivery Zones

$delivery_zones = new Postmates\Resources\DeliveryZones($client);
$delivery_zones->listZones();

https://postmates.com/developer/docs/endpoints#get_zones, (*7)

Create a Delivery

$delivery = new Postmates\Resources\Delivery($client);

$params = [
    'manifest' => 'test manifest',
    'pickup_name' => 'test pickup nanme',
    'pickup_address' => '501-525 Brannan St, San Francisco, CA 94107',
    'pickup_phone_number' => '222 551 1234',
    'dropoff_name' => 'test dropoff name',
    'dropoff_address' => '6 Colin P Kelly Jr St, San Francisco, CA 94107',
    'dropoff_phone_number' => '222 555 5432',
];

$delivery->create($params);

https://postmates.com/developer/docs/endpoints#create_delivery, (*8)

List Deliveries

$delivery = new Postmates\Resources\Delivery($client);
$delivery->listDeliveries();

https://postmates.com/developer/docs/endpoints#list_deliveries, (*9)

Get a Delivery

$delivery = new Postmates\Resources\Delivery($client);
$delivery->get('del_LAPCo_EAxDv6z-');

https://postmates.com/developer/docs/endpoints#get_delivery, (*10)

Cancel a Delivery

$delivery = new Postmates\Resources\Delivery($client);
$delivery->cancel('del_LAPCo_EAxDv6a-');

https://postmates.com/developer/docs/endpoints#cancel_delivery, (*11)

Add Tip to a Delivery

$delivery = new Postmates\Resources\Delivery($client);
$delivery->addTip('del_LAPCo_EAxDv6a-', 1000); // amount in cents

https://postmates.com/developer/docs/endpoints#tip_delivery, (*12)

Handing WebHooks

$webhook = new Postmates\PostmatesWebhook('signature_secret_key');
$webhook_request = $webhook->parseRequest() // this will validate and return the webhook request

if($webhook_request['kind'] == Delivery::EVENT_DELIVERY_STATUS) {
    //this is a delivery status event
}

if($webhook_request['kind'] == Delivery::EVENT_COURIER_UPDATE) {
    //this is a courrier update event
}

if you want to just validate the request but handing it on your own:, (*13)

$webhook = new Postmates\PostmatesWebhook('signature_secret_key');
$webhook_request_is_valid = $webhook->validateRequest($payload, $key)

https://postmates.com/developer/docs#webhooks, (*14)

Errors

All requests will throw an Postmates\PostmatesException in case API returns an Error. An Example:, (*15)

$params = [
    'manifest' => 'test manifest',
    'pickup_name' => 'test pickup nanme',
    'pickup_address' => '501-525 Brannan St, San Francisco, CA 94107',
    'pickup_phone_number' => '222 551 1234',
    'dropoff_name' => 'test dropoff name',
    'dropoff_address' => '6 Colin P Kelly Jr St, San Francisco, CA 94107',
    'dropoff_phone_number' => '222 555 5432',
];


try {

    $delivery->create($params);

} catch (Postmates\PostmatesException $e) {

    $e->getMessage();
    $e->getInvalidParams();

}

Testing

bash $ ./vendor/bin/phpunit, (*16)

Credits

Agli Panci, (*17)

WooCommerce Integration

WooCommerce Postmates Integration Plugin, (*18)

License

The MIT License (MIT)., (*19)

The Versions

04/05 2017

dev-master

9999999-dev https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

07/03 2017

v1.0.8

1.0.8.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

06/03 2017

v1.0.7

1.0.7.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

02/03 2017

v1.0.6

1.0.6.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

02/03 2017

v1.0.5

1.0.5.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

02/03 2017

v1.0.4

1.0.4.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

02/03 2017

v1.0.3

1.0.3.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

02/03 2017

v1.0.2

1.0.2.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

02/03 2017

v1.0.1

1.0.1.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

01/03 2017

v1.0

1.0.0.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

api-client postmates

01/03 2017

v0.9.1

0.9.1.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

The Requires

 

The Development Requires

api-client postmates

01/03 2017

v0.9

0.9.0.0 https://github.com/aglipanci/postmates-client

Postmates API Client for PHP

  Sources   Download

The Requires

 

The Development Requires

api-client postmates