Giter Club home page Giter Club logo

talonone.cs's Introduction

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

Use the Talon.One API to integrate with your application and to manage applications and campaigns:

Determining the base URL of the endpoints

The API is available at the same hostname as your Campaign Manager deployment. For example, if you are reading this page at https://mycompany.talon.one/docs/api/, the URL for the updateCustomerSession endpoint is https://mycompany.talon.one/v2/customer_sessions/{Id}

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

  • API version: 1.0.0
  • SDK version: 4.0.2
  • Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen

Frameworks supported

  • .NET Core >=1.0
  • .NET Framework >=4.6
  • Mono/Xamarin >=vNext

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
Install-Package System.ComponentModel.Annotations

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

Installation

Generate the DLL using your preferred tool (e.g. dotnet build)

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;

Getting Started

Integration API

Note: The Integration API's V1 Update customer session and Update customer profile endpoints are now deprecated. Use their V2 instead. See Migrating to V2 for more information.

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

namespace Example
{
    public class Example
    {
        public static 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" }
                }
            };

            // ************************************************
            // 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);
                Debug.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
                            Debug.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:
                            Debug.WriteLine("Encounter unknown effect type: {0}", effect.EffectType);
                            break;
                    }
                }
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling IntegrationApi.UpdateCustomerSessionV2: " + e.Message );
            }
        }
    }
}

Management API

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

