6by6/freeagent-php

dev-master 2017-03-07 02:03 UTC

README

Build Status

This is a PHP library that provides a comprehensive wrapper for the Freeagent v2 API.

Installation

You can install this library via Composer:

composer require 6by6/freeagent-php

Compatibility

We are currently testing against the following PHP versions:

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

Unit Tests

Phpunit tests are provided with the library, however, we would strongly recommend NOT executing these against your live account. The tests require a clean account and part of the process involves deleting any data before starting i.e. everything about your business.

The test suite will attempt to ensure you are not using a live account before executing tests, however, we will not be held responsible for any loss of data.

If you're just getting started we would recommend using a sandbox account (obtainable via the Freeagent API Quickstart Guide).

Getting Started

Get a list of invoices

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";
}

Bug Reports

Please use the Github Issue Tracker for support.