Skip to main content

SDKs

Talon.One offers SDKs for the following languages. Use them to integrate with Talon.One via the Integration API.

note

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.