Skip to content

aymakan/php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aymakan PHP SDK

This is official Aymakan PHP SDK. It can be used to integrate with Aymakan APIs. The following features lists are available in this SDK.For more details about our API requests and responses click here.


Requirements

  • PHP 7.1 or higher
  • Curl 7.18 or higher

Installing using Composer

composer require aymakan/php-sdk

Getting Started

Your Aymakan access token are available in your customer dashboard account

Setting configuration while instantiating the Client object

Used for composer based installation

// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader'
// Used for composer based installation

require __DIR__  . '/vendor/autoload.php';

// Instantiate the client class
$client = new \Aymakan\Client();
// set token
$client->setApikey('ENTER-YOUR-API-KEY-HERE');
// set Sandbox testing mode
$client->setSandbox(true);

General Methods

Ping API Method

Below is an example on how to fetch api status through ping API call:

$response = $client->pingApi();
echo $response . "\n";

Ping API Details

(back to top)

Cities Method

Below is an example on how to fetch all cities through GetCities API call:

$response = $client->getCityList();
echo $response . "\n";

Cities API Details

(back to top)


Shipping Methods

Create Shipping

Creates a new shipment , to find out more details about request parameters checkout our
Create Shipping API Documentation

$data = array(
 //request parameters
);

$response = $client->createShipment($data);
echo $response . "\n";

(back to top)

Create Bulk Shipping

Below is an example on how to create bulk shipments:

Mandatory Parameter

Parameter Type Mandatory
shipments Array of shipments Yes
$data = array(
    "shipments" => 
    array(
        # data for shipment 1
    ),
    array(
        # data for shipment 2
    ),
      ...
      ...
)

$response = $client->createBulkShipment($data);
echo $response . "\n";

Create Bulk Shippings API Documentation

(back to top)

Create a Reverse Pickup Shipping

Creates a reverse pickup shipment , to find out more details about request parameters checkout our
Create Reverse Pickup Shipping API Documentation

$data = array(
 //request parameters
);

$response = $client->createReversePickupShipment($data);
echo $response . "\n";

(back to top)

Track Shipping

Below is an example on how to track shipments through TrackShipment API call. Shipments can be fetched as a single shipment or multiple shipments at the same time . It is important to note that the tracking numbers should be sent in an array format.

Mandatory Parameter

Parameter Type Mandatory
Tracking Number Array Yes
//Track single shipment 
$response = $client->trackShipment(['AY120266']);

//Track multiple shipments
$response = $client->trackShipment(['AY669001659', '143862', '143866']);

echo $response . "\n";

Track Shipping API Details

(back to top)

Track Shipping Using Reference

Below is an example on how to track shipments by reference number. Shipments can be fetched by reference number as a single shipment or multiple shipments at the same time . It is important to note that the reference number numbers should be sent in an array format.

Mandatory Parameter

Parameter Type Mandatory
Reference Number Array Yes
//Track single shipment by reference number
$response = $client->shipmentByReference(['200018179']);

//Track Multiple shipment by reference number
$response = $client->shipmentByReference(['200018179','test-200018179']);

echo $response . "\n";

Shipment By Reference API Details

(back to top)

Cancel Shipping

Below is an example of how to Cancel Shipment :

Mandatory Parameters

Parameter variable name Type Mandatory
Tracking Number tracking Array Yes
$response = $client->cancelShipment(['tracking' => "AY120266"]);
echo $response . "\n";

Cancel Shipment API Details

(back to top)

Cancel Shipping Using Reference

Below is an example on how to cancel shipments by reference number. Shipments can be fetched by reference number as a single shipment or multiple shipments at the same time . It is important to note that the reference number numbers should be sent in an array format.

Mandatory Parameter

Parameter Type Mandatory
Reference Number Array Yes
# Track single shipment by reference number
$response = $client->cancelShipmentByReference(['200018179'])

# Track Multiple shipment by reference number
$response = $client->cancelShipmentByReference(['200018179','test-200018179'])

echo $response . "\n";

Cancel shipment By Reference API Details

(back to top)

Shipping AWB label Printing

Below is an example on how to make the Shipping AWB label Printing API call. This API requires a single tracking number associated with the customer account , and returns a URL to download the pdf file for all AWB

Mandatory Parameters

Parameter variable name Type Mandatory
Tracking Code tracking_number String Yes
$response = $client->getShipmentLabel("AY120266");
echo $response . "\n";

Shipping AWB label Printing API Details

(back to top)

Bulk Shipping AWB label Printing

Below is an example on how get Bulk Shipping AWB label . This API requires an array with tracking numbers associated with the customer account. If all the tracking numbers are found for that associated account, this API returns a URL to download the pdf file for all AWB.

Mandatory Parameters

Parameter Type Mandatory
Tracking Number Array Yes
//Get multiple shipment label
$client->getBulkShipmentLabel(['AY669001659', '143862', '143866', '143892']);
echo $response . "\n";

