Skip to main content

Go

The Go SDK supports all of the operations of the Integration API and Management API.

package main

import (
"context"
"fmt"

talon "github.com/talon-one/talon_go"
)

func main() {
configuration := talon.NewConfiguration()
// Set API base path
configuration.BasePath = "https://mycompany.europe-west1.talon.one"

integrationClient := talon.NewAPIClient(configuration)

// Create integration authentication context using api key
integrationContext := context.WithValue(context.Background(), talon.ContextAPIKey, talon.APIKey{
Prefix: "ApiKey-v1",
Key: "fd1fd219b1e953a6b2700e8034de5bfc877462ae106127311ddd710978654312",
})

// Integration API example to send a session update
customerSession := talon.NewCustomerSession{
ProfileId: "DEADBEEF",
Coupon: "",
Referral: "",
State: "open",
CartItems: []talon.CartItem{},
Total: 42.0,
}

// Create/Update customer session using `UpdateCustomerSession` function
integrationState, response, err := integrationClient.IntegrationApi.UpdateCustomerSession(integrationContext, "deetdoot", customerSession)
if err != nil {
fmt.Println(err)
} else {
fmt.Printf("%+v \n\n", integrationState.Session)
fmt.Println(response)
}
}