29th Oct 2019

C#

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

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.talon.one",
                ApiKey = new Dictionary<string, string> {
                    { "Authorization", "e18149e88f42205432281c9d3d0e711111302722577ad60dcebc86c43aabfe70" }
                },
                ApiKeyPrefix = new Dictionary<string, string> {
                    { "Authorization", "ApiKey-v1" }
                }
            };

            // Or via the "global" Default configuration:
            //   Configuration.Default.BasePath = "https://mycompany.talon.one";
            //   Configuration.Default.ApiKey.Add("Authorization", "YOUR_API_KEY");
            //   Configuration.Default.ApiKeyPrefix.Add("Authorization", "ApiKey-v1");

            // ************************************************
            // Integration API example to send a session update
            // ************************************************

            // When using the default approach, the next initiation of `IntegrationApi`
            // could be using the empty constructor
            var integrationApi = new IntegrationApi(integrationConfig);
            var customerSessionId = "my_unique_session_integration_id";  // string | The custom identifier for this session, must be unique within the account.
            var customerSessionPayload = new NewCustomerSession {
                ProfileId = "DADBOOF",
                State = NewCustomerSession.StateEnum.Open, // `Open` would be the default value anyway
                Total = (decimal)42.234
            };

            try
            {
                // Create/update a customer session using `UpdateCustomerSession` function
                IntegrationState result = apiInstance.UpdateCustomerSession(customerSessionId, customerSessionPayload);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling IntegrationApi.UpdateCustomerSession: " + e.Message );
            }
        }
    }
}
Still need help? Get in touch!
Last updated on 29th Oct 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