Bulk Shipping AWB label Printing API Details

(back to top)

Customer Shipping

Below is an example on how to make the Customer Shippings API call:

$response = $client->getCustomerShipments();
echo $response . "\n";

Customer Shipping API Details

(back to top)


Pickup Requests Methods

Get Pickup Requests

This API fetches all current customer pickup requests.

$response = $client->pickupRequest()
echo $response . "\n";

Get Pickup Requests API Details

(back to top)

Create pickup request

Below is an example on how to create a pickup request.

Parameter variable name Type Mandatory
Date format should be "Y-m-d" pickup_date String Yes
Time slot time_slot String Yes
The customer's name contact_name String Yes
The customer's phone contact_phone String Yes
The customer's address address String Yes
Amount of shipments shipments Integer Yes
$data = array(
    "pickup_date" => "2022-12-02",
    "time_slot" => "afternoon",
    "contact_name" => "example",
    "contact_phone" => "059999999",
    "address" => "example address",
    "shipments" => 2
);

$response = $client->createPickupRequest($data)
echo $response . "\n";

Create Pickup Request API Details

(back to top)

Cancel pickup request

Below is an example on how to cancel a pickup request.

Parameter variable name Type Mandatory
Pickup request id pickup_request_id Integer Yes
$data = array(
    "pickup_request_id" => 4021
}

$response = $client->cancelPickupRequest($data)
echo $response . "\n";

Cancel Pickup Request API Details

(back to top)

Time slots

Below is an example on how to fetch all time slots available to current customer.

Parameter variable name Type Mandatory
Date format should be "Y-m-d" pickup_date String Yes
$response = $client->timeSlots("2022-12-02")
echo $response . "\n";

Time Slots API Details

(back to top)


Customer Addresses Methods

Manages address associated to customer account.

Get Address

Fetches ALL addresses associated to customer account.

$response = $client->getAddress();

echo $response . "\n";

Get Address API Details

(back to top)

Create Address

Below is an example on how to make the create address associated to customer account.

Mandatory Parameters

Parameter variable name Mandatory
Title title Yes
Name name Yes
Email email Yes
Address address Yes
Neighbourhood neighbourhood Yes
Postcode postcode Yes
Phone phone Yes
Description description Yes
$data = array(
    "title" => "Mr",
    "name" => "example",
    "email" => "example@example.com",
    "city" => "Riyadh",
    "address" => 123,
    "neighbourhood" => "Al-Sahafah",
    "postcode" => "11534",
    "phone" => 0599999999,
    "description" => "create address example"
);

$response = $client->createAddress($data);
echo $response . "\n";

Create Address API Details

(back to top)

Update Address

Below is an example on how to update address associated to customer account.

Mandatory Parameters

Parameter variable name Mandatory
ID id Yes
Title title Yes
Name name Yes
Email email Yes
Address address Yes
Neighbourhood neighbourhood Yes
Postcode postcode Yes
Phone phone Yes
Description description Yes
$data = array(
    "id" => 3,
    "title" => "Mr",
    "name" => "example",
    "email" => "example@example.com",
    "city" => "Riyadh",
    "address" => 123,
    "neighbourhood" => "Al-Sahafah",
    "postcode" => "11534",
    "phone" => 0599999999,
    "description" => "update address example"
);

$response = $client->updateAddress($data);
echo $response . "\n";

Update Address API Details

(back to top)

Delete Address

Below is an example on how to delete an address associated to customer account.

Mandatory Parameters

Parameter variable name Mandatory
ID id Yes
$data = array(
    "id" => 544,
);

$response = $client->deleteAddress($data);
var_dump($response);

Delete Address API Details

(back to top)


Web Hooks Methods

Web Hooks are a convenient way to receive real time updates for your shipments as soon as a status is updated. Web Hooks can be used to update customer internal systems with the latest shipments statuses.

Get Webhooks

Below is an example on how to get webhooks .

$response = $client->getWebHook();
echo $response . "\n";

Get Webhooks API Details

(back to top)

Add Webhook

Below is an example on how to add webhook .

Mandatory Parameters

Parameter variable name Mandatory
Web Hook URL webhook_url Yes
$data = array(
    "webhook_url" => "https://testings.com" 
);

$response = $client->createWebHook($data);
echo $response . "\n";

Add Webhook API Details

(back to top)

Update Webhook

Below is an example on how to update Webhook .

Mandatory Parameters

Parameter variable name Mandatory
ID id Yes
Web Hook URL webhook_url Yes
$data = array(
    "id"=> 219 ,
    "webhook_url" => "https://www.testings.com"
);

$response = $client->updateWebHook($data);
echo $response . "\n";

Update Webhook API Details

(back to top)

Delete Webhook

Below is an example on how to delete webhooks .

$response = $client->deleteWebHook()
echo $response . "\n";

Delete Webhooks API Details

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages