@flashcoffee/fctalonone
TypeScript icon, indicating that this package has built-in type declarations

1.2.50 • Public • Published

fcbraze

Installation

$ yarn add @flashcoffee/fctalonone

Setup

Set required environment variable for credentials

TALON_ONE_URL=https://your-org.asia-southeast1.talon.one
TALON_ONE_API_KEY=ApiKey-v1 yourapikey
TALON_ONE_TOKEN=Bearer yourtoken
TALON_ONE_APP_ID=123

Usage

import FCTalonOne from '@flashcoffee/fctalonone';

await FCTalonOne.integrationApi.updateCustomerSessionV2();
await FCTalonOne.managementApi.getLoyaltyPoints();

OR

import {TalonOneIntegrationApi} from '@flashcoffee/fctalonone';

@Injectable()
export class SomeService {
  constructor(
    private readonly talonOneIntegration: TalonOneIntegrationApi,
    private readonly talonOneManagement: TalonOneManagementApi,
  ) {}

  public async someMethod() {
    await this.talonOneIntegration.updateCustomerSessionV2();
    await this.talonOneManagement.getLoyaltyPoints();
  }
}

@Module({
  providers: [SomeService, TalonOneIntegrationApi],
})
export class SomeModule {}

Available APIs (integration)

All: Github

talonOneIntegration.api; // Available APIs: https://github.com/talon-one/talon_one.js/blob/master/docs/IntegrationApi.md#talononeintegrationapi
talonOneIntegration.updateCustomerSessionV2();
talonOneIntegration.updateCustomerProfileV2();

Available APIs (Management)

All: Github

talonOneManagement.api; // Available APIs: https://github.com/talon-one/talon_one.js/blob/master/docs/ManagementApi.md#talononemanagementapi
talonOneManagement.getApplications();
talonOneManagement.getCampaign();
talonOneManagement.getCampaigns();
talonOneManagement.getCampaignByAttributes();
talonOneManagement.getApplicationCustomer();
talonOneManagement.getApplicationCustomers();
talonOneManagement.getCustomersByAttributes();
talonOneManagement.getLoyaltyPoints();
talonOneManagement.addLoyaltyPoints();
talonOneManagement.removeLoyaltyPoints();
talonOneManagement.searchCouponsAdvancedApplicationWideWithoutTotalCount();
talonOneManagement.createCoupons();
talonOneManagement.updateCoupon();
talonOneManagement.deleteCoupons();

Error Handle

Can refer to this interfaces:

import {
  ITalonOneError,
  IErrorResponse,
  IErrorResponseWithStatus,
  IAPIError,
  IErrorSource,
} from '@flashcoffee/fctalonone';
import {ITalonOneError} from '@flashcoffee/fctalonone';

try {
  const loyaltyPoints = await FCTalonOne.managementApi.getLoyaltyPoints();
} catch (error) {
  if ((error as ITalonOneError).response?.ok === false) {
    const err = error as ITalonOneError;

    console.error('Error', {
      status: err.status,
      statusText: err.statusText,
      body: {
        message: err.body.message,
        errors: err.body.errors,
        StatusCode: err.body.StatusCode,
      },
      response: err.response,
    });

    throw error;
  }
}

Readme

Keywords

Package Sidebar

Install

npm i @flashcoffee/fctalonone

Weekly Downloads

7

Version

1.2.50

License

ISC

Unpacked Size

172 kB

Total Files

239

Last publish

Collaborators

  • geunta.buwono.fc
  • hirzieji.fc
  • jasperleeflashcoffee
  • yesafc
  • vivinapriyanti
  • dorman-flash
  • peterandrew987
  • oki.aji
  • flashcoffeedev
  • robbyfc
  • sulfano.fikri
  • agustinuswd