Search by

kangaroorewards / kangaroorewards-php-sdk

KangarooRewards

Kangaroo Rewards API

Package info

github.com/kangaroorewards/KangarooRewards-PHP-SDK

pkg:composer/kangaroorewards/kangaroorewards-php-sdk

Statistics

Installs: 40

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v3.0.0 2026-08-21 20:38 UTC

This package is auto-updated.

Last update: 2026-08-21 21:18:05 UTC


README

CI Latest Version Software License

Requirements

The following versions of PHP are supported.

  • PHP 8.1
  • PHP 8.2
  • PHP 8.3
  • PHP 8.4
  • PHP 8.5

Requires the curl and json extensions, and guzzlehttp/guzzle ^7.9.

Running PHP 7.x or older? Stay on the 2.x releases.

Installation

composer require kangaroorewards/kangaroorewards-php-sdk:^3.0

Usage

use KangarooRewards\Api\KangarooApi;

$api = new KangarooApi([
    'access_token' => $accessToken,
]);

$resourceOwner = $api->me();

$customer = $api->getCustomer($customerId, ['include' => ['balance']]);

$offers = $api->getOffers();

Options

Option Type Default Description
access_token string required OAuth 2.0 access token.
base_api_url string https://api.kangaroorewards.com API root. A path prefix (e.g. https://host/v1) is preserved.
user_agent string API Client/1.0 Value of the User-Agent header.
headers array [] Extra headers, merged over (and able to override) the defaults.
http_client ClientInterface a new GuzzleHttp\Client Bring your own Guzzle client — handy for retries, proxies and testing.
$api = new KangarooApi([
    'access_token' => $accessToken,
    'base_api_url' => 'https://api.kangaroorewards.com',
    'user_agent'   => 'My App/1.0',
    'headers'      => ['X-Application-Key' => $applicationKey],
]);

Available methods

$api->me($options);
$api->getCustomers($options);
$api->getCustomer($id, $options);
$api->createCustomer($data);
$api->updateCustomer($id, $data);
$api->getCustomerTransactions($id, $options);
$api->getCustomerNotifications($id, $options);
$api->getBranches($options);
$api->getOffers($options);
$api->getProducts($options);

Every method returns the decoded JSON body as an associative array.

Error handling

Situation Exception
Missing/invalid constructor options KangarooRewards\Api\Exception\InvalidArgumentException
Response body is not decodable JSON KangarooRewards\Api\Exception\InvalidResponseException
HTTP 4xx / 5xx GuzzleHttp\Exception\ClientException / ServerException

Both SDK exceptions implement KangarooRewards\Api\Exception\ExceptionInterface and extend the SPL classes the 2.x SDK used, so existing catch (\Exception $e) and catch (\InvalidArgumentException $e) blocks keep working.

use KangarooRewards\Api\Exception\ExceptionInterface as KangarooException;

try {
    $customer = $api->getCustomer($customerId);
} catch (KangarooException $e) {
    // SDK-level failure
} catch (\GuzzleHttp\Exception\RequestException $e) {
    // Transport / HTTP status failure
}

Injecting a custom HTTP client

use GuzzleHttp\Client;

$api = new KangarooApi([
    'access_token' => $accessToken,
    'http_client'  => new Client(['timeout' => 5.0]),
]);

The SDK always sends absolute URLs built from base_api_url, so an injected client behaves exactly like the built-in one.

Testing

composer install
composer test
composer lint
composer check

Upgrading from 2.x

See CHANGELOG.md. The public API is unchanged; the breaking changes are the raised PHP and Guzzle requirements.

Credits

License

The MIT License (MIT). Please see License File for more information.