zvps/royal-mail-shipping-rest-api-client

Royal Mail Shipping REST API 客户端

v6.2 2022-04-06 14:59 UTC

This package is auto-updated.

Last update: 2024-09-06 21:20:39 UTC


README

本 API 规范详细说明了与 Royal Mail API Shipping V3 集成的要求。

它具体说明了如何让企业客户使用 Royal Mail API Shipping V3 与 Royal Mail 进行运输活动,并提供构建此集成所需的技术信息。希望将系统与 Royal Mail 服务接口的客户必须使用相关的配套规范。

Royal Mail API Shipping V3 提供了一个完整的 RESTful 服务,允许账户客户创建运输、生成标签,并为使用 Royal Mail 国内物品运输所需的所有任务生成文件。

基于行业标准构建的 Royal Mail API Shipping V3 为客户提供了一种简单且成本低的集成方法,并使他们能够快速进行运输。API 提供数据流和离线条码,使客户在生成标签时具有更大的灵活性。使用 Royal Mail API Shipping V3 服务不会向客户收取费用,但是客户自身的开发成本必须由开发解决方案的客户承担。Royal Mail 将不承担任何开发、实施和测试成本的责任。客户应将有关为此目的开发系统等方面的初步咨询发送给其账户管理员。

此 API 可以与基于图形用户界面的 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头部

作者