blesta/reseller-api

Blesta Reseller API的官方实现

1.1.0 2016-02-26 22:34 UTC

This package is auto-updated.

Last update: 2024-09-23 10:11:25 UTC


README

Build Status Coverage Status

Blesta Reseller API库。

此库实现了Reseller API

安装

通过composer安装

composer require blesta/reseller-api:~1.0

基本用法

初始化您的连接。您需要将此连接注入到任何您想要初始化的命令类型中。

use Blesta\ResellerApi\Connection;

$connection = new Connection();
$connection->setBasicAuth($username, $password);

致谢

允许获取您账户上的可用信用额。

use Blesta\ResellerApi\Command\Credits;

$credits = new Credits($connection);

获取信用额

$result = $credits->get();
echo $result->response();

套餐

允许获取有关可用套餐的信息。

use Blesta\ResellerApi\Command\Packages;

$packages = new Packages($connection);

获取套餐

$result = $packages->get();
print_r($result->response());

获取定价

$result = $packages->getPricing($package_id);
print_r($result->response());

许可证

允许您添加、更新、暂停、取消暂停和取消许可证。

use Blesta\ResellerApi\Command\Licenses;

$licenses = new Licenses($connection);

添加许可证

$data = array(
    'pricing_id' => 1,
    'test_mode' => 'true'
);
$result = $licenses->add($data);
$licenseKey = $result->response();

更新许可证

$data = array(
    'license' => 'abcdef0123456789',
    'reissue_status' => 'reissue',
    'test_mode' => 'true'
);
$licenses->update($data);

取消许可证

$data = array(
    'license' => 'abcdef0123456789',
    'test_mode' => 'true'
);
$licenses->cancel($data);

暂停许可证

$data = array(
    'license' => 'abcdef0123456789',
    'test_mode' => 'true'
);
$licenses->suspend($data);

取消暂停许可证

$data = array(
    'license' => 'abcdef0123456789',
    'test_mode' => 'true'
);
$licenses->unsuspend($data);

搜索

搜索特定许可证。搜索内容涵盖许可证密钥、域名、IP地址和安装路径。

use Blesta\ResellerApi\Command\Search;

$search = new Search($connection);
$result = $search->data('search string')
    ->page(1)
    ->get();
print_r($result->response());

命令工厂

基本用法部分中显示的示例展示了命令对象的直接使用。您可能会发现内置的命令工厂更易于使用。

$commandFactory = new \Blesta\ResellerApi\Command\CommandFactory();
$credits = $commandFactory->create('Credits', $connection);
$packages = $commandFactory->create('Packages', $connection);
$licenses = $commandFactory->create('Licenses', $connection);
$search = $commandFactory->create('Search', $connection);