omnipartners
Version:
Node.js wrapper for Omniparners API.
546 lines (545 loc) • 15.1 kB
TypeScript
import Api, { IApiFetchOptions } from "../../lib/Api";
import { ILoyaltyBalance, ILoyaltyPointDeduction, ILoyaltyPointsExpirationDate, ILoyaltyPointStampAddition, ILoyaltyTransactionHistory, ILoyaltyUserProfile } from "../../types";
import { IVoucherDetail } from "../deals";
export interface ILoyaltyRetrieveBalanceInput {
program_id: string;
card_program_id?: string;
auth_type?: "user_guid" | "card_no" | "mobile_no" | "partner_ext_id";
user_id: string;
}
export interface ILoyaltyRetrieveTransactionHistoryInput {
program_id: string;
shop_id?: string;
partner_ext_id?: string;
user_id: string;
starting_record?: string;
record_count?: string;
starting_date?: string;
ending_date?: string;
filter_null_transactions?: "1";
sort?: "transaction_date ASC" | "transaction_date DESC" | "transaction_id ASC" | "transaction_id DESC";
}
interface ILoyaltyRetrievePartnerTransactionHistoryInput {
program_id: string;
partner_id: string;
partner_id_type: "extid";
user_guid?: string;
reason?: string;
lang?: string;
starting_record?: string;
record_count?: string;
start_date?: string;
end_date?: string;
}
interface ILoyaltyRetrievePartnerTransactionHistoryResult {
data: {
transaction_id: string;
user_id: string;
action: string;
source_user_id: string;
total_points: string;
transaction_date: string;
program_id: string;
reason: string;
partner_ext_id: string;
reason_description: string;
total_points_alt: number;
transaction_message: Record<string, string>;
}[];
total_records: number;
selected_records: number;
status: string;
}
export interface ILoyaltyGetPointsExpirationDateInput {
program_reference: string;
user_id: string;
user_id_type?: "user_guid" | "user_loyalty_card_number" | "user_mobile" | "partner_ext_id";
number_of_expirations?: number;
expiration_date?: string;
}
export interface ILoyaltyPointStampAdditionInput {
program_id: string;
shop_id: string;
type?: "terminal" | "extid";
user_id: string;
auth_type?: "user_guid" | "card_no";
message?: string;
reason?: string;
source: string;
points?: number;
stamps?: number;
transaction_ext_id?: string;
transaction_ext_origin?: string;
}
export interface ILoyaltyPointDeductionInput {
program_id: string;
shop_id: string;
type?: "terminal" | "extid";
user_id: string;
auth_type?: "user_guid" | "card_no";
message?: string;
source: string;
points: number;
reason?: "redemption" | "expiration" | "adjustment";
transaction_ext_id?: string;
transaction_ext_origin?: string;
}
export interface ILoyaltyEshopPurchaseInput {
program_id: string;
shop_id: string;
type?: "terminal" | "extid";
user_id: string;
source: string;
transaction_ext_id?: string;
transaction_ext_origin?: string;
supplier?: string;
product_id?: string;
send_voucher?: "1";
points: number;
}
export interface ILoyaltyeEshopPurchase {
transactionpoints: number;
newtotalpoints: number;
message: string;
user_profile: ILoyaltyUserProfile;
}
export interface ILoyaltyRetrieveTransactionHistoryResult {
data: ILoyaltyTransactionHistory[];
total_records: number;
selected_records: number;
status: string;
}
export interface ILoyaltyTransactionHistoryStatsInput {
program_id: string;
shop_id?: string;
partner_ext_id?: string;
user_id: string;
start_date?: string;
end_date?: string;
filter_null_transactions?: "1";
}
interface ILoyaltyPartnerTransactionHistoryStatsInput {
program_id: string;
partner_id: string;
partner_id_type: string;
user_guid?: string;
group_by_user?: 1 | 0;
start_date?: string;
end_date?: string;
}
declare type ILoyaltyPartnerTransactionAction = "addition" | "deduction" | "shop-redemption";
declare type ILoyaltyPartnerTransactionActionStats = {
total_points_added: number;
total_points_deducted: number;
total_points_added_alt: number;
total_points_deducted_alt: number;
actions: {
[action in ILoyaltyPartnerTransactionAction]?: {
reason: string;
count: number;
total_points: number;
total_points_alt: number;
}[];
};
};
interface ILoyaltyPartnerTransactionHistoryStatsResult {
status: number;
data: {
global: ILoyaltyPartnerTransactionActionStats;
grouped_by_user?: (ILoyaltyPartnerTransactionActionStats & {
user_guid: string;
})[];
};
}
export interface ILoyaltyActivateCardInput {
source: string;
program_id?: string;
card_no?: string;
mobile_no?: string;
user_email?: string;
user_guid?: string;
shop_id?: string;
type?: "terminal" | "extid";
user_language?: string;
transaction_ext_id?: string;
transaction_ext_origin?: string;
init_points?: string;
init_stamps?: string;
}
export interface ILoyaltyGetCardStatusInput {
program_id: string;
card_no: string;
shop_id?: string;
type?: "terminal" | "extid";
}
export interface ILoyaltyActivateCardResult {
status: string;
user_guid: string;
message: string;
extended_rule_messages: string[];
transactionpoints: number;
newtotalpoints: string;
transactionstamps: number;
new_total_all_stamps: string;
new_total_partner_stamps: string;
card_number: string;
}
export interface ILoyaltyPurchaseProductInput {
source: string;
user_id: string;
program_id?: string;
user_guid?: string;
shop_id?: string;
type?: "terminal" | "extid";
auth_type?: "user_guid" | "card_no" | "mobile_no";
product_codes?: string;
transaction_value?: string;
transaction_points?: string;
mobile_no?: string;
user_email?: string;
transaction_ext_id?: string;
transaction_ext_origin?: string;
}
export interface ILoyaltyPurchaseInput {
user_id: string;
partner_id: string;
/** required if user_id_type !== user_loyalty_card_number */
program_reference?: string;
user_id_type?: "user_guid" | "user_loyalty_card_number" | "user_mobile" | "partner_ext_id";
partner_id_type?: "terminal" | "partner_ext_id";
product_codes?: string;
transaction_value?: string;
/** ex: EUR, GBP */
transaction_currency_code?: string;
transaction_points?: string;
user_mobile?: string;
user_email?: string;
transaction_ext_id?: string;
transaction_ext_origin?: string;
/** Format: YYYY-MM-DD */
transaction_date?: string;
custom_logger_info?: string;
}
export interface ILoyaltyListPurchasesInput {
program_id: string;
user_guid: string;
partner_ext_id?: string;
starting_record?: string;
record_count?: string;
start_date?: string;
end_date?: string;
sort?: string;
}
export interface ILoyaltyResolveUserGUIDInput {
/** don't specify program_id if auth_type === mobile_no */
program_id?: string;
card_program_id?: string;
user_id: string;
auth_type: string;
}
export interface ILoyaltyListGiftCatalogInput {
program_id: string;
language?: "NL" | "IT" | "FR" | "ES" | "EN" | "DE" | string;
starting_record?: string;
record_count?: number;
}
export default class Loyalty extends Api {
defaultHost: string;
errorMap: {
99: {
message: string;
};
100: {
message: string;
};
101: {
message: string;
};
102: {
message: string;
};
103: {
message: string;
};
1000: {
message: string;
};
1001: {
message: string;
};
1003: {
message: string;
};
1004: {
message: string;
};
1005: {
message: string;
};
1006: {
message: string;
};
1008: {
message: string;
};
1009: {
message: string;
};
1010: {
message: string;
};
1011: {
message: string;
};
1012: {
message: string;
};
1014: {
message: string;
};
1023: {
message: string;
};
1024: {
message: string;
};
1025: {
message: string;
};
1026: {
message: string;
};
1027: {
message: string;
};
1042: {
message: string;
};
1043: {
message: string;
};
1044: {
message: string;
};
1045: {
message: string;
};
1046: {
message: string;
};
1047: {
message: string;
};
1049: {
message: string;
};
1051: {
message: string;
};
1053: {
message: string;
};
1054: {
message: string;
};
1055: {
message: string;
};
1056: {
message: string;
};
1058: {
message: string;
};
1059: {
message: string;
};
1060: {
message: string;
};
1061: {
message: string;
};
1062: {
message: string;
};
1063: {
message: string;
};
1064: {
message: string;
};
1065: {
message: string;
};
1066: {
message: string;
};
1067: {
message: string;
};
1069: {
message: string;
};
1070: {
message: string;
};
1071: {
message: string;
};
1072: {
message: string;
};
1073: {
message: string;
};
1075: {
message: string;
};
1076: {
message: string;
};
1089: {
message: string;
};
1091: {
message: string;
};
1092: {
message: string;
};
1093: {
message: string;
};
1094: {
message: string;
};
2000: {
message: string;
};
2001: {
message: string;
};
2002: {
message: string;
};
2003: {
message: string;
};
2004: {
message: string;
};
2005: {
message: string;
};
3001: {
message: string;
};
};
retrieveBalance(data: ILoyaltyRetrieveBalanceInput): Promise<ILoyaltyBalance>;
retrieveTransactionHistory(data: ILoyaltyRetrieveTransactionHistoryInput): Promise<ILoyaltyRetrieveTransactionHistoryResult>;
retrievePartnerTransactionHistory(data: ILoyaltyRetrievePartnerTransactionHistoryInput, options?: Pick<IApiFetchOptions, "retry">): Promise<ILoyaltyRetrievePartnerTransactionHistoryResult>;
getPointsExpirationDate(data: ILoyaltyGetPointsExpirationDateInput): Promise<ILoyaltyPointsExpirationDate>;
pointStampsAddition(data: ILoyaltyPointStampAdditionInput): Promise<ILoyaltyPointStampAddition>;
pointStampsDeduction(data: ILoyaltyPointDeductionInput): Promise<ILoyaltyPointDeduction>;
eshopPurchase(data: ILoyaltyEshopPurchaseInput): Promise<ILoyaltyeEshopPurchase>;
private _call;
transactionHistoryStats(data: ILoyaltyTransactionHistoryStatsInput): Promise<{
status: number;
data: {
addition?: number;
deduction?: number;
"pet-sale"?: number;
activatecard?: number;
purchase?: number;
};
}>;
partnerTransactionHistoryStats(data: ILoyaltyPartnerTransactionHistoryStatsInput): Promise<ILoyaltyPartnerTransactionHistoryStatsResult>;
activateCard(data: ILoyaltyActivateCardInput): Promise<{
status: number;
}>;
getCardStatus(data: ILoyaltyGetCardStatusInput): Promise<{
status: number;
data: {
partner_extid: string;
activation_date: string;
member_status: string;
has_email: string;
has_mobile_phone: string;
};
}>;
purchaseProduct(data: ILoyaltyPurchaseProductInput): Promise<{
status: number;
}>;
purchase(data: ILoyaltyPurchaseInput): Promise<{
status: number;
log_id: number;
transaction_id: number;
ruleids: string[];
logicids: string[];
product_count: number;
transactionpoints: number;
transactionstamps: number;
newtotalpoints: string;
new_total_all_stamps: string;
new_total_partner_stamps: string;
simple_rules_new_points: number;
extended_rules_new_points: number;
instant_discount_point_deduction_execution: number;
product_codes_warning: string;
message: string;
extended_rule_messages: string[];
instant_discount_confirmation_message: string[];
saving_deals_status: string[];
saving_deals_received: string[];
vouchers: IVoucherDetail[];
deal_vouchers: IVoucherDetail[];
user_hold_points: number;
user_profile: {
user_status: string;
has_email: "Y" | "N";
has_mobile_phone: "Y" | "N";
user_email_status: string;
};
time: number;
user_guid: string;
}>;
listPurchases(data: ILoyaltyListPurchasesInput): Promise<{
data: {
transaction_id: string;
partner_ext_id: string;
partner_id: string;
program_id: string;
user_guid: string;
purchase_date: string;
}[];
total_records: number;
selected_records: number;
status: string;
}>;
resolveUserGuid(data: ILoyaltyResolveUserGUIDInput): Promise<{
user_guid: string;
user_profile: {
user_status: string;
has_email: string;
has_mobile_phone: string;
};
}>;
listGiftCatalog(data: ILoyaltyListGiftCatalogInput): Promise<{
data: {
becharge_product_id: string;
becharge_brand_id: string;
becharge_brand_name: string;
becharge_product_value: string;
becharge_product_currency: string;
becharge_brand_image: string;
becharge_product_image: string;
becharge_category: string;
becharge_product_value_in_points: number;
}[];
total_records: string;
status: "0" | string;
selected_records: number;
}>;
}
export {};