sadovojav/bitcart-sdk-php

Bitcart API PHP 客户端库。

dev-master 2023-08-25 11:21 UTC

This package is auto-updated.

Last update: 2024-08-25 13:42:29 UTC


README

此库使您在 PHP 应用程序中集成 Bitcart 更加容易。

- Package is under development. The main code can completely change

方法

此库以意见化的方式处理 API,旨在使开发者的生活尽可能简单和方便。因此,我们决定稍微改变参数的结构,但仍允许完整和高级用例。

API 客户端参数的一般推理顺序如下

  • 首先,必需参数 => 不允许 NULL 的方法参数
  • 推荐参数 => 允许 NULL 作为默认值的方法参数
  • 可选参数 => 允许 NULL 作为默认值的参数
  • 最后,高级参数 => 在一个额外的类内部

如何使用

composer require sadovojav/bitcart-sdk-php
// Require the autoload file.
require __DIR__ . '/../src/autoload.php';

// Example to create user.
$baseUrl = ''; // e.g. https://your.bitract-server.tld

try {
    // POST /users
    $user = (new \Bitcart\Client\User($baseUrl))->createUser(\Bitcart\DTO\UserDto::fromArray([
       'email' => 'user@example.com',
       'password' => 'some_password',
       'settings' => (new \Bitcart\DTO\SettingsDto()),
    ]));
    var_dump($user);
} catch (\Throwable $e) {
    echo "Error: " . $e->getMessage();
}

检查清单

开放

用户

  • GET /users/stats
  • GET /users/me
  • POST /users/me/settings
  • GET /users/count
  • GET /users/{model_id}
  • DELETE /users/{model_id}
  • PATCH /users/{model_id}
  • GET /users
  • POST /users
  • POST /users/batch

钱包

  • GET /wallets/history/all
  • GET /wallets/history/{model_id}
  • GET /wallets/balance
  • GET /wallets/{model_id}/balance
  • GET /wallets/{model_id}/checkin
  • GET /wallets/{model_id}/channels
  • POST /wallets/{model_id}/channels/open
  • POST /wallets/{model_id}/channels/close
  • POST /wallets/{model_id}/inpay
  • GET /wallets/count
  • GET /wallets/{model_id}
  • DELETE /wallets/{model_id}
  • PATCH /wallets/{model_id}
  • GET /wallets
  • POST /wallets POST /wallets/batch

商店

  • GET /stores/{model_id}/ping
  • PATCH /stores/{model_id}/checkout_settings
  • PATCH /stores/{model_id}/theme_settings
  • PATCH /stores/{model_id}/plugin_settings
  • GET /stores/count
  • GET /stores/{model_id}
  • DELETE /stores/{model_id}
  • PATCH /stores/{model_id}
  • GET /stores
  • POST /stores
  • POST /stores/batch
  • GET /stores/{store_id}/integrations/shopify/{order_id}

发票

  • GET /invoices/order_id/{order_id}
  • GET /invoices/export
  • PATCH /invoices/{model_id}/customer
  • PATCH /invoices/{model_id}/details
  • GET /invoices/count
  • GET /invoices/{model_id}
  • DELETE /invoices/{model_id}
  • PATCH /invoices/{model_id}
  • GET /invoices
  • POST /invoices
  • POST /invoices/batch

产品

  • GET /products/maxprice
  • GET /products/categories
  • GET /products/count
  • GET /products/{model_id}
  • DELETE /products/{model_id}
  • PATCH /products/{model_id}
  • GET /products
  • POST /products
  • POST /products/batch

支付

  • GET /payouts/count
  • GET /payouts/{model_id}
  • DELETE /payouts/{model_id}
  • PATCH /payouts/{model_id}
  • GET /payouts
  • POST /payouts
  • POST /payouts/batch

令牌

  • GET /token
  • POST /token
  • GET /token/current
  • GET /token/count
  • DELETE /token/{model_id}
  • PATCH /token/{model_id}

加密货币

  • GET /cryptos
  • GET /cryptos/supported
  • GET /cryptos/rate
  • GET /cryptos/fiatlist
  • GET /cryptos/tokens/{currency}
  • GET /cryptos/tokens/{currency}/abi
  • GET /cryptos/explorer/{currency}
  • GET /cryptos/rpc/{currency}

最佳实践

  • 始终使用尽可能权限最小的 API 密钥。

贡献

我们在提交 pull-request 时运行静态分析器 PsalmPHP-CS-fixer 以检查编码风格。请检查是否存在任何错误并相应地进行修复。

编码风格

我们使用PSR-12代码风格来确保适当的格式和间距。您可以使用composer命令测试和格式化代码。在提交PR之前,您可以运行composer cs-checkcomposer cs-fix,这将运行php-cs-fixer。