An up to date PHP client for Harvest Forecast's API
Harvest Forecast is a planification tool built by Harvest.
- the code in the
generateddorectory is not hand-written but generated;
- if the API changes and you need to fix an API call, please edit the OpenAPI specification file, then regenerate the SDK.
If no PSR-18 client or PSR-7 message factory is available yet in your project or you don't care which one to use, just install some default:
composer require symfony/http-client nyholm/psr7
You can now install the Forecast client:
composer require jolicode/forecast-php-api
First, you need to retrieve an access token. Please checkout Harvest's documentation about the OAuth2 Authorization Flow.
Then, use the factory that is provided to create the client:
// $client contains all the methods to interact with the API $client = JoliCode\Forecast\ClientFactory::create( $accessToken, $forecastAccountId ); $clients = $client->listClients()->getClients(); $assignments = $client->listAssignments([ 'start_date' => '2019-01-01', 'end_date' => '2019-01-31', ])->getAssignments(); dump($clients); dump($assignments);
In the above example, the
$client variable is an instance of the Client class, which you can browse through to learn more about the API features.
Want more example or documentation? See the documentation.
Instead of the
listClients() method above, you can use all of these methods:
Got some problems using this library? Need a missing feature? Do not hesitate to open an issue and share it with us.
If some operation is missing or not working correctly, please follow the steps to regenerate the SDK.
You can see the current and past versions using one of the following:
And finally some meta documentation:
This library is licensed under the MIT License - see the LICENSE file for details.