Skip to content

abhith/TalonOne.cs

 
 

Repository files navigation

TalonOne - the C# library for the Talon.One API

The Talon.One API is used to manage applications and campaigns, as well as to integrate with your application. The operations in the Integration API section are used to integrate with our platform, while the other operations are used to manage applications and campaigns.

Where is the API?

The API is available at the same hostname as these docs. For example, if you are reading this page at https://mycompany.talon.one/docs/api/, the URL for the [updateCustomerProfile][] operation is https://mycompany.talon.one/v1/customer_profiles/id

[updateCustomerProfile]: #operation- -v1-customer_profiles- -integrationId- -put

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.0.0
  • SDK version: 3.3.0
  • Build package: org.openapitools.codegen.languages.CSharpClientCodegen

Frameworks supported

  • .NET 4.0 or later
  • Windows Phone 7.1 (Mango)

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using TalonOne.Api;
using TalonOne.Client;
using TalonOne.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out TalonOne.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Getting Started

Integration API

V2

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_2";  // string | The custom identifier for this session, must be unique within the account.

            // Preparing a NewCustomerSessionV2 object
            NewCustomerSessionV2 customerSession = new NewCustomerSessionV2 {
                ProfileId = "PROFILE_ID",
                CouponCodes = new List<string> {
                    "Cool-Stuff-2020"
                },
                CartItems = new List<CartItem> {
                    new CartItem(
                        "Hummus Tahini", // Name
                        "hum-t", // Sku
                        1, // Quantity
                        (decimal)5.5, // Price
                        "Food" // Category
                    ),
                    new CartItem(
                        "Iced Mint Lemonade", // Name
                        "ice-mn-lemon", // Sku
                        1, // Quantity
                        (decimal)3.5, // Price
                        "Beverages" // Category
                    )
                }
            };

            // Instantiating an IntegrationRequest object
            IntegrationRequest body = new IntegrationRequest(
                customerSession,
                // Optional list of requested information to be present on the response.
                // See src/TalonOne/Model/IntegrationRequest#ResponseContentEnum for full list of supported values
                // new List<IntegrationRequest.ResponseContentEnum> {
                //     IntegrationRequest.ResponseContentEnum.CustomerSession,
                //     IntegrationRequest.ResponseContentEnum.CustomerProfile
                // }
            );


            try
            {
                // Create/update a customer session using `UpdateCustomerSessionV2` function
                IntegrationStateV2 response = integrationApi.UpdateCustomerSessionV2(customerSessionId, body);
                Console.WriteLine(response);

                // Parsing the returned effects list, please consult https://developers.talon.one/Integration-API/handling-effects-v2 for the full list of effects and their corresponding properties
                foreach (Effect effect in response.Effects) {
                    switch(effect.EffectType) {
                        case "setDiscount":
                            // Initiating right props instance according to the effect type
                            SetDiscountEffectProps setDiscountEffectProps = (SetDiscountEffectProps) Newtonsoft.Json.JsonConvert.DeserializeObject(effect.Props.ToString(), typeof(SetDiscountEffectProps));

                            // Access the specific effect's properties
                            Console.WriteLine("Set a discount '{0}' of {1:00.000}", setDiscountEffectProps.Name, setDiscountEffectProps.Value);
                            break;
                        // case "acceptCoupon":
                            // AcceptCouponEffectProps acceptCouponEffectProps = (AcceptCouponEffectProps) Newtonsoft.Json.JsonConvert.DeserializeObject(effect.Props.ToString(), typeof(AcceptCouponEffectProps));

                            // Work with AcceptCouponEffectProps' properties
                            // ...
                            // break;
                        default:
                            Console.WriteLine("Encounter unknown effect type: {0}", effect.EffectType);
                            break;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling IntegrationApi.UpdateCustomerSessionV2: " + e.Message );
            }
        }
    }
}

V1

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 = "unique_profile_integration_id",
                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 response = integrationApi.UpdateCustomerSession(customerSessionId, customerSessionPayload);
                Console.WriteLine(response);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling IntegrationApi.UpdateCustomerSession: " + e.Message );
            }
        }
    }
}

Management API

