valsplat/harvest-php-client

This package is abandoned and no longer maintained. No replacement package was suggested.

A PHP Client for the Harvest V2 API

v1.0 2019-01-04 16:22 UTC

This package is auto-updated.

Last update: 2021-09-11 07:46:01 UTC


README

68747470733a2f2f7777772e676574686172766573742e636f6d2f6173736574732f70726573732f686172766573742d6c6f676f2d69636f6e2d373761366638353531303265326638356137666265303730353735663239333334366136343363333731613439636566663334316432383134653237303436382e706e67

(Unofficial) Harvest v2 API Client for PHP

Contributing

$ git clone git@github.com:valsplat/harvest-php-client.git
$ cd harvest-php-client
$ composer update -o

Installation

$ composer require valsplat/harvest-php-client

Endpoints

This API client is very much a work in progress and is incomplete at this time. You can only use the Client, Project, Task, TaskAssignment, User and UserAssignment endpoints. Feel free to create a Pull Request to increase coverage.

Authentication

Authentication is done via providing your account ID and a personal access token:

$connection = new \Valsplat\Harvest\Connection();
$connection->setAccessToken('ACCESS_TOKEN');
$connection->setAccountId('ACCOUNT_ID');

Get your token and account ID here: https://id.getharvest.com/oauth2/access_tokens/new

Errors

The API client throws two exceptions:

  • \Valsplat\Harvest\Exceptions\NotFoundException - Entity could not be found
  • \Valsplat\Harvest\Exceptions\ApiException - Generic Api exception

Basic Usage

Each endpoint is accessible via its own method on the \Valsplat\Harvest\Harvest instance. The method name is singular, camelcased:

$vlak = new \Valsplat\Harvest\Harvest($connection);
$vlak->TaskAssignment();

Generic methods & filters

  • list((array)params) - get a collection of entities. You find the available params per endpoint in the Harvest docs.
  • get((int)id) - get a single entity via its id.
  • create() - create given entity.
  • update() - update given entity.
  • save() - convenience method; calls update() if the entity already exists, create() otherwise.
  • delete() - delete given entity.

Usage examples

Authentication and usage examples: example.php

TODO

  • Tests w/ mocked http client
  • Complete endpoint support
  • Automatic marshaling of attributes