smartoysters/saferme-api

SaferMe API client for PHP

dev-master 2023-10-31 06:52 UTC

This package is auto-updated.

Last update: 2024-04-30 00:47:15 UTC


README

Build Status

This package provides a complete framework agnostic SaferMe API client library for PHP.

Feel free to drop me a message at james.rickard@oceanfarmr.com or tweet me at @frodosghost.

Documentation

Check out the SaferMe Docs.

Installation

You can install the package via composer require command:

composer require smartoysters/saferme-api

Or simply add it to your composer.json dependences and run composer update:

"require": {
    "smartoysters/saferme-api": "^1.0"
}

Usage

Following details provided on the authentication doc page.

$installationId is requested to be something-unique-for-this-client-this-app-and-this-api-key. We generated this value at random.org, and select one of the generated keys, and use that in the integration. $teamId is set to extract information from an Organisation within SaferMe.

$email = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$password = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$appId = 'com.thundermaps.main';
$appBundleId = 'com.thundermaps.saferme';
$teamId = 1234;
$installationId = '';

$saferme = new SaferMe::OAuth([
    'email' => $email,
    'password' => $password,
    'appId' => $appId,
    'appBundleId' => $appBundleId,
    'installationId' => $installationId
]);

Teams

If you are using this Client to access multiple teams, you can configure to inject a single team in the Constructor, and reference another team in with ->team() function before calling your endpoint.

// As above
$saferme = new SaferMe::OAuth([
    'email' => $email,
    'password' => $password,
    'appId' => $appId,
    'teamId' => $teamId,
    'appBundleId' => $appBundleId,
    'installationId' => $installationId
]);

$teamId = 4321;

$saferme->team($teamId)->channels()->list();

Guzzle Client Options

The options value in the constructor allows configuration for the Guzzle Client to set any number of default request options.

$options = [
    'timeout'         => 0,
    'allow_redirects' => false,
    'proxy'           => '192.168.16.1:10'
];

$saferme = new SaferMe::OAuth([
    'email' => $email,
    'password' => $password,
    'appId' => $appId,
    'installationId' => $installationId,
    'options' => $options
]);

Inspiration

This package's inspiration is taken from the Devio/Pipedrive - it is such a nice code format for API interaction. Check him out on twitter :: @IsraelOrtuno.