26th Aug 2019

Go

The Talon.One Go SDK can be found at https://github.com/talon-one/talon_go and supports all of the operations of our Integration API and Management API. The Readme offers an extensive code example.

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.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 a 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)
    }
}
Still need help? Get in touch!
Last updated on 26th Aug 2019

Was this article helpful?

Thank you! You have already voted

If you’d like a member of our support team to respond to you, please send a note to support@talon.one

On this page