talon-one/talon-one-client

Use the Talon.One API to integrate with your application and to manage applications and campaigns: - Use the operations in the [Integration API section](#integration-api) are used to integrate with our platform - Use the operation in the [Management API section](#management-api) to manage applicati


README

Use the Talon.One API to integrate with your application and to manage applications and campaigns:

Determining the base URL of the endpoints

The API is available at the same hostname as your Campaign Manager deployment. For example, if you access the Campaign Manager at https://yourbaseurl.talon.one/, the URL for the updateCustomerSessionV2 endpoint is https://yourbaseurl.talon.one/v2/customer_sessions/{Id}

This PHP package is automatically generated by the OpenAPI Generator project:

  • API version:
  • Package version: 8.0.0
  • Build package: org.openapitools.codegen.languages.PhpClientCodegen

Requirements

PHP 7.1 and later

Installation and usage

You have 2 options:

  • Using Composer (recommended).
  • Using the release's source code.

Using Composer

This is the recommended method.

  1. Install Composer following the installation instructions.

  2. Execute the following command in your project root to install this library:

    composer require talon-one/talon-one-client
  3. Include the autoloader:

    require_once '/path/to/your-project/vendor/autoload.php';

Using the release's source

If you prefer not to use Composer, you can download the package in its entirety. The Releases page lists all stable versions.

  1. Download the source code of the desired version, or checkout the source code directly from the repository.

  2. Uncompress the zip file you downloaded, and include the autoloader in your project:

    require_once '/path/to/talon-one-client/vendor/autoload.php';

Running the tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

  1. Follow the installation procedure.
  2. Use the Integration API or the Management API as shown in the following sections.

Integration API

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure Host, API key, & API key prefix for integration authentication
$config = \TalonOne\Client\Configuration::getDefaultConfiguration()
    ->setHost('https://yourbaseurl.talon.one')
    ->setApiKeyPrefix('Authorization', 'ApiKey-v1')
    ->setApiKey('Authorization', 'dbc644d33aa74d582bd9479c59e16f970fe13bf34a208c39d6c7fa7586968468');

// Initiating an integration api instance with the config
$apiInstance = new \TalonOne\Client\Api\IntegrationApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default when `null` is passed.
    null, // new YouClientImplementation(),
    $config
);

$customer_session_id = 'customer_session_id_example'; // string | The unique identifier for this session
$customer_session = new \TalonOne\Client\Model\NewCustomerSessionV2([
    'profileId' => 'example_prof_id',
    'couponCodes' => [
        'Cool-Summer!'
    ],
    'cartItems' => [
        new \TalonOne\Client\Model\CartItem([
            'name' => 'Hawaiian Pizza',
            'sku' => 'piz-hw-001',
            'quantity' => 1,
            'price' => 5.85
        ])
    ]
]);
$body = new \TalonOne\Client\Model\IntegrationRequest([
    'customerSession' => $customer_session,
    // Optional list of requested information to be present on the response.
    // See lib/Model/IntegrationRequest.php#getResponseContentAllowableValues for full list
    // 'responseContent' => [
    //     \TalonOne\Client\Model\IntegrationRequest::RESPONSE_CONTENT_CUSTOMER_SESSION,
    //     \TalonOne\Client\Model\IntegrationRequest::RESPONSE_CONTENT_COUPONS
    // ]
]);

try {
    // Create/Update a customer session using `updateCustomerSessionV2` function
    $integration_state = $apiInstance->updateCustomerSessionV2($customer_session_id, $body);
    print_r($integration_state);

    // Parsing the returned effects list, please consult https://developers.talon.one/Integration-API/handling-effects-v2 for the full list of effects and their corresponding properties
    foreach ($integration_state->getEffects() as $effect) {
        if ("addLoyaltyPoints" == $effect->getEffectType()) {
            // Initiating right props instance according to the effect type
            $props = new \TalonOne\Client\Model\AddLoyaltyPointsEffectProps((array) $effect->getProps());

            // Access the specific effect's properties
            echo $props->getName(), ':: ', $props->getRecipientIntegrationId(), ' just earned ',  $props->getValue(), ' points', PHP_EOL;
        }
        if ("acceptCoupon" == $effect->getEffectType()) {
            // Initiating right props instance according to the effect type
            $props = new \TalonOne\Client\Model\AcceptCouponEffectProps((array) $effect->getProps());
            // work with AcceptCouponEffectProps' properties
            // ...
        }
    }
} catch (Exception $e) {
    echo 'Exception when calling IntegrationApi->updateCustomerSessionV2: ', $e->getMessage(), PHP_EOL;
}

?>

Management API

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure Host, API key, & API key prefix for management authentication
$config = \TalonOne\Client\Configuration::getDefaultConfiguration()
    ->setHost('https://yourbaseurl.talon.one')
    ->setApiKeyPrefix('Authorization', 'ManagementKey-v1')
    ->setApiKey('Authorization', '2f0dce055da01ae595005d7d79154bae7448d319d5fc7c5b2951fadd6ba1ea07');

// Initiating a management api instance with the config
$apiInstance = new \TalonOne\Client\Api\ManagementApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default when `null` is passed.
    null, // new YouClientImplementation(),
    $config
);

try {
    $application_id = 7; // int | desired application identifier
    // Calling `getApplication` function
    $application = $apiInstance->getApplication($application_id);
    print_r($application);
} catch (Exception $e) {
    echo 'Exception when calling ManagementApi->getApplication: ', $e->getMessage(), PHP_EOL;
}

?>

Documentation for API Endpoints

All URIs are relative to https://yourbaseurl.talon.one

Documentation For Models

Documentation For Authorization

api_key_v1

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

management_key

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

manager_auth

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Author