Sendbox API 的简单面向对象 PHP 客户端

v1.0.1 2022-05-15 00:57 UTC

This package is auto-updated.

Last update: 2024-09-15 06:05:15 UTC


README

Sendbox SMS API 的简单面向对象 PHP 客户端。

使用 Sendbox API

要求

  • PHP ^8.0
  • Guzzlehttp ^7.0

安装

通过 Composer

PHP ^8.0

composer require abdulsalamishaq/sendbox

基本用法

<?php

// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use AbdulsalamIshaq\Sendbox\Client;

// Create a new Client instance
$client = new Client('{access_token}');

// Create a new Client instance and set options
$client = new Client('{access_token}', [
            'app_id' => '{app_id}', 
            'client_secret' => '{client_secret}',
            'refresh_token' => '{refresh_token}',
        ]);

$client->shipment->getShipments();

运输

获取运输

使用 运输

<?php

// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use AbdulsalamIshaq\Sendbox\Client;

$client = new Client('{api_key}');

$client->shipment->getShipments();

获取运输

使用 运输

<?php

// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use AbdulsalamIshaq\Sendbox\Client;

$client = new Client('{api_key}');

$client->shipment->getShipments('{shipment_id}');

请求运输报价

使用 报价请求

<?php

// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use AbdulsalamIshaq\Sendbox\Client;

$client = new Client('{api_key}');
$quote = [
    "origin_name" => "Mrs. Hippo",
    "origin_phone" => "+2348170441446",
    "origin_street" => "Clayton St.",
    "origin_city" => "Ikorodu",
    "origin_country" => "NIGERIA",
    "origin_country_code" => "NG",
    "origin_state" => "Lagos",
    "origin_state_code" => "LOS",
    "destination_name" => "Brian",
    "destination_phone" => "+2348170441446",
    "destination_street" => "Drydock Ave Suite 610",
    "destination_city" => "Ikeja",
    "destination_country" => "NIGERIA",
    "destination_country_code" => "NG",
    "destination_state" => "Lagos",
    "destination_state_code" => "LOS",
    "weight" => "0.5",
    "items" => [
        [
            "name" => "Test Brian Iyoha",
            "quantity" => "1",
            "weight" => "1",
            "amount" => "100",
            "value" => "120000"
        ]
    ]
];

$client->shipment->quotes($quote);

创建新的运输

使用 创建新的运输

<?php

// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use AbdulsalamIshaq\Sendbox\Client;

$client = new Client('{api_key}');

$createShipment = [
    "origin_name" => "Mrs. Hippo",
    "origin_phone" => "+2348170441446",
    "origin_street" => "Clayton St.",
    "origin_city" => "Ikorodu",
    "origin_country" => "NIGERIA",
    "origin_country_code" => "NG",
    "origin_state" => "Lagos",
    "origin_state_code" => "LOS",
    "destination_name" => "Brian",
    "destination_phone" => "+2348170441446",
    "destination_street" => "Drydock Ave Suite 610",
    "destination_city" => "Ikeja",
    "destination_country" => "NIGERIA",
    "destination_country_code" => "NG",
    "destination_state" => "Lagos",
    "destination_state_code" => "LOS",
    "weight" => "0.5",
    "items" => [
        [
            "name" => "Test Brian Iyoha",
            "quantity" => "1",
            "weight" => "1",
            "amount" => "100",
            "value" => "120000"

        ]
    ],
    "selected_courier_id" => "rate_key_86a68758ead65de840b8f3e8e235a18f",
    "channel_code" => "api"
];

$client->shipment->create($createShipment);

已保存地址

使用 已保存地址

<?php

// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use AbdulsalamIshaq\Sendbox\Client;

$client = new Client('{api_key}');

$client->shipment->addresses()

支付

支付配置文件

使用 配置文件

<?php

// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use AbdulsalamIshaq\Sendbox\Client;

$client = new Client('{api_key}');
$client->payment->profile()

注意:此包不包括完整的 API 端点,因为某些端点返回 404

测试

composer test

变更日志

请参阅 变更日志 了解最近更改的详细信息。

安全漏洞

请查阅 我们的安全策略 了解如何报告安全漏洞。

致谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。