friendsofapi / fortnox
An API client for Fortnox.se
Requires
- php: ^7.1
- php-http/client-common: ^1.10 || ^2.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.0 || ^2.0
- php-http/multipart-stream-builder: ^1.0
Requires (Dev)
- guzzlehttp/psr7: ^1.4
- nyholm/nsa: ^1.1
- php-http/curl-client: ^1.6
- php-http/message: ^1.0
- php-http/message-factory: ^1.0
- phpunit/phpunit: ^7.4
README
Install
Via Composer
composer require friendsofapi/fortnox
Usage
You need to follow the steps described on https://developer.fortnox.se/getting-started/ to get an access token. Once you got that token you can start playing with the API client.
$apiClient = new ApiClient(); $total = $apiClient->stats()->total(); echo $total->getCount(); // 22;
Errors
See a list of error codes on Fortnox.
Develop
APIs are usually split into categories, called Resources.
In your implementation you should also reflect these categories, for example by having their own classes in Api/
.
Let's take a look at Api/Stats
in our case. The response of any call should be an object in Model/Stats/X
,
like Model/Stats/Total
.
Hydrator
The end user chooses which hydrator to use. The default one should return domain objects.
Request builder
The request builder creates a PSR-7 request with a multipart stream when necessary
If the API does not require multipart streams you should remove the RequestBuilder
and replace it with a RequestFactory
.
License
The MIT License (MIT). Please see License File for more information.