pass-qa/delivery

Pass delivery service API library

1.1.0 2023-03-04 11:51 UTC

This package is auto-updated.

Last update: 2024-05-04 14:18:55 UTC


README

Social Card of Pass Delivery API

Pass Delivery: Api package library

About API

See the integration page for description of pass delivery api.

Documentation

See the documentation for pass delivery api documentation.

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' => [
    // ...
    pass-qa\delivery\src\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 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 new object

use PassQa\Delivery\PassOrder;

$order = new PassOrder()

calculate order price before create 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 for 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

use 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 which 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 security@pass.qa instead of using the issue tracker.

Credits

License

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