PHPackages                             wonnova/woost-gamification-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. wonnova/woost-gamification-php-sdk

ActiveLibrary[API Development](/categories/api)

wonnova/woost-gamification-php-sdk
==================================

Woost SDK for PHP. Use Woost's RESTful API directly from your PHP projects

v0.2.1(10y ago)2212[5 issues](https://github.com/wonnova-development/woost-gamification-php-sdk/issues)MITPHPPHP ^5.4||^7.0

Since Mar 6Pushed 10y ago5 watchersCompare

[ Source](https://github.com/wonnova-development/woost-gamification-php-sdk)[ Packagist](https://packagist.org/packages/wonnova/woost-gamification-php-sdk)[ RSS](/packages/wonnova-woost-gamification-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (5)Used By (0)

Wonnova - Woost gamification PHP SDK
====================================

[](#wonnova---woost-gamification-php-sdk)

Woost SDK for PHP. Use [Woost](http://www.wonnova.com/woost)'s RESTful API directly from your PHP projects

[![Build Status](https://camo.githubusercontent.com/3a64b2a4c40f7ae6922738e8023b7ebec71520faa6a3f481fa01cb11f00ce830/68747470733a2f2f7472617669732d63692e6f72672f776f6e6e6f76612d646576656c6f706d656e742f776f6f73742d67616d696669636174696f6e2d7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/wonnova-development/woost-gamification-php-sdk)[![Code Coverage](https://camo.githubusercontent.com/ad3b1bdc14c66dfb88d4a23a89af4382f6445436fec9639a154901fe370e2810/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776f6e6e6f76612d646576656c6f706d656e742f776f6f73742d67616d696669636174696f6e2d7068702d73646b2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wonnova-development/woost-gamification-php-sdk/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f3e2c0483d363ec519223c027cd8db95075ccf4b92c5615b94a5097485aee727/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776f6e6e6f76612d646576656c6f706d656e742f776f6f73742d67616d696669636174696f6e2d7068702d73646b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wonnova-development/woost-gamification-php-sdk/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/5d003575f432814ede43a844e72ff8b7dbe9d1b8b404d4e669d317bcdb6f0455/68747470733a2f2f706f7365722e707567782e6f72672f776f6e6e6f76612f776f6f73742d67616d696669636174696f6e2d7068702d73646b2f762f737461626c652e737667)](https://packagist.org/packages/wonnova/woost-gamification-php-sdk)[![License](https://camo.githubusercontent.com/d76e8f9d7542b0b92f7689d5e133a38ad9bc8cf8b318ad8853c98cdb80d8e1d7/68747470733a2f2f706f7365722e707567782e6f72672f776f6e6e6f76612f776f6f73742d67616d696669636174696f6e2d7068702d73646b2f6c6963656e73652e737667)](https://packagist.org/packages/wonnova/woost-gamification-php-sdk)

### Installation

[](#installation)

The preferred installation method is [composer](https://getcomposer.com). 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](https://getcomposer.org/doc/).

### Usage

[](#usage)

This library basically provides a simple `Client` object that performs requests to the RESTful API.

```
include __DIR__ . '/../vendor/autoload.php';

// Create the client and inject a Credentials instance on it with your private key
$wonnovaClient = new \Wonnova\SDK\Connection\Client(
    new \Wonnova\SDK\Auth\Credentials(['key' => 'AaBbCcDd123456'])
);

// After this point, you are able to perform requests to the API
try {
    // Create a new user in your system
    $user = new \Wonnova\SDK\Model\User();
    $user->setUsername('john.doe')
         ->setProvider('my_company_name')
         ->setFullName('John Doe')
         ->setDateOfBirth(new \DateTime('1980-03-09 18:56:00'))
         ->setEmail('jdoe@doamin.com');
    $wonnovaClient->createUser($user);

    // Once the user is created, the userId is populated if it wasn't previously set.
    echo $user->getUserId();

    // Make the user perform an action
    // The userId can be used if you don't have access to the full User object
    $actionCode = 'LOGIN';
    $wonnovaClient->notifyAction($user, $actionCode);

    // You can now get the list of your quests and the status of the user in each one of them
    $quests = $wonnovaClient->getUserStatusInQuests($user);
    // This method returns an iterable collection of Quest instances, each one of them with the list of QuestSteps
    foreach ($quests as $quest) {
        echo sprintf('Quest code: %s', $quest->getCode());
        echo sprintf(
            'Quest start date: %s',
            $quest->getStartDate()->format('Y-m-d H:i:s')
        );

        // Get the quest steps
        foreach ($quest->getQuestSteps() as $step) {
            echo sprintf('Quest %s. Step type: %s', $quest->getName(), $step->getType());
            echo sprintf('Quest %s. Step code: %s', $quest->getName(), $step->getCode());
            echo sprintf(
                'Did "%s" complete this step? %s',
                $user->getFullName(),
                ($step->isCompleted() ? 'YES' : 'NO')
            );
        }
    }
} catch (\Wonnova\SDK\Exception\ExceptionInterface $e) {
    echo $e->getTraceAsString();
}
```

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.

```
$memcached = new \Memcached();
$memcached->addServer('127.0.0.1', 11211)
$cacheAdapter = new \Doctrine\Common\Cache\MemecachedCache();
$cacheAdapter->setMemcached($memcached);

$wonnovaClient = new \Wonnova\SDK\Connection\Client(
    new \Wonnova\SDK\Auth\Credentials(['key' => 'AaBbCcDd123456']),
    'es',
    $cacheAdapter
);
```

### Error management

[](#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

[](#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.

```
$method = 'GET';
$route = '/foo/bar/' . $userId;

// This response object is a GuzzleHttp\Message\ResponseInterface instance
$response = $wonnovaClient->connect($method, $route);
$data = json_decode($response->getBody()->getContents(), true);

// To send information in the body, like in POST and PUT requests, use the third argument like this
$response = $wonnovaClient->connect('POST', '/resource/create', [
    'json' => [
        'resourceId' => '123',
        'foo' => 'bar'
    ]
]);
```

### Dependency injection and testing

[](#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](http://guzzle.readthedocs.org/en/latest/testing.html).

An example.

```
// Create a client instance
$wonnovaClient = new \Wonnova\SDK\Connection\Client(
    new \Wonnova\SDK\Auth\Credentials(['key' => 'AaBbCcDd123456'])
);

// Create a mock subscriber
$mockSubscriber = new \GuzzleHttp\Subscriber\Mock([
    // Add a response that will mock the authentication request
    new \GuzzleHttp\Message\Response(
        200,
        [],
        new \GuzzleHttp\Stream\Stream(fopen('data://text/plain,{"token": "foobar"}', 'r'))
    ),

    // Add another response that will mock the request you want to test
    new \GuzzleHttp\Message\Response(
        200,
        [],
        new \GuzzleHttp\Stream\Stream(fopen('data://text/plain,...', 'r'))
    ),
]);

// Set the mock subscriber to the client instance
$wonnovaClient->getEmitter()->attach($mockSubscriber);
$wonnovaClient->getUsers(); // This won't perform a real HTTP request
```

You just need to set a response content that is compatible with what the SDK expectes to get from the request.

### Documentation

[](#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](http://www.wonnova.com/contacto).

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~201 days

Total

3

Last Release

3688d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.4

v0.2.1PHP ^5.4||^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/de88b0f744b52e00e8e26c31c332f87d3f2c22c6399394cdc9dfa3145b74a56a?d=identicon)[acelayawonnova](/maintainers/acelayawonnova)

---

Top Contributors

[![acelaya](https://avatars.githubusercontent.com/u/2719332?v=4)](https://github.com/acelaya "acelaya (65 commits)")[![viktorKhan](https://avatars.githubusercontent.com/u/4686378?v=4)](https://github.com/viktorKhan "viktorKhan (6 commits)")[![vcanizares](https://avatars.githubusercontent.com/u/7871607?v=4)](https://github.com/vcanizares "vcanizares (1 commits)")

---

Tags

gameengagementGamificationloyaltywonnovawoostgamificacionludificacion

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/wonnova-woost-gamification-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/wonnova-woost-gamification-php-sdk/health.svg)](https://phpackages.com/packages/wonnova-woost-gamification-php-sdk)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[coinpaprika/coinpaprika-api-php-client

coinpaprika.com API v1 client

249.5k](/packages/coinpaprika-coinpaprika-api-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
