jay-nay/ost-kit-php-client

OST KIT - 为 OST KIT REST API 提供的 PHP 包装器

v0.9.2 2018-05-19 06:52 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:48:28 UTC


README

Build Status codecov

这是一个非官方的 PHP 包装器,用于访问 REST API v1.xOST KIT

此包装器的旧版本可以在 发布 概览中找到。

Screenshot

在使用 API 之前,必须首先设置品牌化的 Token 经济体系,更多信息请参阅 https://kit.ost.com

安装

使用以下命令安装最新版本

$ composer require jay-nay/ost-kit-php-client

此包位于 packagist。要获取最新版本,请将以下依赖项添加到您的 composer.json 中。

require": {
    "jay-nay/ost-kit-php-client": "dev-master"
}

如何使用客户端

API 文档是自动生成的,并在每次成功构建后部署到 GitHub Pages 上,可以通过 API 文档 进行查看。

使用您的品牌化 Token 经济体系的 API 密钥API 密码 创建 OST KIT 客户端。

<?php
require_once __DIR__ . '/vendor/autoload.php';

use ostkit\OstKitClient;

$ost = OstKitClient::create('YOUR-API-KEY', 'YOUR-API-SECRET');

// Create a user named 'Louise',
$user = $ost->createUser('Louise');

// ... and rename her to 'Liza'.
$user = $ost->updateUser($user['id'], 'Liza');

// Get information about a specific user, including its public address and token balance.
$user = $ost->getUser($user['id']);

// Get the token balance of a user.
$balance = $ost->getBalance($user['id']);

// Get the value of a user's token balance in BT, OST and USD.
$balance = $ost->getCombinedBalance($user['id']);
$btValue = $balance['available_balance'];
$ostValue = $balance['ost_value'];
$usdValue = $balance['usd_value'];

// List the full ledger of a user.
$transactions = $ost->getLedger($user['id']);

// List all users.
$users = $ost->listUsers(true);

// Create a user-to-user action that transfers an arbitrary amount of Branded Tokens to a user.
$action = $ost->createAction('BT fund transfer3', 'user_to_user', 'BT', null, 0.0);

// Update an action, the kind of an action is specified when it is created an cannot change.
// Change the action currency to 'USD', amount is still arbitrary and a commission of 1.5 percent will be charged.
// Commission charges can only be specified for user-to-user actions.
$action = $ost->updateAction($action['id'], null, $action['kind'], 'USD', null, 1.5);

// Get information about a specific action.
$action = $ost->getAction($action['id']);

// Lists some actions.
$actions = $ost->listActions(false);

// Execute an action.
$transaction = $ost->executeAction($action['id'], '2e6c0d8f-29b0-41fe-b7c0-83d9eb043fe1', '6c17aca7-9911-4dc0-8aa6-30dedae4d73d', 1);

// Get the information of an executed transaction.
$transaction = $ost->getTransaction($transaction['id']);

// List some transactions for the users in the array.
$transactions = $ost->listTransactions(false, array('id' => array('4e84c205-7da4-4547-b400-fa40e979227b')));

// Transfer some OST⍺ Prime (in Wei).
$transfer = $ost->transfer('0x495ed9A80b429C4A1eA678988ffBE5685D64fF99', 1);

// Retrieve a transfer.
$transfer = $ost->getTransfer('4073cd70-e4b8-44e9-96ad-871dd8c1e70f');

// List all transfers
$tansfers = $ost->listTransfers(true);

// more examples to come; have a look at the phpdoc in the meanwhile: https://realjaynay.github.io/ost-kit-php-client/ :)

OST KIT PHP 客户端路线图

一些要做的事情以及潜在功能的想法

  • 通过进行异步、多线程的 Web 调用来提高 Web 客户端的 性能
  • 通过在适用的情况下完全支持数组作为输入类型来提高 Web 客户端的 效率
  • 根据 Web 响应的 result_type 属性自动推导要返回的 JSON 子数组。
  • 完整记录 API 以及所有函数参数和返回类型。
  • company_to_user 交易类型中将 公司 自动分配为债务人,在 user_to_company 交易类型中将 公司 自动分配为债权人。
  • 实现根据 OST KIT 中的 UUID 获取用户的 钱包地址,以便可以直接在 OST View 中查看。

问题、功能请求和错误报告

如果您有问题、对客户端有很好的想法或在使用此客户端时遇到问题,请在该项目的 问题 区域中报告。

Jay Nay 提供