Giter VIP home page Giter VIP logo

talon_one.js's Introduction

talon_one

TalonOne - JavaScript client for talon_one 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

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.0.0
  • Package version: 4.2.0
  • Build package: org.openapitools.codegen.languages.JavascriptClientCodegen

Installation

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install talon_one --save

Finally, you need to build the module:

npm run build
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

To use the link you just defined in your project, switch to the directory you want to use your talon_one from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

Finally, you need to build the module:

npm run build

git

If the library is hosted at a git repository, e.g.https://github.com/talon-one/talon_one.js then install it via:

    npm install talon-one/talon_one.js --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

Integration API

V2

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();

// Initializing a customer session object
const customerSession = TalonOne.NewCustomerSessionV2.constructFromObject({
  profileId: 'example_prof_id',
  cartItems: [
    {
      name: 'Döner King',
      sku: 'kd-100',
      quantity: 1,
      price: 2.00,
      category: 'pizzas'
    },
    {
      name: 'Spezi 500ml',
      sku: 'sp-50',
      quantity: 1,
      price: 2,
      category: 'beverages'
    },
    {
      name: 'Queen Döner',
      sku: 'qd-100',
      quantity: 1,
      price: 2.50,
      category: 'pizzas'
    },
    {
      name: 'Club Mate 330ml',
      sku: 'cm-33',
      quantity: 1,
      price: 1.80,
      category: 'beverages'
    }
  ],
  couponCodes: [
    'Cool-Summer!'
  ]
});

//Initializing an integration request wrapping the customer session
const integrationRequest = new TalonOne.IntegrationRequest(customerSession);

// Optional list of requested information to be present on the response.
// See src/model/IntegrationRequest#ResponseContentEnum for full list of supported values
// integrationRequest.responseContent = [
//   TalonOne.IntegrationRequest.ResponseContentEnum.customerSession,
//   TalonOne.IntegrationRequest.ResponseContentEnum.customerProfile
// ]

integrationApi
  .updateCustomerSessionV2("example_integration_v2_id", integrationRequest)
  .then(
    data => {
      console.log(JSON.stringify(data, null, 2));

      // 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
      data.effects.forEach(effect => {
        switch(effect.effectType) {
          case 'setDiscount':
            // Initiating right props instance according to the effect type
            const setDiscountProps = TalonOne.SetDiscountEffectProps.constructFromObject(effect.props)
            // Initiating the right props class is not a necessity, it is only a suggestion here that could help in case of unexpected returned values from the API

            // Access the specific effect's properties
            console.log(`Set a discount '${setDiscountProps.name}' of ${setDiscountProps.value}`)
            break
          case 'acceptCoupon':
            // Work with AcceptCouponEffectProps' properties
            // ...
          default:
            throw new Error(`Unhandled effect type from Talon.One integration: ${effect.effectType}`)
        }
      })
    },
    err => {
      console.error(err);
    }
  );

V1

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();

/**
 * // Using `constructFromObject` initializer:
 * const customerSession = TalonOne.NewCustomerSession.constructFromObject({
 *   total: 100.33,
 *   coupon: "Cool-Summer!"
 * });
 */

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);
    }
  );

Management API

const TalonOne = require("talon_one");

const defaultClient = TalonOne.ApiClient.instance;
defaultClient.basePath = "https://mycompany.talon.one";

// Configure API key authorization: manager_auth
const managerAuth = defaultClient.authentications["manager_auth"];
managerAuth.apiKeyPrefix = "Bearer";

// Management API example to load application with id 7
const managerApi = new TalonOne.ManagementApi();

/**
 * // Using `constructFromObject`:
 * const loginParams = TalonOne.LoginParams.constructFromObject({
 *   email: "[email protected]",
 *   password: "$hhhD0ntT3ll!"
 * });
 */

const loginParams = new TalonOne.LoginParams(
  "[email protected]",
  "$hhhD0ntT3ll!"
);

