infradigital/api-client

Infra Digital Nusantara APIs 客户端适配器

v1.1 2019-01-14 02:37 UTC

README

INFRA DIGITAL NUSANTARA APIs

这是一个用于向 IDN 端点发起请求的 API 库。

您可以通过 composer 安装此库。您可以使用以下命令安装此库 composer require infradigital/api-client 或将库的 Packagist 命名空间注册到您的 composer.json 文件中 { "require": { "infradigital/api-client": "1.*" } } 然后调用 composer install 命令 php composer install

如何使用

要初始化 API 类,您首先可以导入 ApiClient 类,如下所示 use InfraDigital\ApiClient; 然后在您的 PHP 代码中初始化它

$idnClient = new ApiClient\Client($idnUserName, $idnPassword);

一旦初始化了类,您就可以像以下示例那样使用它

$idnClient->studentApi()->createStudent('Test User 1234' . date('YMDhis'), 'testBillKey01234' . date('YMDhis'),'0987612345', 'use.only@valid.domain', 'This is test to create user');

如果我们把它们放在一起,就会看起来像这样

use InfraDigital\ApiClient;

$idnClient = new ApiClient\Client($idnUserName, $idnPassword);
$idnClient->studentApi()->createStudent('Test User 1234' . date('YMDhis'), 'testBillKey01234' . date('YMDhis'),'0987612345', 'use.only@valid.domain', 'This is test to create user');

您可以在初始化类后使用以下简短代码 $idnClient->setDevMode();。这样,它将默认使用 IDN 生产域作为 uri。

$idnClient = new ApiClient\Client($idnUserName, $idnPassword);
$idnClient->setDevMode(); // This will be tell the class to use development uri
$idnClient->studentApi()->createStudent('Test User 1234' . date('YMDhis'), 'testBillKey01234' . date('YMDhis'),'0987612345', 'use.only@valid.domain', 'This is test to create user');