2017 © Pedro Peláez
 

package laravel-harvest

A Laravel wrapper for the Harvest API.

image

byte5digital/laravel-harvest

A Laravel wrapper for the Harvest API.

  • Monday, June 11, 2018
  • by Naoray
  • Repository
  • 1 Watchers
  • 7 Stars
  • 200 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 24 Versions
  • 156 % Grown

The README.md

A Laravel wrapper for the Harvest API

Software License Travis StyleCI Total Downloads, (*1)

A small wrapper for the harvest API which aims to make your life more easier., (*2)

Currently it is only possible to receive data from harvest with this package but not to create content., (*3)

Install

Laravel Version 5.6+

composer require byte5digital/laravel-harvest, (*4)

Laravel Version 5.5

composer require byte5digital/laravel-harvest:2.0, (*5)

If you want to store harvest data into your database, set the uses_database in the harvest config to true and publish the migrations:, (*6)

php artisan vendor:publish --provider="Byte5\LaravelHarvest\LaravelHarvestServiceProvider", (*7)

If you only want to publish the config file add: --tag="config", (*8)

Usage

You can use either the Harvest Facade or resolve the ApiManager out of the ioc container., (*9)

// resolve out of ioc container
$harvest = app()->make('harvest');

Getting Data

Every Api call looks like this:, (*10)

$harvest->model_name->get();
Harvest::model_name()->get();

You can either grab the results with get() or find($id), (*11)

// getting all clients
$harvest->clients->get();
Harvest::clients()->get();

// getting a client with id of 12345
$harvest->clients->find(12345);
Harvest::clients()->find(12345);

// getting all expenses
$harvest->expenses->get();
Harvest::expenses()->get();

// getting an expense with id of 12345
$harvest->expenses->find(12345);
Harvest::expenses()->find(12345);

//... you get the idea

There are some cases which have different methods, because they rely on other objects., (*12)

// get all user_assignments with the project id of 12345
$harvest->userAssignments->fromProject(12345)->get()

// get an user_assignments with the id of 12345 which belongs to the project id of 4567
$harvest->userAssignments->fromProject(4567)->find(12345)

// get all estimate messages with the estimate id of 12345
$harvest->estimateMessages->fromEstimate(12345)->get();

// get an estimate messages with the id of 12345 which belongs to the estimate id of 4567
$harvest->estimateMessages->fromEstimate(4567)->find(12345)

List of exceptions: - EstimateMessage - InvoiceMessage - InvoicePayment - ProjectAssignment - TaskAssignment - UserAssignment, (*13)

Handling Responses

Api responses can be either converted into json, a collection or a paginated collection which is basically json combined with collection., (*14)

// receiving some response
$respose = Harvest::users()->get();

// convert result to json
$result->toJson();

// convert result to collection
$result->toCollection();

// convert result to paginated collection
$result->toPaginatedCollection();

Handle Pagination

By default harvest gives back a JSON-response with up to 100 records. If you want to limit your results you should use limit(). If you want results from a specific page just pipe fromPage() before find or get., (*15)

// get results from page 10
$harvest->projects()->page(10)->get()

// limit result entries to 50
$harvest->projects()->limit(50)->get();

// limit result entries and get results from page 10
$harvest->projects()->limit(50)->page(10)->get();

If your harvest entries exceeds 100 records and you just want to get the results from the next or previous page, you may call next() on the result to get to the next 100 results., (*16)

// get next result page
$result = $result->next();

// get previous result page
$result = $result->previous();

Additional Params

Adding additional params to your requests is also possible. Not every param is supported yet, (*17)

supported params: - is_active => active(), (*18)

Some Api Calls allow you to have different params:, (*19)

    // get all invoices with a state of 'draft'
    $harvest->invoices()->state('draft')->get();

    // get all invoices with a client_id of '123445'
    $harvest->invoices()->client('123445')->get();

    // get all invoices with a project_id of '123445'
    $harvest->invoices()->project('123445')->get();

    // get all invoices which were updated since '2018-01-12'
    // => does also accept other formats like '12.01.2018'
    $harvest->invoices()->updatedSince('2018-01-12')->get();

    // get all invoices with an issue_date >= '2018-01-01'
    $harvest->invoices()->from('2018-01-01')->get();

    // get all invoices with an issue_date <= '2018-01-01'
    $harvest->invoices()->to('2018-01-01')->get();

Loading External Relations

When you query the API for any object which has external relations, you might want to checkout the loadExternal() method to get those relations loaded locally., (*20)

// loading all external relations of one expense model
// by default if you have enabled `uses_database` in the config
// all external relations are saved to the database.
$expense->loadExternal();

// load all external relations without saving to db
$expense->loadExternal('*', false);

// load only user and client relations
$expense->loadExternal(['user', 'client']);

ToDo

  • update/create records
  • improve tests

Testing

Run the tests with:, (*21)

bash vendor/bin/phpunit, (*22)

Upgrading

Please see UPGRADING for details., (*23)

Changelog

Please see CHANGELOG for more information what has changed recently., (*24)

Contributing

Please see CONTRIBUTING for details., (*25)

Security

If you discover any security-related issues, please email kkoenig@byte5.de instead of using the issue tracker., (*26)

License

The MIT License (MIT). Please see License File for more information., (*27)

The Versions

11/06 2018

dev-master

9999999-dev

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

11/06 2018

dev-dev

dev-dev

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

11/06 2018

2.2.x-dev

2.2.9999999.9999999-dev

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

11/06 2018

v2.2.3

2.2.3.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

11/06 2018

2.0.x-dev

2.0.9999999.9999999-dev

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

11/06 2018

v2.0.7

2.0.7.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

28/05 2018

v2.2.2

2.2.2.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

24/05 2018

v2.2.1

2.2.1.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

17/04 2018

v2.2

2.2.0.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

21/02 2018

2.1.x-dev

2.1.9999999.9999999-dev

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

21/02 2018

v2.1.1

2.1.1.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

21/02 2018

v2.0.6

2.0.6.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

08/02 2018

v2.0.5

2.0.5.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

08/01 2018

v2.0.4

2.0.4.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

laravel harvest getharvest

05/01 2018

v2.0.3

2.0.3.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

05/01 2018

v2.0.2

2.0.2.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

05/01 2018

v2.0.1

2.0.1.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

04/01 2018

v2.0

2.0.0.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

22/12 2017

v1.2.2

1.2.2.0

A Laravel wrapper for the Harvest API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Krishan König

21/12 2017

v1.2.1

1.2.1.0

A description for laravel-harvest.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Naoray Kroaths

19/12 2017

v1.2

1.2.0.0

A description for laravel-harvest.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Naoray Kroaths

13/12 2017

v1.1.1

1.1.1.0

A description for laravel-harvest.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Naoray Kroaths

13/12 2017

v1.1

1.1.0.0

A description for laravel-harvest.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Naoray Kroaths

12/12 2017

v1.0

1.0.0.0

A description for laravel-harvest.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Naoray Kroaths