managerApi.createSession(loginParams).then(
  function(data) {
    // Save token in the configuration for future management API calls
    managerAuth.apiKey = data.token;

    // Calling `getApplication` function with the desired id (7)
    managerApi.getApplication(7).then(
      function(data) {
        console.log(
          "API called successfully. Returned data:\n" + JSON.stringify(data)
        );
      },
      function(error) {
        console.error("Error while fetching the application:\n" + error);
      }
    );
  },
  function(error) {
    console.error("Error while login:\n" + error);
  }
);

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
TalonOne.IntegrationApi createCouponReservation POST /v1/coupon_reservations/{couponValue} Create a new coupon reservation
TalonOne.IntegrationApi createReferral POST /v1/referrals Create a referral code for an advocate
TalonOne.IntegrationApi deleteCouponReservation DELETE /v1/coupon_reservations/{couponValue} Delete coupon reservations
TalonOne.IntegrationApi deleteCustomerData DELETE /v1/customer_data/{integrationId} Delete the personal data of a customer.
TalonOne.IntegrationApi getCustomerInventory GET /v1/customer_profiles/{integrationId}/inventory Get an inventory of all data associated with a specific customer profile.
TalonOne.IntegrationApi getReservedCustomers GET /v1/coupon_reservations/customerprofiles/{couponValue} Get the users that have this coupon reserved
TalonOne.IntegrationApi trackEvent POST /v1/events Track an Event
TalonOne.IntegrationApi updateCustomerProfile PUT /v1/customer_profiles/{integrationId} Update a Customer Profile V1
TalonOne.IntegrationApi updateCustomerProfileAudiences POST /v2/customer_audiences Update a Customer Profile Audiences
TalonOne.IntegrationApi updateCustomerProfileV2 PUT /v2/customer_profiles/{integrationId} Update a Customer Profile
TalonOne.IntegrationApi updateCustomerProfilesV2 PUT /v2/customer_profiles Update multiple Customer Profiles
TalonOne.IntegrationApi updateCustomerSession PUT /v1/customer_sessions/{customerSessionId} Update a Customer Session V1
TalonOne.IntegrationApi updateCustomerSessionV2 PUT /v2/customer_sessions/{customerSessionId} Update a Customer Session
TalonOne.ManagementApi addLoyaltyPoints PUT /v1/loyalty_programs/{programID}/profile/{integrationID}/add_points Add points in a certain loyalty program for the specified customer
TalonOne.ManagementApi copyCampaignToApplications POST /v1/applications/{applicationId}/campaigns/{campaignId}/copy Copy the campaign into every specified application
TalonOne.ManagementApi createAdditionalCost POST /v1/additional_costs Define a new additional cost
TalonOne.ManagementApi createAttribute POST /v1/attributes Define a new custom attribute
TalonOne.ManagementApi createCampaign POST /v1/applications/{applicationId}/campaigns Create a Campaign
TalonOne.ManagementApi createCoupons POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons Create Coupons
TalonOne.ManagementApi createPasswordRecoveryEmail POST /v1/password_recovery_emails Request a password reset
TalonOne.ManagementApi createRuleset POST /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets Create a Ruleset
TalonOne.ManagementApi createSession POST /v1/sessions Create a Session
TalonOne.ManagementApi deleteCampaign DELETE /v1/applications/{applicationId}/campaigns/{campaignId} Delete a Campaign
TalonOne.ManagementApi deleteCoupon DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/coupons/{couponId} Delete one Coupon
TalonOne.ManagementApi deleteCoupons DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/coupons Delete Coupons
TalonOne.ManagementApi deleteReferral DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/referrals/{referralId} Delete one Referral
TalonOne.ManagementApi deleteRuleset DELETE /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets/{rulesetId} Delete a Ruleset
TalonOne.ManagementApi getAccessLogs GET /v1/applications/{applicationId}/access_logs Get access logs for application (with total count)
TalonOne.ManagementApi getAccessLogsWithoutTotalCount GET /v1/applications/{applicationId}/access_logs/no_total Get access logs for application
TalonOne.ManagementApi getAccount GET /v1/accounts/{accountId} Get Account Details
TalonOne.ManagementApi getAccountAnalytics GET /v1/accounts/{accountId}/analytics Get Account Analytics
TalonOne.ManagementApi getAdditionalCost GET /v1/additional_costs/{additionalCostId} Get an additional cost
TalonOne.ManagementApi getAdditionalCosts GET /v1/additional_costs List additional costs
TalonOne.ManagementApi getAllAccessLogs GET /v1/access_logs Get all access logs
TalonOne.ManagementApi getAllRoles GET /v1/roles Get all roles.
TalonOne.ManagementApi getApplication GET /v1/applications/{applicationId} Get Application
TalonOne.ManagementApi getApplicationApiHealth GET /v1/applications/{applicationId}/health_report Get report of health of application API
TalonOne.ManagementApi getApplicationCustomer GET /v1/applications/{applicationId}/customers/{customerId} Get Application Customer
TalonOne.ManagementApi getApplicationCustomers GET /v1/applications/{applicationId}/customers List Application Customers
TalonOne.ManagementApi getApplicationCustomersByAttributes POST /v1/application_customer_search Get a list of the customer profiles that match the given attributes (with total count)
TalonOne.ManagementApi getApplicationEventTypes GET /v1/applications/{applicationId}/event_types List Applications Event Types
TalonOne.ManagementApi getApplicationEvents GET /v1/applications/{applicationId}/events List Applications Events (with total count)
TalonOne.ManagementApi getApplicationEventsWithoutTotalCount GET /v1/applications/{applicationId}/events/no_total List Applications Events
TalonOne.ManagementApi getApplicationSession GET /v1/applications/{applicationId}/sessions/{sessionId} Get Application Session
TalonOne.ManagementApi getApplicationSessions GET /v1/applications/{applicationId}/sessions List Application Sessions
TalonOne.ManagementApi getApplications GET /v1/applications List Applications
TalonOne.ManagementApi getAttribute GET /v1/attributes/{attributeId} Get a custom attribute
TalonOne.ManagementApi getAttributes GET /v1/attributes List custom attributes
TalonOne.ManagementApi getCampaign GET /v1/applications/{applicationId}/campaigns/{campaignId} Get a Campaign
TalonOne.ManagementApi getCampaignAnalytics GET /v1/applications/{applicationId}/campaigns/{campaignId}/analytics Get analytics of campaigns
TalonOne.ManagementApi getCampaignByAttributes POST /v1/applications/{applicationId}/campaigns_search Get a list of all campaigns that match the given attributes
TalonOne.ManagementApi getCampaigns GET /v1/applications/{applicationId}/campaigns List your Campaigns
TalonOne.ManagementApi getChanges GET /v1/changes Get audit log for an account
TalonOne.ManagementApi getCoupons GET /v1/applications/{applicationId}/campaigns/{campaignId}/coupons List Coupons (with total count)
TalonOne.ManagementApi getCouponsByAttributes POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons_search Get a list of the coupons that match the given attributes
TalonOne.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)
TalonOne.ManagementApi getCouponsWithoutTotalCount GET /v1/applications/{applicationId}/campaigns/{campaignId}/coupons/no_total List Coupons
TalonOne.ManagementApi getCustomerActivityReport GET /v1/applications/{applicationId}/customer_activity_reports/{customerId} Get Activity Report for Single Customer
TalonOne.ManagementApi getCustomerActivityReports GET /v1/applications/{applicationId}/customer_activity_reports Get Activity Reports for Application Customers (with total count)
TalonOne.ManagementApi getCustomerActivityReportsWithoutTotalCount GET /v1/applications/{applicationId}/customer_activity_reports/no_total Get Activity Reports for Application Customers
TalonOne.ManagementApi getCustomerAnalytics GET /v1/applications/{applicationId}/customers/{customerId}/analytics Get Analytics Report for a Customer
TalonOne.ManagementApi getCustomerProfile GET /v1/customers/{customerId} Get Customer Profile
TalonOne.ManagementApi getCustomerProfiles GET /v1/customers/no_total List Customer Profiles
TalonOne.ManagementApi getCustomersByAttributes POST /v1/customer_search/no_total Get a list of the customer profiles that match the given attributes
TalonOne.ManagementApi getEventTypes GET /v1/event_types List Event Types
TalonOne.ManagementApi getExports GET /v1/exports Get Exports
TalonOne.ManagementApi getImports GET /v1/imports Get Imports
TalonOne.ManagementApi getLoyaltyPoints GET /v1/loyalty_programs/{programID}/profile/{integrationID} get the Loyalty Ledger for this integrationID
TalonOne.ManagementApi getLoyaltyProgram GET /v1/loyalty_programs/{programID} Get a loyalty program
TalonOne.ManagementApi getLoyaltyPrograms GET /v1/loyalty_programs List all loyalty Programs
TalonOne.ManagementApi getLoyaltyStatistics GET /v1/loyalty_programs/{programID}/statistics Get loyalty program statistics by loyalty program ID
TalonOne.ManagementApi getReferrals GET /v1/applications/{applicationId}/campaigns/{campaignId}/referrals List Referrals (with total count)
TalonOne.ManagementApi getReferralsWithoutTotalCount GET /v1/applications/{applicationId}/campaigns/{campaignId}/referrals/no_total List Referrals
TalonOne.ManagementApi getRole GET /v1/roles/{roleId} Get information for the specified role.
TalonOne.ManagementApi getRuleset GET /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets/{rulesetId} Get a Ruleset
TalonOne.ManagementApi getRulesets GET /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets List Campaign Rulesets
TalonOne.ManagementApi getUser GET /v1/users/{userId} Get a single User
TalonOne.ManagementApi getUsers GET /v1/users List Users in your account
TalonOne.ManagementApi getWebhook GET /v1/webhooks/{webhookId} Get Webhook
TalonOne.ManagementApi getWebhookActivationLogs GET /v1/webhook_activation_logs List Webhook activation Log Entries
TalonOne.ManagementApi getWebhookLogs GET /v1/webhook_logs List Webhook Log Entries
TalonOne.ManagementApi getWebhooks GET /v1/webhooks List Webhooks
TalonOne.ManagementApi removeLoyaltyPoints PUT /v1/loyalty_programs/{programID}/profile/{integrationID}/deduct_points Deduct points in a certain loyalty program for the specified customer
TalonOne.ManagementApi resetPassword POST /v1/reset_password Reset password
TalonOne.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)
TalonOne.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)
TalonOne.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
TalonOne.ManagementApi searchCouponsAdvancedWithoutTotalCount POST /v1/applications/{applicationId}/campaigns/{campaignId}/coupons_search_advanced/no_total Get a list of the coupons that match the given attributes
TalonOne.ManagementApi updateAdditionalCost PUT /v1/additional_costs/{additionalCostId} Update an additional cost
TalonOne.ManagementApi updateAttribute PUT /v1/attributes/{attributeId} Update a custom attribute
TalonOne.ManagementApi updateCampaign PUT /v1/applications/{applicationId}/campaigns/{campaignId} Update a Campaign
TalonOne.ManagementApi updateCoupon PUT /v1/applications/{applicationId}/campaigns/{campaignId}/coupons/{couponId} Update a Coupon
TalonOne.ManagementApi updateCouponBatch PUT /v1/applications/{applicationId}/campaigns/{campaignId}/coupons Update a Batch of Coupons
TalonOne.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

talon_one.js's People

Contributors

refs avatar altjake avatar

Watchers

James Cloos 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.