10th Jan 2020

JavaScript

The official Talon.One JavaScript SDK can be found at https://github.com/talon-one/talon_one.js and supports all of the operations of our Integration API. The SDK is compatible with Node.js, and can be used in browsers with a module bundler such as Browserify or Webpack.

const TalonOne = require("talon_one");

const defaultClient = TalonOne.ApiClient.instance;
defaultClient.basePath = "https://mycompany.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();
const customerSession = new TalonOne.NewCustomerSession();

customerSession.total = 100.33;
customerSession.coupon = "Cool-Summer!";

integrationApi
  .updateCustomerSession("example_integration_id", customerSession)
  .then(
    function(data) {
      console.log(JSON.stringify(data, null, 2));
    },
    function(error) {
      console.error(error);
    }
  );
Still need help? Get in touch!
Last updated on 10th Jan 2020

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