Skip to content

gaming-engine/sendportal-api-client

Repository files navigation

SendPortal.IO API Client

Latest Version on Packagist Total Downloads GitHub Actions

A simple wrapper around the SendPortal.IO Version 2 API.

Installation

You can install the package via composer:

composer require gaming-engine/sendportal-api-client

Usage

This library is best used with a dependency injection library however, it is possible to instantiate is without the use of one.

You have access to several clients one for each type of endpoint that the API provides. The

The clients are as follows:

  • GamingEngine\SendPortalAPI\Clients\CampaignClient
  • GamingEngine\SendPortalAPI\Clients\SubscriberClient
  • GamingEngine\SendPortalAPI\Clients\SubscriberTagClient
  • GamingEngine\SendPortalAPI\Clients\TagClient
  • GamingEngine\SendPortalAPI\Clients\TagSubscriberClient
  • GamingEngine\SendPortalAPI\Clients\TemplateClient

For more details about the request parameters for the API please refer to the documentation.

Retrieval

use GamingEngine\SendPortalAPI\Clients\ApiClient;
use GamingEngine\SendPortalAPI\Clients\CampaignClient;
use GamingEngine\SendPortalAPI\Http\GuzzleHttpClient;
use GamingEngine\SendPortalAPI\Models\Configuration;
use GuzzleHttp\Client;

require_once './vendor/autoload.php';

$apiClient = new ApiClient(
    new Configuration('https://sendportal.domain.tld', 'bearer-token'),
    new GuzzleHttpClient(
        new Client()
    )
);

$specific = new CampaignClient($apiClient);

var_dump($specific->retrieve());

Create/Update

use GamingEngine\SendPortalAPI\Clients\ApiClient;
use GamingEngine\SendPortalAPI\Clients\CampaignClient;
use GamingEngine\SendPortalAPI\DataTransfer\CampaignDTO;
use GamingEngine\SendPortalAPI\Http\GuzzleHttpClient;
use GamingEngine\SendPortalAPI\Models\Configuration;
use GuzzleHttp\Client;

require_once './vendor/autoload.php';

$apiClient = new ApiClient(
    new Configuration('https://sendportal.domain.tld', 'bearer-token'),
    new GuzzleHttpClient(
        new Client()
    )
);

$specific = new CampaignClient($apiClient);
$dto = new CampaignDTO([
    'name' => 'Hello',
    // All fields
]);

// Provides the newly created campaign
var_dump($specific->create($dto));

// Provides the newly updated campaign
var_dump($specific->update(2, $dto));

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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