API Reference

Installation

composer require pass-qa/delivery

Optional:

The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

'providers' => [
    // ...
    PassQa\Delivery\Providers\PassDeliveryApiServiceProvider::class,
];

Publish files

You should publish the config/passdelivery.php config file with:

php artisan vendor:publish --provider="PassQa\Delivery\Providers\PassDeliveryApiServiceProvider"

After that, you should put your api_key in the config file, also you can set test_mode to true for development or false for production.

Usage Instructions

First Step

You must generate a token. See this page to learn how to create a token.

create a new object

use PassQa\Delivery\PassOrder;

$order = new PassOrder()

Calculate the order price before creating order

Request a quote to receive your exact delivery fee for an order by using the origin address and destination addresses.

This endpoint retrieves calculation information in the format of a pair of {latitude, longitude} coordinates.

$priceData = [
        "pickup" =>[
            "lat" =>"25.275047",
            "long" => "51.535141"
        ],
        "dropoffs" => [
            [
                "lat" =>"25.277007", 
                "long" => "51.530034"
            ],
                 [
                "lat" =>"25.277005", 
                "long" => "51.530039"
                 ],
                 [
                "lat" =>"25.277001", 
                "long" => "51.530030"
                 ]
        ]
    ];

use object

use PassQa\Delivery\PassOrder;

$order = new PassOrder();

$response = $order->Price($priceData);

or use facade

use PassQa\Delivery\Facades\PassOrder;

$response = PassOrder::Price($priceData);

Create an order

Once you calculated the price of your order, you can use this endpoint in order to create a new order.

$orderData = [
        "addresses"=> [
            "pickup" =>[
                "lat"=> "25.275047",
                "long"=> "51.535141",
                "name"=> "majva",
                "phone"=> "+97466661234",
                "address"=> "this street",
                "description"=> "it is a sample description"
            ],
            "dropoffs" => [
                [
                    "lat"=> "25.277007",
                    "long"=> "51.530034",
                    "name"=> "majva",
                    "phone"=> "+97466661234",
                    "address"=> "that street",
                    "description"=> "it is a sample description"
                ],
                [
                    "lat"=> "25.277007",
                    "long"=> "51.530034",
                    "name"=> "majva",
                    "phone"=> "+97466661234",
                    "address"=> "other street",
                    "description"=> "it is a sample description"
                ],
                [
                    "lat"=> "25.277007",
                    "long"=> "51.530034",
                    "name"=> "majva",
                    "phone"=> "+97466661234",
                    "address"=> "another street",
                    "description"=> "it is a sample description"
                ]
            ]
        ]
    ];

use object

use PassQa\Delivery\PassOrder;

$order = new PassOrder();

$response = $order->Create($orderData);

or use facade

use PassQa\Delivery\Facades\PassOrder;

$response = PassOrder::Create($orderData);

Tracking driver of your order

Once you successfully have created an order, you will be able to watch the Pass driver on a live map.

The driver's location and order status will be change as the driver is moving.

The 'order id' is available in the create API response

using the object

use PassQa\Delivery\PassOrder;

$order = new PassOrder();

$response = $order->Tracking('order id');

or use facade

use PassQa\Delivery\Facades\PassOrder;

$response = PassOrder::Tracking('order id');

Get order detail

Call the following endpoint in order to get the order details.

The order details include:

  1. Pickup and Dropoff details including description
  2. Driver details including name, phone number, avatar and vehicle information
  3. Order price and payment details
  4. Order statuses
  5. Share URL. A tool that you can use to share a link with your clients to view the live driver status.

The 'order id' is available in the create API response

use object

use PassQa\Delivery\PassOrder;

$order = new PassOrder();

$response = $order->Detail('order id');

or use facade

use PassQa\Delivery\Facades\PassOrder;

$response = PassOrder::Detail('order id');

Cancel an order

You can cancel any order before courier arrival (before the pickup status)

The 'order id' is available in the create API response

use object

use PassQa\Delivery\PassOrder;

$order = new PassOrder();

$response = $order->Cancel('order id');

or use facade

use PassQa\Delivery\Facades\PassOrder;

$response = PassOrder::Cancel('order id');

List of orders

List of all submitted orders by your tokens

use object

use PassQa\Delivery\PassOrder;

$order = new PassOrder();

$response = $order->List();

or use facade

use PassQa\Delivery\Facades\PassOrder;

$response = PassOrder::List();

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.