omnipartners
Version:
Node.js wrapper for Omniparners API.
478 lines (477 loc) • 18.3 kB
JavaScript
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Api_1 = __importDefault(require("../../lib/Api"));
const apiDecorators_1 = require("../../lib/apiDecorators");
class Loyalty extends Api_1.default {
constructor() {
super(...arguments);
this.defaultHost = "https://rewards.clixray.io/points";
this.errorMap = {
99: { message: "Missing key." },
100: { message: "Missing action." },
101: { message: "Missing program ID." },
102: { message: "Point amount cannot be negative value" },
103: { message: "Inactive Key" },
1000: {
message: "Current user total points are insufficient to perform this points deduction action",
},
1001: {
message: "Error on performing user points data logging in deduction action",
},
1003: { message: "Database access error in Activity Process Action" },
1004: {
message: "Points Service Secret is not available for that key.",
},
1005: { message: "Points Service Secret key retrieve error" },
1006: {
message: "Unauthorized user access, input secret key might be invalid.",
},
1008: { message: "Error on performing product purchase action." },
1009: {
message: "Error on extended logic rule activity process action – Points offerer selection.",
},
1010: { message: "Error on performing extended logic rule activities" },
1011: { message: "Error on performing user points data logging" },
1012: {
message: "Error on performing instant discount deal - extended rule - Partner currency not set",
},
1014: {
message: "Error on performing instant discount deal - extended rule",
},
1023: { message: "Transaction history records not found" },
1024: { message: "Transaction history records retrieve error" },
1025: { message: "Invalid Key" },
1026: { message: "Key retrieve error" },
1027: { message: "Invalid Secret Key" },
1042: { message: "Resolve the Card Number - Invalid Request" },
1043: {
message: "Resolve the Card Number / Mobile Number - User not found",
},
1044: { message: "Associated user account is not active" },
1045: { message: "Resolve the Card Number - Card not found" },
1046: { message: "Resolve the Card Number - Card expired" },
1047: { message: "Resolve the Card Number - Card inactive" },
1049: { message: "Card-No / Mobile Number - User Record already exist" },
1051: { message: "Partner terminal map records not found" },
1053: {
message: "Shop Id (partner Id) not mapped with program OR Partner does not exist or not active.",
},
1054: { message: "Authentication key and action not mapped" },
1055: {
message: "ptn_ext_customer_id ( partner_ext_id ) record not found",
},
1056: { message: "Required fields are not found in service request" },
1058: { message: "Multiple programs exist for that user" },
1059: { message: "Internal error - Account Database access error" },
1060: { message: "Resolve the user - Invalid user_guid sent." },
1061: { message: "Invalid reason" },
1062: { message: "Card number does not belong to the partner / group" },
1063: { message: "Card number does not belong to any program." },
1064: { message: "Partner extension id records retrieve error" },
1065: { message: "Key /Action authorization records retrieve error" },
1066: {
message: "Partner associated user account is not available in the system",
},
1067: { message: "Key not found" },
1069: { message: "Shop associated programs resolution error" },
1070: { message: "program_id required" },
1071: { message: "Internal error - Program id resolution for the card" },
1072: { message: "User Guid not found for that partner ext id" },
1073: { message: "Internal error - Check product status" },
1075: { message: "This phone number is not a valid Mobile Phone number." },
1076: { message: "Internal error - Strict mobile phone validation error." },
1089: { message: "Invalid User E-Mail address." },
1091: { message: "Default program is not set in control center." },
1092: { message: 'Invalid "Transaction Value" sent in request.' },
1093: { message: 'Invalid "Transaction Points" sent in request.' },
1094: { message: "Invalid parameter values sent in request." },
2000: { message: "Internal error - no more cards available in the range." },
2001: { message: "Internal error - no virtual card range specified" },
2002: {
message: "Internal error - Card number you sent with partner/group card range restriction. So partner is required to specify in request.",
},
2003: {
message: "Invalid init_points parameter value sent in the request. It should be a number.",
},
2004: {
message: "Invalid init_stamps parameter value sent in the request. It should be a number.",
},
2005: { message: "Anonymous cards activation not allowed." },
3001: { message: "Internal error." },
};
}
retrieveBalance(data) {
return this._call("getpointbalance", data, {
hashKey: "sigid",
hashKeys: ["action", "program_id", "user_id"],
retry: true,
});
}
retrieveTransactionHistory(data) {
return this._call("transacnhistory", data, {
errorMap: {
1023: { message: "Transaction history records not found" },
1024: { message: "Transaction history records retrieve error" },
1067: { message: "Key not found" },
},
hashKeys: ["action", "program_id", "shop_id", "user_id"],
retry: true,
});
}
retrievePartnerTransactionHistory(data, options) {
return this._call("partner-transaction-history", data, {
errorMap: {
1023: { message: "Transaction history records not found" },
1024: { message: "Transaction history records retrieve error" },
1067: { message: "Key not found" },
},
retry: false,
...options,
hashKeys: undefined,
});
}
getPointsExpirationDate(data) {
return this._call("get-points-expiration-date", data, {
errorMap: {
1070: { message: "program_id required" },
},
hashKeys: [
"action",
"expiration_date",
"key",
"number_of_expirations",
"program_reference",
"user_id",
"user_id_type",
],
retry: true,
});
}
pointStampsAddition(data) {
return this._call("addition", data, {
errorMap: {
1070: { message: "program_id required" },
},
hashKey: "sigid",
hashKeys: ["source", "user_id", "action"],
retry: false,
});
}
pointStampsDeduction(data) {
return this._call("deduction", data, {
errorMap: {
1070: { message: "program_id required" },
},
hashKey: "sigid",
hashKeys: ["source", "user_id", "action"],
retry: false,
});
}
eshopPurchase(data) {
return this._call("shop-redemption", data, {
hashKey: "sigid",
hashKeys: ["source", "user_id", "action"],
retry: false,
});
}
_call(action, data, options = {}) {
return this.post("/", {
action,
...data,
}, {
hashKeys: ["action"],
...options,
});
}
transactionHistoryStats(data) {
return this._call("get-transaction-history-stats", data, {
errorMap: {
1023: { message: "Transaction history records not found" },
1043: { message: "User (GUID) not found" },
},
hashKey: "sigid",
hashKeys: ["action", "program_id", "shop_id", "user_id"],
});
}
partnerTransactionHistoryStats(data) {
return this._call("get-partner-transaction-history-stats", data, {
errorMap: {
1024: { message: "Transaction history records retrieve error" },
},
hashKeys: undefined,
});
}
activateCard(data) {
return this._call("activatecard", data, {
hashKey: "sigid",
hashKeys: ["mobile_no", "program_id", "card_no"],
});
}
getCardStatus(data) {
return this._call("get-card-status", data, {
hashKeys: ["program_id", "card_no"],
});
}
purchaseProduct(data) {
return this._call("purchase", data, {
hashKey: "sigid",
hashKeys: ["shop_id", "user_id", "action"],
});
}
purchase(data) {
return this._call("rewards-transaction", {
transaction_type: "purchase",
...data,
}, {
errorMap: {
4001: { message: "Access denied action" },
},
hashKeys: undefined,
});
}
listPurchases(data) {
return this._call("list-purchases", data, {
hashKeys: ["action", "program_id", "user_guid"],
});
}
resolveUserGuid(data) {
return this._call("resolveuserguid", data, {
hashKey: "sigid",
hashKeys: ["action", "program_id", "user_id"],
});
}
listGiftCatalog(data) {
return this._call("list-gift-catalog", data, {
hashKey: "sigid",
hashKeys: ["action", "program_id"],
});
}
}
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php/Retrieve_balance"),
(0, apiDecorators_1.filterInput)([
"program_id",
"card_program_id",
"auth_type",
"user_id", // (Required) : { message: "Service request sender needs to set user GUID information / Card Number / Mobile Number / partner_ext_id information here."},
])
], Loyalty.prototype, "retrieveBalance", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php/Retrieve_transaction_history"),
(0, apiDecorators_1.filterInput)([
"program_id",
"shop_id",
"partner_ext_id",
"user_id",
"starting_record",
"record_count",
"starting_date",
"ending_date",
"filter_null_transactions",
"sort",
])
], Loyalty.prototype, "retrieveTransactionHistory", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Retrieve_partner_transaction_history"),
(0, apiDecorators_1.filterInput)([
"program_id",
"partner_id",
"partner_id_type",
"user_guid",
"reason",
"lang",
"starting_record",
"record_count",
"start_date",
"end_date",
])
], Loyalty.prototype, "retrievePartnerTransactionHistory", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Get_Points_Expiration_Date"),
(0, apiDecorators_1.filterInput)([
"program_reference",
"user_id",
"user_id_type",
"number_of_expirations",
"expiration_date",
])
], Loyalty.prototype, "getPointsExpirationDate", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php/Point_/_Stamps_addition"),
(0, apiDecorators_1.filterInput)([
"program_id",
"shop_id",
"type",
"user_id",
"auth_type",
"message",
"reason",
"source",
"points",
"stamps",
"transaction_ext_id",
"transaction_ext_origin",
])
], Loyalty.prototype, "pointStampsAddition", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php/Point_deduction"),
(0, apiDecorators_1.filterInput)([
"program_id",
"shop_id",
"type",
"user_id",
"auth_type",
"message",
"source",
"points",
"reason",
"transaction_ext_id",
"transaction_ext_origin",
])
], Loyalty.prototype, "pointStampsDeduction", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Loyalty_eShop_purchase"),
(0, apiDecorators_1.filterInput)([
"program_id",
"shop_id",
"type",
"user_id",
"source",
"transaction_ext_id",
"transaction_ext_origin",
"supplier",
"product_id",
"send_voucher",
"points",
])
], Loyalty.prototype, "eshopPurchase", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php/Get_transaction_history_stats"),
(0, apiDecorators_1.filterInput)([
"program_id",
"shop_id",
"partner_ext_id",
"user_id",
"start_date",
"end_date",
"filter_null_transactions",
])
], Loyalty.prototype, "transactionHistoryStats", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Get_partner_transaction_history_stats"),
(0, apiDecorators_1.filterInput)([
"program_id",
"partner_id",
"partner_id_type",
"user_guid",
"group_by_user",
"start_date",
"end_date",
])
], Loyalty.prototype, "partnerTransactionHistoryStats", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Card_activation"),
(0, apiDecorators_1.filterInput)([
"source",
"program_id",
"card_no",
"mobile_no",
"user_email",
"user_guid",
"shop_id",
"type",
"user_language",
"transaction_ext_id",
"transaction_ext_origin",
"init_points",
"init_stamps", // (Optional)
])
], Loyalty.prototype, "activateCard", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Get_Card_Status"),
(0, apiDecorators_1.filterInput)([
"program_id",
"card_no",
"shop_id",
"type", // (Optional)
])
], Loyalty.prototype, "getCardStatus", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Product_purchase"),
(0, apiDecorators_1.filterInput)([
"program_id",
"user_id",
"shop_id",
"auth_type",
"type",
"product_codes",
"transaction_value",
"transaction_points",
"mobile_no",
"user_email",
"transaction_ext_id",
"transaction_ext_origin", // (Optional)
])
], Loyalty.prototype, "purchaseProduct", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Purchase"),
(0, apiDecorators_1.filterInput)([
"transaction_type",
"program_reference",
"user_id",
"user_id_type",
"partner_id",
"partner_id_type",
"product_codes",
"transaction_value",
"transaction_currency_code",
"transaction_points",
"user_mobile",
"user_email",
"transaction_ext_id",
"transaction_ext_origin",
"transaction_date",
"custom_logger_info", // (Optional) Custom values to add as logging values. Ex. {"tag_1":"custom_tag_1", "tag_2":"custom_tag_2"}
])
], Loyalty.prototype, "purchase", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=List_purchases"),
(0, apiDecorators_1.filterInput)([
"program_id",
"partner_ext_id",
"user_guid",
"starting_record",
"record_count",
"start_date",
"end_date",
"sort", // (Optional)This field contains array of string specifying the sort fields and direction.
])
], Loyalty.prototype, "listPurchases", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Resolve_User_GUID"),
(0, apiDecorators_1.filterInput)([
"program_id",
"card_program_id",
"user_id",
"auth_type", // (Required) It could be contain ‘card_no’ OR ‘mobile_no’ text value .
])
], Loyalty.prototype, "resolveUserGuid", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=List_Gift_Catalog"),
(0, apiDecorators_1.filterInput)([
"program_id",
"language",
"starting_record",
"record_count", // If request sender needs to filter the result, then he needs to specify max number of transactions here, then starting_record field value also need to be set.
])
], Loyalty.prototype, "listGiftCatalog", null);
exports.default = Loyalty;