bernskioldmedia / laravel-harvest
This is an API wrapper class for the Harvest Time Tracking API.
Requires
- php: ^8.0.2
- guzzlehttp/guzzle: ^7.4
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-12-23 17:49:05 UTC
README
This package adds a fluent way of interacting with the Harvest time tracking system and its API.
Installation
You can install the package via composer:
composer require bernskioldmedia/laravel-harvest
You can publish the config file with:
php artisan vendor:publish --tag="harvest-config"
This is the contents of the published config file:
return [ /** * The API key used for authenticating with the Harvest API. */ 'api_key' => env('HARVEST_API_KEY', ''), /** * The Account ID number from Harvest that you want to use. */ 'account_id' => env('HARVEST_ACCOUNT_ID', ''), /** * The user agent (application name) is sent through to * Harvest so that they can identify who requests come from. */ 'application_name' => env('HARVEST_APP_NAME', env('APP_NAME')), /** * The contact e-mail address for the application is required * so that Harvest can get in touch for any reason. */ 'application_email' => env('HARVEST_APP_EMAIL', ''), /** * The Base URL for the Harvest API including the version. * This package currently only supports V2 of the API. */ 'base_url' => env('HARVEST_API_URL', 'https://api.harvestapp.com/v2'), ];
Usage
The package provides a convenient facade to interact with all resources. The package will let you consume the API through fluent methods, but will not touch or map the response coming from the API. Please see the Harvest API docs for more information on responses.
The package currently supports all Harvest API resources, as well as their reporting endpoints. Your IDE should discover them on the Harvest Facade when typing.
When getting lists using the all
method there are also fluent filtering methods to help you filter. Additionally some
resources have "actions" as well. The names of these functions match mostly to the parameters in the Harvest API docs.
use BernskioldMedia\Harvest\Facades\Harvest; // Get all clients from Harvest. Harvest::clients()->all(); // Show only active clients from Harvest. Harvest::clients()->active()->all(); // Get a single client from Harvest. Harvest::clients()->get(123); // Create a client from Harvest. Harvest::clients()->create(['name' => 'My new client']); // Update a client in Harvest. Harvest::clients()->update(123, ['name' => 'My new name']); // Delete a client from Harvest. Harvest::clients()->delete(123); // Mark an invoice as sent. Harvest::invoices()->send(1);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.