aymakan / php-sdk
Aymakan PHP SDK
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-09-13 13:22:34 UTC
README
这是官方Aymakan PHP SDK。它可用于集成Aymakan API。以下SDK中可用的功能列表。有关我们API请求和响应的更多详细信息,请点击此处。
要求
- PHP 7.1或更高版本
- Curl 7.18或更高版本
使用Composer安装
composer require aymakan/php-sdk
入门
您的Aymakan访问令牌可在客户仪表板账户中找到
在实例化客户端对象时设置配置
用于基于Composer的安装
// 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);
通用方法
Ping API方法
以下是通过ping API调用来获取API状态的示例
$response = $client->pingApi(); echo $response . "\n";
(回到顶部)
城市方法
以下是通过GetCities API调用来获取所有城市的示例
$response = $client->getCityList(); echo $response . "\n";
(回到顶部)
运输方式
创建运输
创建新的运输,有关请求参数
的更多详细信息,请参阅我们的
创建运输API文档
$data = array( //request parameters ); $response = $client->createShipment($data); echo $response . "\n";
(回到顶部)
创建批量运输
以下是通过创建批量运输的示例
必填参数
$data = array( "shipments" => array( # data for shipment 1 ), array( # data for shipment 2 ), ... ... ) $response = $client->createBulkShipment($data); echo $response . "\n";
(回到顶部)
创建逆向取货运输
创建逆向取货运输,有关请求参数
的更多详细信息,请参阅我们的
创建逆向取货运输API文档
$data = array( //request parameters ); $response = $client->createReversePickupShipment($data); echo $response . "\n";
(回到顶部)
跟踪运输
以下是通过TrackShipment API调用来跟踪运输的示例。可以同时获取单个运输或多个运输。需要注意的是,跟踪号码应以数组格式发送。
必填参数
//Track single shipment $response = $client->trackShipment(['AY120266']); //Track multiple shipments $response = $client->trackShipment(['AY669001659', '143862', '143866']); echo $response . "\n";
(回到顶部)
使用参考跟踪运输
以下是通过参考号跟踪运输的示例。可以同时获取单个运输或多个运输。需要注意的是,参考号应以数组格式发送。
必填参数
//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";
(回到顶部)
取消运输
以下是如何取消运输的示例
必填参数
$response = $client->cancelShipment(['tracking' => "AY120266"]); echo $response . "\n";
(回到顶部)
使用参考号取消运输
以下是如何通过参考号取消运输的示例。可以同时获取单个运输或多个运输。需要注意的是,参考号应以数组格式发送。
必填参数
# 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";
(回到顶部)
运输AWB标签打印
以下是如何调用运输AWB标签打印API的示例。此API需要一个与客户账户关联的单个跟踪号码,并返回下载所有AWB的PDF文件的URL。
必填参数
$response = $client->getShipmentLabel("AY120266"); echo $response . "\n";
(回到顶部)
批量运输AWB标签打印
以下是如何获取批量运输AWB标签的示例。此API需要一个包含与客户账户关联的跟踪号码的数组。如果找到所有关联账户的跟踪号码,则此API返回下载所有AWB的PDF文件的URL。
必填参数
//Get multiple shipment label $client->getBulkShipmentLabel(['AY669001659', '143862', '143866', '143892']); echo $response . "\n";
(回到顶部)
客户运输
以下是如何调用客户运输API的示例。
$response = $client->getCustomerShipments(); echo $response . "\n";
(回到顶部)
取货请求方法
获取取件请求
此API获取所有当前客户的取件请求。
$response = $client->pickupRequest() echo $response . "\n";
(回到顶部)
创建取货请求
以下是如何创建取件请求的示例。
$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";
(回到顶部)
取消取货请求
以下是如何取消取件请求的示例。
$data = array( "pickup_request_id" => 4021 } $response = $client->cancelPickupRequest($data) echo $response . "\n";
(回到顶部)
时间段
以下是如何获取当前客户所有可用时间段示例。
$response = $client->timeSlots("2022-12-02") echo $response . "\n";
(回到顶部)
客户地址方法
管理与客户账户关联的地址。
获取地址
获取与客户账户关联的所有地址。
$response = $client->getAddress(); echo $response . "\n";
(回到顶部)
创建地址
以下是如何创建与客户账户关联的地址的示例。
必填参数
$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";
(回到顶部)
更新地址
以下是如何更新与客户账户关联的地址的示例。
必填参数
$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";
(回到顶部)
删除地址
以下是如何删除与客户账户关联的地址的示例。
必填参数
$data = array( "id" => 544, ); $response = $client->deleteAddress($data); var_dump($response);
(回到顶部)
Web Hooks方法
Web Hooks是一种方便的方式,可以在状态更新时实时接收您的运输更新。Web Hooks可以用于将最新的运输状态更新更新到客户的内部系统。
获取Webhooks
以下是如何获取Webhooks的示例。
$response = $client->getWebHook(); echo $response . "\n";
(回到顶部)
添加Webhook
以下是如何添加Webhook的示例。
必填参数
$data = array( "webhook_url" => "https://testings.com" ); $response = $client->createWebHook($data); echo $response . "\n";
(回到顶部)
更新Webhook
以下是如何更新Webhook的示例。
必填参数
$data = array( "id"=> 219 , "webhook_url" => "https://www.testings.com" ); $response = $client->updateWebHook($data); echo $response . "\n";
(回到顶部)
删除Webhook
以下是如何删除Webhooks的示例。
$response = $client->deleteWebHook() echo $response . "\n";
(回到顶部)