using System;
using System.Diagnostics;
using TalonOne.Api;
using TalonOne.Client;
using TalonOne.Model;

namespace Example
{
    public class Example
    {
        public void main()
        {
            // Configure BasePath
            var managementConfig = new Configuration {
                BasePath = "https://mycompany.talon.one"
            };

            // Or via the "global" Default configuration:
            //   Configuration.Default.BasePath = "https://mycompany.talon.one";

            // ****************************************************
            // Management API example to load application with id 7
            // ****************************************************

            // When using the default approach, the next initiation of `ManagementApi`
            // could be using the empty constructor
            var managementApi = new ManagementApi(managementConfig);

            try
            {
                // Obtain session token
                var loginParams = new LoginParams("admin@talon.one", "https://whatthecommit.com/17fe05217dbe10af4d1158c71914faeb");
                var session = managementApi.CreateSession(loginParams);

                // Save token in the configuration for future management API calls
                managementConfig.ApiKey.Add("Authorization", session.Token);
                managementConfig.ApiKeyPrefix.Add("Authorization", "Bearer");

                // Or again, via the "global" Default configuration:
                //   Configuration.Default.ApiKey.Add("Authorization", session.Token);
                //   Configuration.Default.ApiKeyPrefix.Add("Authorization", "Bearer");

                // Calling `GetApplication` function with the desired id (7)
                Application app = managementApi.GetApplication(7);
                Console.WriteLine(app);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling ManagementApi.GetApplication: " + e.Message );
            }
        }
    }
}

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
IntegrationApi CreateCouponReservation POST /v1/coupon_reservations/{couponValue} Create a new coupon reservation
IntegrationApi CreateReferral POST /v1/referrals Create a referral code for an advocate
IntegrationApi DeleteCouponReservation DELETE /v1/coupon_reservations/{couponValue} Delete coupon reservations
IntegrationApi DeleteCustomerData DELETE /v1/customer_data/{integrationId} Delete the personal data of a customer.
IntegrationApi GetCustomerInventory GET /v1/customer_profiles/{integrationId}/inventory Get an inventory of all data associated with a specific customer profile.
IntegrationApi GetReservedCustomers GET /v1/coupon_reservations/customerprofiles/{couponValue} Get the users that have this coupon reserved
IntegrationApi TrackEvent POST /v1/events Track an Event
IntegrationApi UpdateCustomerProfile PUT /v1/customer_profiles/{integrationId} Update a Customer Profile V1
IntegrationApi UpdateCustomerProfileAudiences POST /v2/customer_audiences Update a Customer Profile Audiences
IntegrationApi UpdateCustomerProfileV2 PUT /v2/customer_profiles/{integrationId} Update a Customer Profile
IntegrationApi UpdateCustomerProfilesV2 PUT /v2/customer_profiles Update multiple Customer Profiles
IntegrationApi UpdateCustomerSession PUT /v1/customer_sessions/{customerSessionId} Update a Customer Session V1
IntegrationApi UpdateCustomerSessionV2 PUT /v2/customer_sessions/{customerSessionId} Update a Customer Session
ManagementApi AddLoyaltyPoints PUT /v1/loyalty_programs/{programID}/profile/{integrationID}/add_points Add points in a certain loyalty program for the specified customer
ManagementApi CopyCampaignToApplications POST /v1/applications/{applicationId}/campaigns/{campaignId}/copy Copy the campaign into every specified application
ManagementApi CreateAdditionalCost POST /v1/additional_costs Define a new additional cost
ManagementApi CreateAttribute POST /v1/attributes Define a new custom attribute
ManagementApi CreateCampaign POST /v1/applications/{applicationId}/campaigns Create a Campaign
ManagementApi CreateCoupons POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons Create Coupons
ManagementApi CreatePasswordRecoveryEmail POST /v1/password_recovery_emails Request a password reset
ManagementApi CreateRuleset POST /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets Create a Ruleset
ManagementApi CreateSession POST /v1/sessions Create a Session
ManagementApi DeleteCampaign DELETE /v1/applications/{applicationId}/campaigns/{campaignId} Delete a Campaign
ManagementApi DeleteCoupon DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/coupons/{couponId} Delete one Coupon
ManagementApi DeleteCoupons DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/coupons Delete Coupons
ManagementApi DeleteReferral DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/referrals/{referralId} Delete one Referral
ManagementApi DeleteRuleset DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets/{rulesetId} Delete a Ruleset
ManagementApi GetAccessLogs GET /v1/applications/{applicationId}/access_logs Get access logs for application (with total count)
ManagementApi GetAccessLogsWithoutTotalCount GET /v1/applications/{applicationId}/access_logs/no_total Get access logs for application
ManagementApi GetAccount GET /v1/accounts/{accountId} Get Account Details
ManagementApi GetAccountAnalytics GET /v1/accounts/{accountId}/analytics Get Account Analytics
ManagementApi GetAdditionalCost GET /v1/additional_costs/{additionalCostId} Get an additional cost
ManagementApi GetAdditionalCosts GET /v1/additional_costs List additional costs
ManagementApi GetAllAccessLogs GET /v1/access_logs Get all access logs
ManagementApi GetAllRoles GET /v1/roles Get all roles.
ManagementApi GetApplication GET /v1/applications/{applicationId} Get Application
ManagementApi GetApplicationApiHealth GET /v1/applications/{applicationId}/health_report Get report of health of application API
ManagementApi GetApplicationCustomer GET /v1/applications/{applicationId}/customers/{customerId} Get Application Customer
ManagementApi GetApplicationCustomers GET /v1/applications/{applicationId}/customers List Application Customers
ManagementApi GetApplicationCustomersByAttributes POST /v1/application_customer_search Get a list of the customer profiles that match the given attributes (with total count)
ManagementApi GetApplicationEventTypes GET /v1/applications/{applicationId}/event_types List Applications Event Types
ManagementApi GetApplicationEvents GET /v1/applications/{applicationId}/events List Applications Events (with total count)
ManagementApi GetApplicationEventsWithoutTotalCount GET /v1/applications/{applicationId}/events/no_total List Applications Events
ManagementApi GetApplicationSession GET /v1/applications/{applicationId}/sessions/{sessionId} Get Application Session
ManagementApi GetApplicationSessions GET /v1/applications/{applicationId}/sessions List Application Sessions
ManagementApi GetApplications GET /v1/applications List Applications
ManagementApi GetAttribute GET /v1/attributes/{attributeId} Get a custom attribute
ManagementApi GetAttributes GET /v1/attributes List custom attributes
ManagementApi GetCampaign GET /v1/applications/{applicationId}/campaigns/{campaignId} Get a Campaign
ManagementApi GetCampaignAnalytics GET /v1/applications/{applicationId}/campaigns/{campaignId}/analytics Get analytics of campaigns
ManagementApi GetCampaignByAttributes POST /v1/applications/{applicationId}/campaigns_search Get a list of all campaigns that match the given attributes
ManagementApi GetCampaigns GET /v1/applications/{applicationId}/campaigns List your Campaigns
ManagementApi GetChanges GET /v1/changes Get audit log for an account
ManagementApi GetCoupons GET /v1/applications/{applicationId}/campaigns/{campaignId}/coupons List Coupons (with total count)
ManagementApi GetCouponsByAttributes POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons_search Get a list of the coupons that match the given attributes
ManagementApi GetCouponsByAttributesApplicationWide POST /v1/applications/{applicationId}/coupons_search Get a list of the coupons that match the given attributes in all active campaigns of an application (with total count)
ManagementApi GetCouponsWithoutTotalCount GET /v1/applications/{applicationId}/campaigns/{campaignId}/coupons/no_total List Coupons
ManagementApi GetCustomerActivityReport GET /v1/applications/{applicationId}/customer_activity_reports/{customerId} Get Activity Report for Single Customer
ManagementApi GetCustomerActivityReports GET /v1/applications/{applicationId}/customer_activity_reports Get Activity Reports for Application Customers (with total count)
ManagementApi GetCustomerActivityReportsWithoutTotalCount GET /v1/applications/{applicationId}/customer_activity_reports/no_total Get Activity Reports for Application Customers
ManagementApi GetCustomerAnalytics GET /v1/applications/{applicationId}/customers/{customerId}/analytics Get Analytics Report for a Customer
ManagementApi GetCustomerProfile GET /v1/customers/{customerId} Get Customer Profile
ManagementApi GetCustomerProfiles GET /v1/customers/no_total List Customer Profiles
ManagementApi GetCustomersByAttributes POST /v1/customer_search/no_total Get a list of the customer profiles that match the given attributes
ManagementApi GetEventTypes GET /v1/event_types List Event Types
ManagementApi GetExports GET /v1/exports Get Exports
ManagementApi GetImports GET /v1/imports Get Imports
ManagementApi GetLoyaltyPoints GET /v1/loyalty_programs/{programID}/profile/{integrationID} get the Loyalty Ledger for this integrationID
ManagementApi GetLoyaltyProgram GET /v1/loyalty_programs/{programID} Get a loyalty program
ManagementApi GetLoyaltyPrograms GET /v1/loyalty_programs List all loyalty Programs
ManagementApi GetLoyaltyStatistics GET /v1/loyalty_programs/{programID}/statistics Get loyalty program statistics by loyalty program ID
ManagementApi GetReferrals GET /v1/applications/{applicationId}/campaigns/{campaignId}/referrals List Referrals (with total count)
ManagementApi GetReferralsWithoutTotalCount GET /v1/applications/{applicationId}/campaigns/{campaignId}/referrals/no_total List Referrals
ManagementApi GetRole GET /v1/roles/{roleId} Get information for the specified role.
ManagementApi GetRuleset GET /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets/{rulesetId} Get a Ruleset
ManagementApi GetRulesets GET /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets List Campaign Rulesets
ManagementApi GetUser GET /v1/users/{userId} Get a single User
ManagementApi GetUsers GET /v1/users List Users in your account
ManagementApi GetWebhook GET /v1/webhooks/{webhookId} Get Webhook
ManagementApi GetWebhookActivationLogs GET /v1/webhook_activation_logs List Webhook activation Log Entries
ManagementApi GetWebhookLogs GET /v1/webhook_logs List Webhook Log Entries
ManagementApi GetWebhooks GET /v1/webhooks List Webhooks
ManagementApi RemoveLoyaltyPoints PUT /v1/loyalty_programs/{programID}/profile/{integrationID}/deduct_points Deduct points in a certain loyalty program for the specified customer
ManagementApi ResetPassword POST /v1/reset_password Reset password
ManagementApi SearchCouponsAdvanced POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons_search_advanced Get a list of the coupons that match the given attributes (with total count)
ManagementApi SearchCouponsAdvancedApplicationWide POST /v1/applications/{applicationId}/coupons_search_advanced Get a list of the coupons that match the given attributes in all active campaigns of an application (with total count)
ManagementApi SearchCouponsAdvancedApplicationWideWithoutTotalCount POST /v1/applications/{applicationId}/coupons_search_advanced/no_total Get a list of the coupons that match the given attributes in all active campaigns of an application
ManagementApi SearchCouponsAdvancedWithoutTotalCount POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons_search_advanced/no_total Get a list of the coupons that match the given attributes
ManagementApi UpdateAdditionalCost PUT /v1/additional_costs/{additionalCostId} Update an additional cost
ManagementApi UpdateAttribute PUT /v1/attributes/{attributeId} Update a custom attribute
ManagementApi UpdateCampaign PUT /v1/applications/{applicationId}/campaigns/{campaignId} Update a Campaign
ManagementApi UpdateCoupon PUT /v1/applications/{applicationId}/campaigns/{campaignId}/coupons/{couponId} Update a Coupon
ManagementApi UpdateCouponBatch PUT /v1/applications/{applicationId}/campaigns/{campaignId}/coupons Update a Batch of Coupons
ManagementApi UpdateRuleset PUT /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets/{rulesetId} Update a Ruleset

Documentation for Models

Documentation for Authorization

api_key_v1

  • Type: API key

  • API key parameter name: Authorization

  • Location: HTTP header

integration_auth

  • Type: API key

  • API key parameter name: Content-Signature

  • Location: HTTP header

manager_auth

  • Type: API key

  • API key parameter name: Authorization

  • Location: HTTP header

About

Talon.One API SDK for C#

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.9%
  • Other 0.1%