Download the PHP package wonnova/woost-gamification-php-sdk without Composer
On this page you can find all versions of the php package wonnova/woost-gamification-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wonnova/woost-gamification-php-sdk
More information about wonnova/woost-gamification-php-sdk
Files in wonnova/woost-gamification-php-sdk
Package woost-gamification-php-sdk
Short Description Woost SDK for PHP. Use Woost's RESTful API directly from your PHP projects
License MIT
Informations about the package woost-gamification-php-sdk
Wonnova - Woost gamification PHP SDK
Woost SDK for PHP. Use Woost's RESTful API directly from your PHP projects
Installation
The preferred installation method is composer. Just run this in your project in order to update your composer.json
file and install your dependencies.
composer require wonnova/woost-gamification-php-sdk
If you never worked with composer, take a look at its documentation.
Usage
This library basically provides a simple Client
object that performs requests to the RESTful API.
The Client object gets another two arguments. The first one is the language in which you want to get responses. It is es
by default.
The second one is a cache adapter (an instance of Doctrine\Common\Cache\Cache
). By default a FilesystemCache
instance is used pointing to your system's temp directory.
This adapter is used to store the authentication token between requests to improve performance. If you have access to something "faster" like Redis, Memcached or OPcache, we recommend you to use another cache adapter.
Error management
Each method in the Client
object will perform at least one HTTP request (even more if a reauthentication has to be performed). If the server returns a response with 200 status code, the response content will be parsed, but 4xx and 5xx status codes could throw an exception.
- 401: This could be returned when the authentication token is invalid. In that case the client will automatically reauthenticate. If the server returns this status but it is not an INVALID_TOKEN response, then a
Wonnova\SDK\Exception\UnauthorizedException
will be thrown. - 400: This status is returned when an invalid request is performed for some reason, like invalid arguments and such. This case will throw a
Wonnova\SDK\Exception\InvalidRequestException
. - 404: If for some reason the requested URL does not exist and a 404 error is returned, a
Wonnova\SDK\Exception\NotFoundException
will be thrown. In a normal situation this shouldn't happen unless you manually perform a request to a custom route. - 500: Of course, if there is a server error, a
Wonnova\SDK\Exception\ServerException
will be thrown. - Others: Other status codes shouldn't be returned, but in case something went wrong, a
Wonnova\SDK\Exception\RuntimeException
will be thrown.
All the 4xx exceptions extend from a common Wonnova\SDK\Exception\ClientException
, and all the exceptions in this package implement the common Wonnova\SDK\Exception\ExceptionInterface
to ease catching them.
Future compatibility
If for some reason Wonnova has to publish a new version of the API with new endpoints before a new version of this SDK is published and you need to consume those new endpoints, there is a way to do it.
Using the public connect
method, you will get a raw response of any route request. You won't get mapped objects, but you will be able to manually parse the response and work with it.
Dependency injection and testing
If you need to depend on Wonnova's Client object, always use the Wonnova\SDK\Connection\ClientInterface
instead of the concrete Client
object. This way you will be able to replace the object in case of need.
If you don't want to replace all the methods in the Client object but you need to test another object that depends on it and don't want real HTTP requests to be performed, there is no problem. The object Wonnova\SDK\Connection\Client
is based and extends GuzzleHttp\Client
, so you will be able to mock HTTP requests as explained here.
An example.
You just need to set a response content that is compatible with what the SDK expectes to get from the request.
Documentation
If you need to know the specifications of the API that is consumed by this SDK, or want to get an extended documentation of the SDK itself, feel free to contact us.
All versions of woost-gamification-php-sdk with dependencies
guzzlehttp/guzzle Version ~5.0
jms/serializer Version 0.16.*
doctrine/common Version ~2.4
doctrine/cache Version ~1.4