xi0s / royal-mail-shipping-rest-api-client
Royal Mail Shipping REST API 客户端
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- phpunit/phpunit: ^10.0
README
本 API 规范详细说明了与 Royal Mail API Shipping V3 集成的要求。
它特别涵盖了皇家邮政 API Shipping V3 如何被企业客户用于与皇家邮政进行运输活动,并为构建此集成提供了技术信息。此规范必须与相关配套规范一起使用,供希望将系统与皇家邮政服务接口的客户使用。
Royal Mail API Shipping V3 提供了一个完全基于 REST 的服务,允许账户客户创建运输、生成标签以及生成所有国内物品运输所需的文档。
基于行业标准构建的 Royal Mail API Shipping V3 为客户提供了一种简单且低成本的集成方法,并使他们能够快速获得运输。API 提供数据流和离线条码生成,以便客户在生成标签时具有更大的灵活性。客户使用 Royal Mail API Shipping V3 服务不收取任何费用,但开发解决方案的客户必须承担自己的开发成本。皇家邮政不会对这些开发、实施和测试成本承担责任。客户应将有关开发此类系统用途的初步询问转交给其账户经理。
此 API 可以与基于 GUI 的运输平台 Royal Mail Pro Shipping 一起使用。有关 Royal Mail Pro Shipping 的更多详细信息,包括有关更新/取消运输和编制清单的视频和简报,请参阅 http://www.royalmail.com/pro-shipping-help。
此 PHP 包是 Swagger Codegen 项目自动生成的
- API 版本:3.0.12
- 构建包:io.swagger.codegen.v3.generators.php.PhpClientCodegen
要求
PHP 5.5 及以上版本
安装与使用
Composer
要通过 Composer 安装绑定,请将以下内容添加到 composer.json
{
"repositories": [
{
"type": "git",
"url": "https://github.com/zVPS/royal-mail-shipping-rest-api-client.git"
}
],
"require": {
"zVPS/royal-mail-shipping-rest-api-client": "*@dev"
}
}
然后运行 composer install
手动安装
下载文件并包含 autoload.php
require_once 'vendor/autoload.php';
测试
要运行单元测试
composer install
./vendor/bin/phpunit
入门
请按照 安装过程 进行,然后运行以下命令
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: clientID/Secret $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Id', 'YOUR_API_KEY'); $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Secret', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-IBM-Client-Id', 'Bearer'); $apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $body = new \RoyalMail\Shipping\Rest\Api\models\Address(); // \RoyalMail\Shipping\Rest\Api\models\Address | The address. $xRMGAuthToken = "xRMGAuthToken_example"; // string | Authorisation token required to invoke this operation. Can be retrieved by invoking the **_/token** operation. try { $result = $apiInstance->addressesCreate($body, $xRMGAuthToken); print_r($result); } catch (Exception $e) { echo 'Exception when calling AddressesApi->addressesCreate: ', $e->getMessage(), PHP_EOL; } // Configure API key authorization: clientID $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Id', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-IBM-Client-Id', 'Bearer'); $apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $xRMGAuthToken = "xRMGAuthToken_example"; // string | Authorisation token required to invoke this operation. Can be retrieved by invoking the **_/token** operation. $addressId = "addressId_example"; // string | Your unique Address ID of the address to delete. try { $result = $apiInstance->addressesDelete($xRMGAuthToken, $addressId); print_r($result); } catch (Exception $e) { echo 'Exception when calling AddressesApi->addressesDelete: ', $e->getMessage(), PHP_EOL; } // Configure API key authorization: clientID $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Id', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-IBM-Client-Id', 'Bearer'); $apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $xRMGAuthToken = "xRMGAuthToken_example"; // string | Authorisation token required to invoke this operation. Can be retrieved by invoking the **_/token** operation. $addressId = "addressId_example"; // string | Your unique Address ID. try { $result = $apiInstance->addressesGet($xRMGAuthToken, $addressId); print_r($result); } catch (Exception $e) { echo 'Exception when calling AddressesApi->addressesGet: ', $e->getMessage(), PHP_EOL; } // Configure API key authorization: clientID $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Id', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-IBM-Client-Id', 'Bearer'); $apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $xRMGAuthToken = "xRMGAuthToken_example"; // string | Authorisation token required to invoke this operation. Can be retrieved by invoking the **_/token** operation. try { $result = $apiInstance->addressesGetAll($xRMGAuthToken); print_r($result); } catch (Exception $e) { echo 'Exception when calling AddressesApi->addressesGetAll: ', $e->getMessage(), PHP_EOL; } // Configure API key authorization: clientID $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Id', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-IBM-Client-Id', 'Bearer'); $apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $body = new \RoyalMail\Shipping\Rest\Api\models\Address(); // \RoyalMail\Shipping\Rest\Api\models\Address | The address with the updated details. $xRMGAuthToken = "xRMGAuthToken_example"; // string | Authorisation token required to invoke this operation. Can be retrieved by invoking the **_/token** operation. $addressId = "addressId_example"; // string | Your unique Address ID of the address to update. try { $result = $apiInstance->addressesUpdate($body, $xRMGAuthToken, $addressId); print_r($result); } catch (Exception $e) { echo 'Exception when calling AddressesApi->addressesUpdate: ', $e->getMessage(), PHP_EOL; } ?>
API 端点文档
所有 URI 都是相对于 ///shipping/v3
模型文档
- 地址
- 地址响应
- 创建运输目的地
- 创建运输服务选项
- 创建运输运输
- 创建运输运输信息
- 创建运输运输包装
- 错误详情
- 项目
- 项目响应
- 清单
- 清单承运商代码请求
- 清单请求
- 清单响应
- 清单服务代码请求
- 包装响应
- 包装
- 包装响应
- 打印文档请求
- 打印文档响应
- 打印标签请求
- 打印标签响应
- 服务可用性目的地
- 服务可用性格式
- 服务可用性选项
- 服务可用性响应
- 服务可用性服务选项
- 服务可用性运输
- 服务可用性运输信息
- 服务可用性运输包装
- 运输取消请求
- 运输创建响应
- 运输推迟请求
- 运输保留请求
- 运输项目
- 运输取消响应
- 运输推迟响应
- 运输保留响应
- 发货释放请求
- 发货释放响应
- 发货人
授权文件
clientID
- 类型: API密钥
- API密钥参数名: X-IBM-Client-Id
- 位置: HTTP头
clientSecret
- 类型: API密钥
- API密钥参数名: X-IBM-Client-Secret
- 位置: HTTP头