6by6/freeagent-php

freeagent API 的包装器

v1.0.3 2018-07-23 13:46 UTC

This package is auto-updated.

Last update: 2024-08-29 03:36:18 UTC


README

Build Status

这是一个PHP库,为Freeagent v2 API提供了一个全面的包装。

安装

您可以通过Composer安装此库

composer require 6by6/freeagent-php

兼容性

我们目前正在测试以下PHP版本

  • '5.6'
  • '7.0'
  • hhvm
  • nightly

单元测试

该库提供了Phpunit测试,但我们强烈建议不要在生产账户上执行这些测试。测试需要干净账户,过程的一部分涉及在开始前删除任何数据,即与您的业务相关的所有内容。

测试套件将尝试在执行测试前确保您没有使用生产账户,但我们不会对任何数据丢失负责。

如果您是刚开始,我们建议使用沙箱账户(可通过Freeagent API 快速入门指南获取)。

入门

获取发票列表

use SixBySix\Freeagent\OAuth\Api;
use SixBySix\Freeagent\Entity\EntityCollection;
use SixBySix\Freeagent\Entity\Invoice;

/** @var Api $api */
$api = new Api(
  $clientId = getenv('API_CLIENT_ID'),
  $clientSecret = getenv('API_CLIENT_SECRET'),
  $refreshToken = getenv('API_REFRESH_TOKEN'),
  $sandbox = true
);

/** @var EntityCollection $invoiceCollection */
$invoiceCollection = $api->invoice()->query([
  'view' => 'last_3_months',
]);

/** @var Invoice $invoice */
foreach ($invoiceCollection as $invoice) {
  echo "{$invoice->getReference()}\n";
}

错误报告

请使用Github Issue Tracker进行支持。