19th Dec 2019


The official Talon.One Ruby SDK can be found at https://github.com/talon-one/talon_one.rb. The SDK supports both the Integration API and Management API, and can be used on Ruby 2 (or newer).

# Fill in the details of your Talon.One Application here

talon = TalonOne::Integration::Client.new :endpoint => 'https://mycompany.talon.one',
                                          :application_id => 213,
                                          :application_key => '5ea4583bfb81beef'

# When the customer registers or updates their account

talon.update_customer_profile "my_unique_profile_id",
  "name" => "Val Kust",
  "billingAddress1" => "21 Jump St."

# When the customer adds an item to their cart

result = talon.update_customer_session "my_unique_session_id",
  "profileId" => "my_unique_profile_id",
  "cartItems" => [{
    "name" => "Shiny Red Shoes",
    "sku" => "srs_1234",
    "price" => 49.99,
    "quantity" => 1,
    "currency" => "USD"
  "attributes" => {
    "ShippingCost" => 3.75
  "total" => 53.74

# Process the effects generated by Talon.One as a response

result.events.effects.each do |effect|
  if effect.function == "rejectCoupon"
    # Customer entered an invalid coupon

    @talon_msg = "Coupon Invalid."
    @sale.discount = 0
  elsif effect.function == "acceptCoupon"
    # Customer entered a valid coupon

    @talon_msg = "Coupon Accepted."
  elsif effect.function == "setDiscount"
    # Apply a discount to the current cart

    @sale.discount = effect.args[1].to_f/total.to_f
  elsif effect.function == "addFreeItem"
    # Put a free item in the cart

    sku = effect.args[1]
    item = Item.where(sku: sku).first
    create_line_item(item.id, @sale.id, 1)
Still need help? Get in touch!
Last updated on 19th Dec 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