All Projects → aglipanci → postmates-api

aglipanci / postmates-api

Licence: other
PHP API Client for Posmates

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to postmates-api

nzb
Get Things Done® with nzb, a beautiful terminal interface for Nozbe. Inspired by Wunderline
Stars: ✭ 35 (+118.75%)
Mutual labels:  api-client
pychannels
Python library for querying and controlling the Channels app.
Stars: ✭ 15 (-6.25%)
Mutual labels:  api-client
Bittrex.Api.Client
A C# http client wrapper for the Bittrex cryptocurrency trading platform api
Stars: ✭ 14 (-12.5%)
Mutual labels:  api-client
pocket-api
A python wrapper around GetPocket API V3.
Stars: ✭ 103 (+543.75%)
Mutual labels:  api-client
tweetsOLAPing
implementing an end-to-end tweets ETL/Analysis pipeline.
Stars: ✭ 24 (+50%)
Mutual labels:  api-client
hcloud-rust
Unofficial Rust crate for accessing the Hetzner Cloud API
Stars: ✭ 22 (+37.5%)
Mutual labels:  api-client
ynab.go
Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.
Stars: ✭ 49 (+206.25%)
Mutual labels:  api-client
jobs-stackoverflow
Making it easy to integrate with the Stack Overflow job board API
Stars: ✭ 17 (+6.25%)
Mutual labels:  api-client
keen-analysis.js
A light JavaScript client for Keen
Stars: ✭ 40 (+150%)
Mutual labels:  api-client
laravel-quickbooks-client
SPINEN's Laravel Client for QuickBooks.
Stars: ✭ 25 (+56.25%)
Mutual labels:  api-client
CompaniesHouse.NET
A simple .NET client wrapper for CompaniesHouse API
Stars: ✭ 28 (+75%)
Mutual labels:  api-client
dns
dns is a simple CLI tool for DNS-LG API
Stars: ✭ 28 (+75%)
Mutual labels:  api-client
messaging-apis
Messaging APIs for multi-platform
Stars: ✭ 1,759 (+10893.75%)
Mutual labels:  api-client
pushover
Go wrapper for the Pushover API
Stars: ✭ 112 (+600%)
Mutual labels:  api-client
j2ssh-maverick
The open source branch of our legacy API providing a robust, mission critical SSH component to the community.
Stars: ✭ 57 (+256.25%)
Mutual labels:  api-client
mite-cli
command line interface for time tracking service mite.yo.lk
Stars: ✭ 17 (+6.25%)
Mutual labels:  api-client
js-http-client
[DEPRECATED] Official Textile JS HTTP Wrapper Client
Stars: ✭ 29 (+81.25%)
Mutual labels:  api-client
eoLinker
在线 API 研发管理测试工具,最后能用的开源修复版本(4.0.1本地测试插件兼容3.5与4.0版本)。
Stars: ✭ 62 (+287.5%)
Mutual labels:  api-client
pastebin-csharp
API client for Pastebin in C#
Stars: ✭ 25 (+56.25%)
Mutual labels:  api-client
revolut-php
💳 PHP Bindings for the Revolut Business API
Stars: ✭ 37 (+131.25%)
Mutual labels:  api-client

PHP API Client for Postmates

Build Status

A PHP client for consuming the Postmates API.

Install

Via Composer

$ composer require aglipanci/postmates-api

Note that the minimum required version of PHP is 5.6

Usage

Create client

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

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

Get Delivery Zones

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

https://postmates.com/developer/docs/endpoints#get_zones

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

List Deliveries

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

https://postmates.com/developer/docs/endpoints#list_deliveries

Get a Delivery

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

https://postmates.com/developer/docs/endpoints#get_delivery

Cancel a Delivery

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

https://postmates.com/developer/docs/endpoints#cancel_delivery

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

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:

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

https://postmates.com/developer/docs#webhooks

Errors

All requests will throw an Postmates\PostmatesException in case API returns an Error. An Example:

$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

$ ./vendor/bin/phpunit

Credits

Agli Panci

WooCommerce Integration

WooCommerce Postmates Integration Plugin

License

The MIT License (MIT).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].