1.2.50 • Published 3 years ago

@flashcoffee/fctalonone v1.2.50

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
3 years ago

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;
  }
}
1.2.55-alpha.7

3 years ago

1.2.55-alpha.3

3 years ago

1.2.50

3 years ago

1.2.50-alpha.5

3 years ago

1.2.50-alpha.4

3 years ago

1.2.50-alpha.3

3 years ago

1.2.50-alpha.2

3 years ago

1.2.50-alpha.1

3 years ago

1.2.50-alpha.0

3 years ago