SDKs
Talon.One offers SDKs for the following languages. Use them to integrate with Talon.One via the Integration API.
The SDKs do not cover Application notifications and loyalty notifications.
- Go
- Java
- JavaScript
- C#
- Ruby
- Python
- PHP
The Talon.One Go SDK can be found on GitHub.
Quick start
Install via Go get:
go get -u https://github.com/talon-one/talon_go
Use the Update customer session endpoint:
package main
import (
"context"
"encoding/json"
"fmt"
talon "github.com/talon-one/talon_go"
)
func main() {
configuration := talon.NewConfiguration()
// Set API base path
configuration.Servers = talon.ServerConfigurations{
{
// Notice that there is no trailing '/'
URL: "https://mycompany.europe-west1.talon.one",
Description: "Talon.One's API base URL",
},
}
integrationClient := talon.NewAPIClient(configuration)
// Create integration authentication context using api key
integrationAuthContext := context.WithValue(
context.Background(),
talon.ContextAPIKeys,
map[string]talon.APIKey{
"Authorization": talon.APIKey{
Prefix: "ApiKey-v1",
Key: "fd1fd219b1e953a6b2700e8034de5bfc877462ae106127311ddd710978654312",
},
},
)
// Instantiating a NewCustomerSessionV2 struct
customerSession := talon.NewCustomerSession{
// You can use both struct literals
ProfileId: talon.PtrString("DEADBEEF"),
CouponCodes: &[]string{"Cool-Stuff!"},
}
// Or alternatively, using the relevant setter in a later stage in the code
newCustomerSession.SetCartItems([]talon.CartItem{
talon.CartItem{
Name: "Pad Thai - Veggie",
Sku: "pad-332",
Quantity: 1,
Price: 5.5,
Category: talon.PtrString("Noodles"),
},
talon.CartItem{
Name: "Chang",
Sku: "chang-br-42",
Quantity: 1,
Price: 2.3,
Category: talon.PtrString("Beverages"),
},
})
// Instantiating a new IntegrationRequest
integrationRequest := talon.IntegrationRequest{
CustomerSession: newCustomerSession,
}
// Optional list of requested information to be present on the response.
// Consult the Integration API docs for a full list of supported values
// integrationRequest.SetResponseContent([]string{
// "customerSession",
// "customerProfile",
// "loyalty",
// })
// Create/Update customer session using `UpdateCustomerSessionV2` function
integrationState, _, err := integrationClient.IntegrationApi.
UpdateCustomerSessionV2(integrationAuthContext, "deetdoot_2").
Body(integrationRequest).
Execute()
if err != nil {
fmt.Printf("ERROR while calling UpdateCustomerSessionV2: %s\n", err)
return
}
fmt.Printf("%#v\n", integrationState)
}
For more information, see Go SDK.
The Talon.One Java SDK is hosted as a Maven repository on GitHub. See the code.
Quick start
-
Install via Maven:
-
Add the Talon.One's artifacts repository under the repositories section in your
pom.xml
file:<repository>
<id>talon-one</id>
<url>https://github.com/talon-one/maven-artefacts/raw/master</url>
</repository> -
You can add the dependency to the version that you wish to use:
<dependency>
<groupId>one.talon</groupId>
<artifactId>talon-one-client</artifactId>
<version>4.0.0</version>
<scope>compile</scope>
</dependency>
-
-
Make an API call to update the customer session using the Update customer session endpoint:
package com.example.consumer;
import one.talon.ApiClient;
import one.talon.api.IntegrationApi;
import one.talon.api.ManagementApi;
import one.talon.model.*;
public class TalonApiTest {
public static void main(String[] args) {
IntegrationApi iApi = new IntegrationApi(new ApiClient("api_key_v1"));
// Setup: basePath
iApi.getApiClient().setBasePath("https://mycompany.europe-west1.talon.one");
// Setup: when using 'api_key_v1', set apiKey & apiKeyPrefix must be provided
iApi.getApiClient().setApiKeyPrefix("ApiKey-v1");
iApi.getApiClient().setApiKey("dbc644d33aa74d582bd9479c59e16f970fe13bf34a208c39d6c7fa7586968468");
try {
// Creating a cart item object
CartItem cartItem = new CartItem();
cartItem.setName("Hawaiian Pizza");
cartItem.setSku("pizza-x");
cartItem.setQuantity(1);
cartItem.setPrice(new java.math.BigDecimal("5.5"));
// Creating a customer session of V2
NewCustomerSessionV2 customerSession = new NewCustomerSessionV2();
customerSession.setProfileId("Cool_Dude");
customerSession.addCouponCodesItem("Cool-Summer!");
customerSession.addCartItemsItem(cartItem);
// Initiating integration request wrapping the customer session update
IntegrationRequest request = new IntegrationRequest()
.customerSession(customerSession);
// Optional list of requested information to be present on the response.
// Consult the UpdateCustomerSessionV2 API docs for a full list of supported values
// .responseContent(Arrays.asList(
// IntegrationRequest.ResponseContentEnum.CUSTOMERSESSION,
// IntegrationRequest.ResponseContentEnum.CUSTOMERPROFILE
// ));
// Create/Update customer session using `updateCustomerSessionV2` function
IntegrationStateV2 is = iApi.updateCustomerSessionV2("deetdoot", request);
System.out.println(is.toString());
} catch (Exception e) {
System.out.println(e);
}
}
}
For more information, see Java SDK.
The Talon.One JavaScript SDK can be found on npm. See the code.
Quick start
Install via npm:
npm install talon_one --save
Or using yarn:
yarn add talon_one
Make an API call to the Update customer session endpoint:
const TalonOne = require("talon_one");
const defaultClient = TalonOne.ApiClient.instance;
defaultClient.basePath = "https://mycompany.europe-west1.talon.one";
// Configure API key authorization: api_key_v1
const api_key_v1 = defaultClient.authentications["api_key_v1"];
api_key_v1.apiKey =
"dbc644d33aa74d582bd9479c59e16f970fe13bf34a208c39d6c7fa7586968468";
api_key_v1.apiKeyPrefix = "ApiKey-v1";
// Integration API example to send a session update
const integrationApi = new TalonOne.IntegrationApi();
// Initializing a customer session object
const customerSession = TalonOne.NewCustomerSessionV2.constructFromObject({
profileId: 'example_prof_id',
cartItems: [{
name: 'Döner King',
sku: 'kd-100',
quantity: 1,
price: 2.00,
category: 'pizzas'
}, {
name: 'Spezi 500ml',
sku: 'sp-50',
quantity: 1,
price: 2,
category: 'beverages'
}, {
name: 'Queen Döner',
sku: 'qd-100',
quantity: 1,
price: 2.50,
category: 'pizzas'
}, {
name: 'Club Mate 330ml',
sku: 'cm-33',
quantity: 1,
price: 1.80,
category: 'beverages'
}],
couponCodes: [
'Cool-Summer!'
]
});
// Initializing an integration request wrapping the customer session
const integrationRequest = new TalonOne.IntegrationRequest(customerSession);
// Optional list of requested information to be present on the response.
// Consult the UpdateCustomerSessionV2 docs for a full list of supported values
/integrationRequest.responseContent = ['customerSession', 'customerProfile']
integrationApi
.updateCustomerSessionV2("example_integration_v2_id", integrationRequest)
.then(
function(data) {
console.log(JSON.stringify(data, null, 2));
},
function(error) {
console.error(error);
}
);
For more information, see JavaScript SDK.
The Talon.One C# SDK can be found at Nuget. See the code.
Quick start
Install via Package Manager:
Install-Package TalonOne -Version 2.3.0
Or using a PackageReference
in the Project.csproj
file:
<PackageReference Include="TalonOne" Version="2.3.0" />
Make an API call to the Update customer session endpoint:
using System;
using System.Diagnostics;
using TalonOne.Api;
using TalonOne.Client;
using TalonOne.Model;
namespace Example {
public class Example {
public void main() {
// Configure BasePath & API key authorization: api_key_v1
var integrationConfig = new Configuration {
BasePath = "https://mycompany.europe-west1.talon.one",
ApiKey = new Dictionary < string,
string > {
{
"Authorization",
"e18149e88f42205432281c9d3d0e711111302722577ad60dcebc86c43aabfe70"
}
}, ApiKeyPrefix = new Dictionary < string,
string > {
{
"Authorization",
"ApiKey-v1"
}
}
};
var integrationApi = new IntegrationApi(integrationConfig);
var customerSessionId = "MY_UNIQUE_SESSION_INTEGRATION_ID"; // A unique identifier for this session
// Preparing a NewCustomerSessionV2 object
var customerSession = new NewCustomerSessionV2 {
ProfileId = "PROFILE_ID",
CouponCodes = new List < string > {
"Cool-Stuff-2020"
},
CartItems = new List < CartItem > {
new CartItem("Hummus Tahini", // Name
"hum-t", // Sku
1, // Quantity
(decimal) 5.5, // Price
"Food" // Category
),
new CartItem("Iced Mint Lemonade", // Name
"ice-mn-lemon", // Sku
1, // Quantity
(decimal) 3.5, // Price
"Beverages" // Category
)
}
};
// Instantiating an IntegrationRequest object
IntegrationRequest integrationRequest = new IntegrationRequest(
customerSession,
// Optional list of requested information to be present on the response.
// Consult the UpdateCustomerSessionV2 endpoint docs for a full list of supported values
// new List<IntegrationRequest.ResponseContentEnum> {
// IntegrationRequest.ResponseContentEnum.CustomerSession,
// IntegrationRequest.ResponseContentEnum.CustomerProfile
// }
);
try {
// Create/Update customer session using `UpdateCustomerSessionV2` function
IntegrationState response = apiInstance.UpdateCustomerSessionV2(customerSessionId, integrationRequest);
Console.WriteLine(response);
}
catch(Exception e) {
Console.WriteLine("Exception when calling IntegrationApi.UpdateCustomerSessionV2: " + e.Message);
}
}
}
}
For more information, see C# SDK.
The Talon.One Ruby SDK can be found at RubyGems. See the code.
Quick start
Install via RubyGems:
gem install talon_one
Make an API call to the Update customer session endpoint:
require 'talon_one'
# Setup authorization
TalonOne.configure do |config|
# Configure the API host destination
config.host = 'mycompany.europe-west1.talon.one'
config.scheme = 'https'
# Configure API key authorization: api_key_v1
config.api_key['Authorization'] = 'ca1890f0ec3bfa8ed4be04e2aec0c606c0df8ad464f17d3ea8b51df12ba60e5d'
config.api_key_prefix['Authorization'] = 'ApiKey-v1'
end
# Integration API example to send a session update
integration_api = TalonOne::IntegrationApi.new
session_integration_id = '8fb7129e-68e6-4464-9631-09b588391619' # String | The integration identifier of the session
# Preparing a NewCustomerSessionV2 object
customer_session_v2 = TalonOne::NewCustomerSessionV2.new(
profile_id: 'Some_1',
state: 'open',
cart_items: [
TalonOne::CartItem.new(
name: 'Nigiri Sake',
sku: 'sush1',
quantity: 2,
price: 3.7,
category: 'Sushi'
),
TalonOne::CartItem.new(
name: 'Rainbow Roll I/O',
sku: 'sush2',
quantity: 1,
price: 6.5,
category: 'Sushi'
),
TalonOne::CartItem.new(
name: 'Kirin',
sku: 'k1r',
quantity: 2,
price: 2.2,
category: 'Beverages'
),
],
coupon_codes: [
'Cool-Stuff!'
]
)
# Instantiating a new IntegrationRequest object
integration_request = TalonOne::IntegrationRequest.new(
customer_session: customer_session_v2,
# Optional list of requested information to be present on the response.
# Consult the UpdateCustomerSessionV2 endpoint docs for a full list of supported values
# response_content: [
# 'customerSession'
# ]
)
begin
# Create/Update customer session using `update_customer_session_v2` function
result = integration_api.update_customer_session_v2(session_integration_id, integration_request)
# Prints response to the console
puts result
rescue TalonOne::ApiError => e
puts "Exception when calling IntegrationApi->update_customer_session_v2: #{e}"
end
For more information, see Ruby SDK.
The Talon.One Python SDK can be found on GitHub.
Quick start
Install via pip:
pip install git+https://github.com/talon-one/talon_one.py.git
Make an API call to the Update customer session endpoint:
import talon_one
from talon_one.rest import ApiException
from pprint import pprint
# Create configuration with your host destination
configuration = talon_one.Configuration()
configuration.host = "https://mycompany.europe-west1.talon.one"
# Configure API key authorization: api_key_v1
configuration.api_key["Authorization"] = "e18149e88f42247f0123456789abcdef9302722577ad60cebc86c4333b6fb70"
configuration.api_key_prefix["Authorization"] = "ApiKey-v1"
# Integration API example to send a session update
integration_api = talon_one.IntegrationApi(talon_one.ApiClient(configuration))
# Preparing a NewCustomerSessionV2 object
customer_session = talon_one.NewCustomerSessionV2(
"PROFILE_ID"
)
customer_session.cart_items = [
talon_one.CartItem("Red Spring Blouse", "rdbs-1111", 1, 49, "Shirts"),
talon_one.CartItem("Denim Trousers", "dtr-2222", 1, 74, "Trousers"),
]
customer_session.coupon_codes = [
"Cool_Stuff"
]
# Instantiating a new IntegrationRequest object
integration_request = talon_one.IntegrationRequest(
customer_session,
# Optional list of requested information to be present on the response.
# Consult the UpdateCustomerSessionV2 endpoint docs for a full list of supported values
# ["customerSession", "loyalty"]
)
try:
# Create/Update customer session using `update_customer_session_v2` function
api_response = integration_api.update_customer_session_v2("my_unique_session_v2_id", integration_request)
pprint(api_response)
except ApiException as e:
print("Exception when calling IntegrationApi->update_customer_session_v2: %s\n" % e)
For more information, see Python SDK.
The Talon.One PHP SDK can be found at Packagist. See the code.
Quick start
Install via composer:
composer require talon-one/talon-one-client
Make an API call to the Update customer session endpoint:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Host, API key, & API key prefix for integration authentication
$config = \TalonOne\Client\Configuration::getDefaultConfiguration()
->setHost('https://mycompany.europe-west1.talon.one')
->setApiKeyPrefix('Authorization', 'ApiKey-v1')
->setApiKey('Authorization', 'dbc644d33aa74d582bd9479c59e16f970fe13bf34a208c39d6c7fa7586968468');
// Initiating an integration api instance with the config
$this->apiInstance = new \TalonOne\Client\Api\IntegrationApi($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.
// Consult the UpdateCustomerSessionV2 endpoint docs for a full list of supported values
// 'responseContent' => [
// \TalonOne\Client\Model\IntegrationRequest::RESPONSE_CONTENT_CUSTOMER_SESSION,
// \TalonOne\Client\Model\IntegrationRequest::RESPONSE_CONTENT_COUPONS
// ]
]);
try {
// Create/Update customer session using 'updateCustomerSessionV2' function
$integration_state = $this->apiInstance->updateCustomerSessionV2($customer_session_id, $body);
print_r($integration_state);
} catch (Exception $e) {
echo 'Exception when calling IntegrationApi->updateCustomerSessionV2: ', $e->getMessage(), PHP_EOL;
}
?>
For more information, see PHP SDK.