Coder Social home page Coder Social logo

julianmican / talononejavasdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from talon-one/talononejavasdk

0.0 0.0 0.0 3 MB

Talon.One API SDK for Java

Home Page: https://docs.talon.one/docs/dev/sdks/java

Shell 0.05% Java 99.89% Scala 0.03% Makefile 0.03%

talononejavasdk's Introduction

talon-one-client

Talon.One API

  • API version: 1.0.0

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}

Automatically generated by the OpenAPI Generator

Requirements

Building the API client library requires:

  1. Java 1.7+
  2. Maven/Gradle

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>one.talon</groupId>
  <artifactId>talon-one-client</artifactId>
  <version>4.4.1</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "one.talon:talon-one-client:4.4.1"

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/talon-one-client-4.4.1.jar
  • target/lib/*.jar

Getting Started

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

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.

package com.example.consumer;

import com.google.gson.Gson;

import one.talon.ApiClient;
import one.talon.api.IntegrationApi;
import one.talon.api.ManagementApi;
import one.talon.model.*;

public class TalonApiTest {
    public static void main(String[] args) {
        Gson gson = new Gson();
        IntegrationApi iApi = new IntegrationApi(new ApiClient("api_key_v1"));

        // Setup: basePath
        iApi.getApiClient().setBasePath("https://mycompany.talon.one");
        // Setup: when using 'api_key_v1', set apiKey & apiKeyPrefix must be provided
        iApi.getApiClient().setApiKeyPrefix("ApiKey-v1");
        iApi.getApiClient().setApiKey("dbc644d33aa74d582bd9479c59e16f970fe13bf34a208c39d6c7fa7586968468");

        try {
          // Creating a cart item object
            CartItem cartItem = new CartItem();
            cartItem.setName("Hawaiian Pizza");
            cartItem.setSku("pizza-x");
            cartItem.setQuantity(1);
            cartItem.setPrice(new java.math.BigDecimal("5.5"));

            // Creating a customer session of V2
            NewCustomerSessionV2 customerSession = new NewCustomerSessionV2();
            customerSession.setProfileId("Cool_Dude");
            customerSession.addCouponCodesItem("Cool-Summer!");
            customerSession.addCartItemsItem(cartItem);

            // Initiating integration request wrapping the customer session update
            IntegrationRequest request = new IntegrationRequest()
                .customerSession(customerSession)
                // Optional parameter of requested information to be present on the response related to the customer session update
                .responseContent(Arrays.asList(
                    IntegrationRequest.ResponseContentEnum.CUSTOMERSESSION,
                    IntegrationRequest.ResponseContentEnum.CUSTOMERPROFILE
                ));

            // Flag to communicate whether the request is a "dry run"
            Boolean dryRun = false;

            // Create/update a customer session using `updateCustomerSessionV2` function
            IntegrationStateV2 is = iApi.updateCustomerSessionV2("deetdoot", request, dryRun);
            System.out.println(is.toString());

            // 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
            for (Effect eff : is.getEffects()) {
                if (eff.getEffectType().equals("addLoyaltyPoints")) {
                    // Typecasting according to the specific effect type
                    AddLoyaltyPointsEffectProps props = gson.fromJson(
                        gson.toJson(eff.getProps()),
                        AddLoyaltyPointsEffectProps.class
                    );
                    // Access the specific effect's properties
                    System.out.println(props.getName());
                    System.out.println(props.getProgramId());
                    System.out.println(props.getValue());
                }
                if (eff.getEffectType().equals("acceptCoupon")) {
                    // Typecasting according to the specific effect type
                    AcceptCouponEffectProps props = gson.fromJson(
                      gson.toJson(eff.getProps()),
                      AcceptCouponEffectProps.class
                    );
                    // work with AcceptCouponEffectProps' properties
                    // ...
                }
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

Management API

package com.example.consumer;

import one.talon.ApiClient;
import one.talon.api.IntegrationApi;
import one.talon.api.ManagementApi;
import one.talon.model.*;

public class TalonApiTest {
    public static void main(String[] args) {
        // Management API example to load application with id 7
        ManagementApi mApi = new ManagementApi(new ApiClient("manager_auth"));

        // Setup: basePath and bearer prefix
        mApi.getApiClient().setBasePath("https://mycompany.talon.one");
        mApi.getApiClient().setApiKeyPrefix("Bearer");

        LoginParams lp = new LoginParams();
        lp.setEmail("[email protected]");
        lp.setPassword("yourpassword");

        try {
            // Acquire session token
            Session s = mApi.createSession(lp);
            mApi.getApiClient().setApiKey(s.getToken());

            // Calling `getApplication` function with the desired id (7)
            Application application = mApi.getApplication(7);
            System.out.println(application.toString());
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

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 createReferralsForMultipleAdvocates POST /v1/referrals_for_multiple_advocates Create referral codes for multiple advocates
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 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 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 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 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 destroySession DELETE /v1/sessions Destroy a Session
ManagementApi exportCoupons GET /v1/applications/{applicationId}/export_coupons Export Coupons to a CSV file
ManagementApi exportCustomerSessions GET /v1/applications/{applicationId}/export_customer_sessions Export Customer Sessions to a CSV file
ManagementApi exportEffects GET /v1/applications/{applicationId}/export_effects Export triggered Effects to a 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 a CSV file
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 getAudiences GET /v1/audiences Get all audiences
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 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 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 giveaways codes into a giveaways 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 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 updateReferral PUT /v1/applications/{applicationId}/campaigns/{campaignId}/referrals/{referralId} Update one Referral
ManagementApi updateRuleset PUT /v1/applications/{applicationId}/campaigns/{campaignId}/rulesets/{rulesetId} Update a Ruleset

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

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

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Author

talononejavasdk's People

Contributors

refs avatar altjake avatar dependabot[bot] 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.