namespace Example
{
    public class Example
    {
        public static void Main()
        {
            // Configure BasePath
            var managementConfig = new Configuration {
                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("[email protected]", "https://whatthecommit.com/17fe05217dbe10af4d1158c71914faeb");
                var session = managementApi.CreateSession(loginParams);

                // Save token in the configuration for future management API calls
                managementConfig.AddApiKey("Authorization", session.Token);
                managementConfig.AddApiKeyPrefix("Authorization", "Bearer");
                managementApi = new ManagementApi(managementConfig); // re-instantiate an api instance for the token to take effect

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

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
IntegrationApi CreateAudienceV2 POST /v2/audiences Create audience
IntegrationApi CreateCouponReservation POST /v1/coupon_reservations/{couponValue} Create coupon reservation
IntegrationApi CreateReferral POST /v1/referrals Create referral code for an advocate
IntegrationApi CreateReferralsForMultipleAdvocates POST /v1/referrals_for_multiple_advocates Create referral codes for multiple advocates
IntegrationApi DeleteAudienceMembershipsV2 DELETE /v2/audiences/{audienceId}/memberships Delete audience memberships
IntegrationApi DeleteAudienceV2 DELETE /v2/audiences/{audienceId} Delete audience
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 List data associated with a specific customer profile
IntegrationApi GetReservedCustomers GET /v1/coupon_reservations/customerprofiles/{couponValue} List users that have this coupon reserved
IntegrationApi TrackEvent POST /v1/events Track an Event
IntegrationApi UpdateAudienceCustomersAttributes PUT /v2/audience_customers/{audienceId}/attributes Update profile attributes for all customers in audience
IntegrationApi UpdateAudienceV2 PUT /v2/audiences/{audienceId} Update audience
IntegrationApi UpdateCustomerProfileAudiences POST /v2/customer_audiences Update multiple customer profiles' audiences
IntegrationApi UpdateCustomerProfileV2 PUT /v2/customer_profiles/{integrationId} Update customer profile
IntegrationApi UpdateCustomerProfilesV2 PUT /v2/customer_profiles Update multiple customer profiles
IntegrationApi UpdateCustomerSessionV2 PUT /v2/customer_sessions/{customerSessionId} Update customer session
ManagementApi AddLoyaltyPoints PUT /v1/loyalty_programs/{programID}/profile/{integrationID}/add_points Add points in loyalty program for given 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 Create custom attribute
ManagementApi CreateCampaign POST /v1/applications/{applicationId}/campaigns Create campaign
ManagementApi CreateCoupons POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons Create coupons
ManagementApi CreateCouponsForMultipleRecipients POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons_with_recipients Create coupons for multiple recipients
ManagementApi CreatePasswordRecoveryEmail POST /v1/password_recovery_emails Request a password reset
ManagementApi CreateRuleset POST /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets Create ruleset
ManagementApi CreateSession POST /v1/sessions Create session
ManagementApi DeleteCampaign DELETE /v1/applications/{applicationId}/campaigns/{campaignId} Delete campaign
ManagementApi DeleteCoupon DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/coupons/{couponId} Delete coupon
ManagementApi DeleteCoupons DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/coupons Delete coupons
ManagementApi DeleteReferral DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/referrals/{referralId} Delete referral
ManagementApi DestroySession DELETE /v1/sessions Destroy session
ManagementApi ExportCoupons GET /v1/applications/{applicationId}/export_coupons Export coupons to CSV file
ManagementApi ExportCustomerSessions GET /v1/applications/{applicationId}/export_customer_sessions Export customer sessions to CSV file
ManagementApi ExportEffects GET /v1/applications/{applicationId}/export_effects Export triggered effects to CSV file
ManagementApi ExportLoyaltyBalance GET /v1/loyalty_programs/{programID}/export_customer_balance Export customer loyalty balance to a CSV file
ManagementApi ExportLoyaltyLedger GET /v1/loyalty_programs/{programID}/profile/{integrationID}/export_log Export a customer's loyalty ledger log to CSV file
ManagementApi ExportReferrals GET /v1/applications/{applicationId}/export_referrals Export referrals to CSV file
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 List access logs
ManagementApi GetAllRoles GET /v1/roles List 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's customer
ManagementApi GetApplicationCustomerFriends GET /v1/applications/{applicationId}/profile/{integrationId}/friends List friends referred by customer profile
ManagementApi GetApplicationCustomers GET /v1/applications/{applicationId}/customers List application's customers
ManagementApi GetApplicationCustomersByAttributes POST /v1/applications/{applicationId}/customer_search List application customers matching the given attributes
ManagementApi GetApplicationEventTypes GET /v1/applications/{applicationId}/event_types List Applications event types
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 GetAudiences GET /v1/audiences List audiences
ManagementApi GetCampaign GET /v1/applications/{applicationId}/campaigns/{campaignId} Get campaign
ManagementApi GetCampaignAnalytics GET /v1/applications/{applicationId}/campaigns/{campaignId}/analytics Get analytics of campaigns
ManagementApi GetCampaignByAttributes POST /v1/applications/{applicationId}/campaigns_search List campaigns that match the given attributes
ManagementApi GetCampaigns GET /v1/applications/{applicationId}/campaigns List campaigns
ManagementApi GetChanges GET /v1/changes Get audit log for an account
ManagementApi GetCouponsByAttributes POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons_search List coupons that match the given attributes
ManagementApi GetCouponsWithoutTotalCount GET /v1/applications/{applicationId}/campaigns/{campaignId}/coupons/no_total List coupons
ManagementApi GetCustomerActivityReport GET /v1/applications/{applicationId}/customer_activity_reports/{customerId} Get customer's activity report
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 customer's analytics report
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 List customer profiles matching the given attributes
ManagementApi GetEventTypes GET /v1/event_types List Event Types
ManagementApi GetExports GET /v1/exports Get Exports
ManagementApi GetLoyaltyPoints GET /v1/loyalty_programs/{programID}/profile/{integrationID} Get the Loyalty Ledger for this integrationID
ManagementApi GetLoyaltyProgram GET /v1/loyalty_programs/{programID} Get loyalty program
ManagementApi GetLoyaltyPrograms GET /v1/loyalty_programs List loyalty programs
ManagementApi GetLoyaltyStatistics GET /v1/loyalty_programs/{programID}/statistics Get loyalty program statistics by loyalty program ID
ManagementApi GetReferralsWithoutTotalCount GET /v1/applications/{applicationId}/campaigns/{campaignId}/referrals/no_total List referrals
ManagementApi GetRole GET /v1/roles/{roleId} Get role
ManagementApi GetRuleset GET /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets/{rulesetId} Get 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 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 ImportCollection POST /v1/applications/{applicationId}/campaigns/{campaignId}/collections/{collectionId}/import Import collection via CSV file
ManagementApi ImportCoupons POST /v1/applications/{applicationId}/campaigns/{campaignId}/import_coupons Import coupons via CSV file
ManagementApi ImportLoyaltyPoints POST /v1/loyalty_programs/{programID}/import_points Import loyalty points via CSV file
ManagementApi ImportPoolGiveaways POST /v1/giveaways/pools/{poolId}/import Import giveaway codes into a giveaway pool
ManagementApi ImportReferrals POST /v1/applications/{applicationId}/campaigns/{campaignId}/import_referrals Import referrals via CSV file
ManagementApi RemoveLoyaltyPoints PUT /v1/loyalty_programs/{programID}/profile/{integrationID}/deduct_points Deduct points in loyalty program for given customer
ManagementApi ResetPassword POST /v1/reset_password Reset password
ManagementApi SearchCouponsAdvancedApplicationWideWithoutTotalCount POST /v1/applications/{applicationId}/coupons_search_advanced/no_total List 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 List 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 campaign
ManagementApi UpdateCoupon PUT /v1/applications/{applicationId}/campaigns/{campaignId}/coupons/{couponId} Update coupon
ManagementApi UpdateCouponBatch PUT /v1/applications/{applicationId}/campaigns/{campaignId}/coupons Update a batch of coupons
ManagementApi UpdateReferral PUT /v1/applications/{applicationId}/campaigns/{campaignId}/referrals/{referralId} Update referral
ManagementApi UpdateRuleset PUT /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets/{rulesetId} Update ruleset

Documentation for Models

Documentation for Authorization

api_key_v1

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

manager_auth

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

talonone.cs's People

Contributors

altjake avatar grncdr avatar

Stargazers

Gilberto Bittencourt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.