omnipartners
Version:
Node.js wrapper for Omniparners API.
706 lines (705 loc) • 28.8 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 Deals extends Api_1.default {
constructor() {
super(...arguments);
this.defaultHost = "https://deals.clixray.io/";
this.errorMap = {
1005: { message: "Database connection or SQL error." },
1006: {
message: "Unauthorized user access, input authenticate key might be invalid.",
},
1008: { message: "Deals Service Key not sent." },
1009: { message: "Deals Service Hash not sent." },
1010: { message: "Deals Service action not sent." },
1024: { message: "Invalid Hash text sent with request." },
2001: { message: "Redeem period expired." },
2002: { message: "Deal is not active at the moment." },
2003: { message: "Coupon is already redeemed." },
2006: { message: "Invalid partner" },
2008: {
message: "The voucher already redeemed or canceled by the CC admin.",
},
2021: { message: "User GUID is not found in database." },
3020: { message: "Parameter user_guid not available in the request." },
3022: { message: "Subscription status code is not set in request." },
3023: { message: "Subscription status code is not valid text." },
3026: { message: "The ref parameter not available in the request" },
3031: { message: "Subscription cannot be found." },
3033: {
message: "When the post body empty or content not valid JSON obejct",
},
3035: { message: "invalid deal reference." },
3044: {
message: "Partner can't resolve by the supplied external-customer-id",
},
3059: { message: "Parameter partner_extid not available in the request." },
3051: { message: "Parameter ean_code not available in the request" },
3034: { message: "Invalid EAN code" },
1019: { message: "Can't resolve partner." },
3055: { message: "Subscription fail due to error in barcode generation." },
3027: { message: "Can't resolve user." },
3028: { message: "Inactive deal" },
3029: { message: "Deal already expired." },
3045: { message: "Can't find a record for given data" },
3049: { message: "Stock not available." },
3030: { message: "User not in the allowed segment." },
3056: { message: "User not have a pet with a restricted pet type." },
3052: { message: "User not have a pet with a restricted pet breed." },
3053: {
message: "If pet is required for the deal and user not have a pet.",
},
3054: { message: "User subscription limit reach." },
3057: { message: "Deal is not allowed for the supplied product." },
3058: { message: "The deal is not allowed for the supplied partner." },
3060: { message: "'code' is not available in the request parameters" },
3061: { message: "Secure code already used" },
3063: { message: "Secure code parameter not available in the request" },
3064: { message: "Invalid secure code" },
3069: { message: "Invalid pet guid" },
3086: { message: "Invalid IBAN" },
3087: { message: "Invalid BIC" },
3088: {
message: "The minimum number of loyalty points required to subscribe is not reached.",
},
3091: {
message: "The deal is denied for the user since user is inactive.",
},
3092: {
message: "Use Send invitation Link to send invitation since user is inactive.",
},
3093: { message: "Saving date of the deal has expired." },
3097: {
message: "Not enough points for pay off the deal subscription point redemption",
},
3098: { message: "User doesn't have a pet in allowed age limit." },
3108: { message: "Referral code parameter not available in the request." },
3109: { message: "Invalid Referral code parameter." },
3110: { message: "Referral code is not allowed." },
3111: {
message: "Delivery address ID parameter is not available in the request.",
},
3112: { message: "Doesn't have any address associated with the user." },
3113: { message: "Invalid delivery address ID." },
3144: { message: "Subscription failure due to secure code expiry." },
5000: { message: "Internal Error." },
1023: { message: "Input barcode is not set." },
1025: { message: "Input barcode is not valid." },
1027: { message: "Maximum redemption request limit reached." },
1029: {
message: "Benefit Id not set. / Invalid Benefit type define in the deal",
},
1030: {
message: "Already redeemed voucher subscription or its in progress.",
},
1032: { message: "Benefit Id not found." },
1035: { message: "Receipt Storage location not configured." },
1036: { message: "Target currency not set." },
1037: { message: "Invalid Payment details sent. (eg: Invalid IBAN)" },
1038: { message: "Invalid currency code." },
1039: { message: "Invalid payment detail parameters sent." },
1040: { message: "Invalid customer details." },
1042: { message: "Voucher cannot redeem." },
1047: { message: "Issue in refund service connection." },
1046: { message: "Already paid IBAN is used." },
1048: {
message: "Maximum number of payment count for the selected IBAN reached.",
},
1049: {
message: "Maximum date for submitting the redemption request exceed.",
},
1050: { message: "Reward purchase transaction id not sent." },
1051: { message: "Reward purchase transaction id not found." },
1052: {
message: "Invalid purchase amount get from reward purchase transaction.",
},
1053: { message: "Reward purchase transaction id already used." },
3025: { message: "Subscription was expired, so cannot redeem it." },
3050: { message: "Invalid subscription." },
3062: { message: "Missing required parameter." },
3124: { message: "Invalid benefit amount." },
3048: { message: "Already redeemed coupon." },
3094: { message: "Invalid receipt date." },
3096: { message: "Invalid image mime type." },
3115: { message: "Subscription failure due to user status." },
3119: { message: "Fail due to pet inclusion/exclusion restrictions" },
3118: { message: "Parameter 'pet_guid' not available in the request" },
3120: { message: "Fail due to pet stage inclusion/exclusion restrictions" },
3121: {
message: "Fail due to purchase place inclusion/exclusion restrictions",
},
3122: {
message: "Fail due to concurrent subscription is not allowed for the deal",
},
3127: { message: "User doesn't have a pet in allowed date pool limit." },
3128: { message: "User doesn't have a pet in allowed neutered state." },
3131: {
message: "Required parameter 'child_guid' not available in the request",
},
3132: { message: "Invalid 'child_guid'." },
3133: { message: "Subscription failure due to child gender." },
3134: { message: "Subscription failure due to child age." },
3135: { message: "Subscription failure due to child count." },
3116: {
message: "Subscription failure due to invalid external tracking reference format.",
},
3123: {
message: "Invalid Referral code type. Valid values are 'referral_code' or 'ext_id'",
},
};
}
getDealsList(data) {
return this._call("list-deals", data, {
retry: true,
});
}
getDeal({ data_options, ...data }) {
return this._call("get-deal-details", {
...data,
data_options: data_options
? Array.isArray(data_options)
? data_options.join(",")
: data_options
: undefined,
}, {
hashKeys: ["ref"],
retry: true,
});
}
getRegisteredPartners({ data_options, ...data }) {
return this._call("get-registered-partners", {
...data,
data_options: data_options
? Array.isArray(data_options)
? data_options.join(",")
: data_options
: undefined,
}, {
hashKeys: ["deal_ref"],
retry: true,
});
}
getVisiblePartner(data) {
return this._call("get-visible-partners-for-user", data, {
hashKeys: ["deal_ref"],
retry: true,
});
}
checkPartnerValidity(data) {
return this._call("check-partner-validity", data, {
hashKeys: ["deal_ref"],
retry: true,
});
}
checkDealValidity(data) {
return this._call("check-deal-validity", data, {
hashKeys: ["deal_ref", "user_guid"],
retry: true,
});
}
subscribeToDeal(data) {
return this._call("deal-subscribe", data, {
hashKeys: ["ref"],
retry: true,
});
}
listVouchers(data) {
return this._call("listoffers", data, {
retry: true,
});
}
redeemVoucher(data) {
return this._call("redemption", data, {
hashKeys: [
data.barcode ? "barcode" : data.secure_code ? "secure_code" : "",
],
retry: true,
});
}
getVoucherDetail(data) {
return this._call("get-subscription-details", data, {
retry: true,
hashKeys: ["barcode", "coupon_id"],
});
}
listEligiblePets(data) {
return this._call("list-eligible-pets", data, {
hashKeys: undefined,
retry: true,
});
}
getProductList(data) {
return this._call("get-product-list", data, {
hashKeys: ["deal_ref"],
retry: true,
});
}
checkSecureCode({ data_options, ...data }) {
return this._call("check-secure-code", {
...data,
data_options: data_options
? Array.isArray(data_options)
? data_options.join(",")
: data_options
: undefined,
}, {
hashKeys: ["deal_ref", "code"],
retry: true,
});
}
getSecureCode(data) {
return this._call("generate-secure-code", data, {
hashKeys: ["deal_ref"],
retry: true,
});
}
updateSecureCodeProperties(data) {
return this._call("update-access-code-properties", data, {
hashKeys: undefined,
retry: true,
errorMap: {
1019: { message: "Referral partner ext id not exist." },
3062: { message: "At least one parameter must provide to update." },
3063: { message: "Access code does not exist." },
3129: {
message: "Invalid status provided. Valid values are 'AVAILABLE' and 'PUBLISHED'.",
},
3130: { message: "Error on updating the record." },
},
});
}
listEligibleDirectCashbackDeals(data) {
return this._call("list-direct-cashback-eligible-deals", data, {
retry: true,
hashKeys: undefined,
});
}
listDirectCashbackEligiblePets(data) {
return this._call("list-direct-cashback-eligible-pets", data, {
retry: true,
hashKeys: undefined,
});
}
getDirectCashbackDealDetail(data) {
return this._call("get-direct-cashback-deal-details", {
...data,
data_options: data.data_options
? Array.isArray(data.data_options)
? data.data_options.join(",")
: data.data_options
: undefined,
}, {
retry: true,
hashKeys: undefined,
});
}
getDirectCashbackVoucherList(data) {
return this._call("get-direct-cashback-voucher-list", data, {
retry: true,
hashKeys: undefined,
});
}
getDirectCashbackVoucherDetail({ deal_data_options, ...data }) {
return this._call("get-direct-cashback-voucher-details", {
...data,
deal_data_options: deal_data_options
? Array.isArray(deal_data_options)
? deal_data_options.join(",")
: deal_data_options
: undefined,
}, {
retry: true,
hashKeys: undefined,
});
}
getDirectCashbackDealBenefit(data) {
return this._call("find-benefit", data, {
retry: true,
hashKeys: undefined,
});
}
subscribeToDirectCashbackDeal(data) {
return this._call("direct-cashback-subscribe", data, {
retry: true,
hashKeys: undefined,
});
}
createDirectCashbackRedemptionRequest(data) {
return this._call("create-direct-cashback-redemption-request", data, {
retry: true,
hashKeys: (d) => [
"key",
...Object.keys(d).filter((k) => k !== "payment_details"),
].sort(),
});
}
createDirectCashbackRedemption(data) {
return this._call("create-direct-cashback-redemption", data, {
hashKeys: (d) => [
"key",
...Object.keys(d).filter((k) => k !== "payment_details"),
].sort(),
});
}
getDirectCashbackRedemptionRequestList(data) {
return this._call("get-user-direct-cashback-redemption-request-list", data, {
retry: true,
hashKeys: undefined,
});
}
getDirectCashbackRedemptionRequestDetail(data) {
return this._call("get-user-direct-cashback-redemption-request", data, {
retry: true,
hashKeys: undefined,
});
}
getDirectCashbackVoucherApprovalHistory(data) {
return this._call("get-direct-cashback-voucher-approval-history", data, {
retry: true,
hashKeys: undefined,
});
}
getVoucherPDF(data) {
return this._call("get-voucher-pdf-location", data, {
retry: true,
hashKeys: ["barcode"],
});
}
disableVoucherRedemption(data) {
return this._call("disable-voucher-redemption", data, {
retry: false,
hashKeys: undefined,
});
}
sendVoucher(data) {
return this._call("sendvoucher", data, {
retry: false,
hashKeys: ["barcode"],
});
}
redeemWithReceipt(data) {
return this._call("redeem-with-receipt", data, {
retry: false,
hashKeys: ["barcode"],
});
}
_call(action, data, options = {}) {
return this.post("/", {
action,
...data,
}, {
hashKeys: ["action"],
...options,
});
}
}
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Get_deals_list"),
(0, apiDecorators_1.filterInput)([
"partner_extid",
"saving_product_ean",
"saving_collection_reference",
"benefit_product_ean",
"benefit_collection_reference",
"pet_search_by",
"pet_search_val",
"deal_type",
"display_on_terminal",
"deal_visibility",
"active_only",
"deal_group_handle",
"excl_deal_group_handle",
])
], Deals.prototype, "getDealsList", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_deals_details"),
(0, apiDecorators_1.filterInput)([
"ref",
"default_lang",
"data_options", // This defines information that is returned in the deal details object. Multiple values should be comma separated. For more information please refer Deal Data Options.
])
], Deals.prototype, "getDeal", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Get_registered_partners"),
(0, apiDecorators_1.filterInput)([
"deal_ref",
"search_term",
"p_length",
"p_page",
"partner_lat",
"partner_lng",
"radius",
"partner_type",
"partner_group",
"partner_mode",
"partner_status",
"data_options", // (Optional) This defines the partner information that is returned in the result. For more information please refer Deal Partner Data Options.
])
], Deals.prototype, "getRegisteredPartners", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_visible_partners"),
(0, apiDecorators_1.filterInput)([
"deal_ref",
"user_guid",
"search",
"favorite_only",
"partner_lat",
"partner_lng",
"radius",
"p_page",
"p_length",
"limit",
])
], Deals.prototype, "getVisiblePartner", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Check_partner_validity"),
(0, apiDecorators_1.filterInput)([
"deal_ref",
"partner_extid", // (Required) Partner extid that need to check the validity for give deal
])
], Deals.prototype, "checkPartnerValidity", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Check_deal_validity"),
(0, apiDecorators_1.filterInput)(["user_guid", "pet_guid", "child_guid", "deal_ref"])
], Deals.prototype, "checkDealValidity", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Subscribe_to_a_deal"),
(0, apiDecorators_1.filterInput)([
"user_guid",
"ref",
"partner_extid",
"ean_code",
"collection_ref",
"secure_code",
"pet_guid",
"child_guid",
"external_tracking_ref",
"iban",
"bic",
"referral_code",
"referral_code_type",
"delivery_address_id",
"lang",
"utm_source",
"utm_campaign",
"utm_medium", // (Optional), UTM medium for the subscription
])
], Deals.prototype, "subscribeToDeal", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/List_vouchers"),
(0, apiDecorators_1.filterInput)([
"user_guid",
"pet_guid",
"child_guid",
"show",
"from",
"to",
"redeemed_from",
"redeemed_to",
"barcode",
"external_tracking_ref",
"partner_extid",
"deal_ref",
"deal_types",
"redemption_request_status",
"deal_data_options",
"data_options",
"coupon_id",
"status",
"inv_resend_count",
"sort_field",
"sort_order",
"q",
"p_length",
"p_page",
"default_lang",
])
], Deals.prototype, "listVouchers", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Redeem_voucher"),
(0, apiDecorators_1.filterInput)([
"shop_id",
"type",
"referral_code",
"referral_code_type",
"barcode",
// REDEMPTION WITH ACCOUNT AND WITHOUT SUBSCRIPTION
"ref",
"secure_code",
"ean_code",
"external_tracking_ref",
"bic",
"delivery_address_id",
"iban",
"user_guid",
"pet_guid",
"child_guid", // (Optional) GUID of a child. User GUID will be retrieved from this if user_guid is not provided. This is required if the deal restricted for child limitations. Otherwise it can be empty.
])
], Deals.prototype, "redeemVoucher", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_deals_subscription_details"),
(0, apiDecorators_1.filterInput)([
"barcode",
"coupon_id",
"deal_data_options",
"data_options", // (Optional) This defines information that is returned in the deal subscription details node. For more information please refer Deal Subscription Data Options.
])
], Deals.prototype, "getVoucherDetail", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/List_Eligible_Pets"),
(0, apiDecorators_1.filterInput)(["deal_ref", "user_guid"])
], Deals.prototype, "listEligiblePets", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_product_list"),
(0, apiDecorators_1.filterInput)(["deal_ref"])
], Deals.prototype, "getProductList", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Check_secure_code"),
(0, apiDecorators_1.filterInput)(["deal_ref", "code", "data_options"])
], Deals.prototype, "checkSecureCode", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/New_secure_code"),
(0, apiDecorators_1.filterInput)(["deal_ref"])
], Deals.prototype, "getSecureCode", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Update_secure_code_properties"),
(0, apiDecorators_1.filterInput)([
"access_code",
"status",
"referral_partner_ext_id",
"expiry_date",
"deal_ref", // (optional) New deal reference for the access code. This will update the deal of the access code only if the code status is 'AVAILABLE'
])
], Deals.prototype, "updateSecureCodeProperties", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_List_of_eligible_Direct_Cashback_Deals"),
(0, apiDecorators_1.filterInput)(["user_guid", "pet_guid", "child_guid"])
], Deals.prototype, "listEligibleDirectCashbackDeals", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/List_Direct_Cashback_Eligible_Pets"),
(0, apiDecorators_1.filterInput)(["user_guid", "deal_ref"])
], Deals.prototype, "listDirectCashbackEligiblePets", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_direct_cashback_deal_details"),
(0, apiDecorators_1.filterInput)([
"ref",
"default_lang",
"data_options", // (Optional) This defines information that is returned in the deal details object. Multiple values should be comma separated. For more information please refer Direct Cashback Deal Data Options.
])
], Deals.prototype, "getDirectCashbackDealDetail", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_direct_cashback_voucher_list"),
(0, apiDecorators_1.filterInput)([
"user_guid",
"pet_guid",
"child_guid",
"from",
"to",
"deal_ref",
"p_length",
"p_page", // (Required) current page. start at 0
])
], Deals.prototype, "getDirectCashbackVoucherList", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_direct_cashback_voucher_details"),
(0, apiDecorators_1.filterInput)(["barcode", "deal_data_options"])
], Deals.prototype, "getDirectCashbackVoucherDetail", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Find_Benefit"),
(0, apiDecorators_1.filterInput)([
"deal_ref",
"product_ean", // (Required) EAN of the product
])
], Deals.prototype, "getDirectCashbackDealBenefit", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Subscribe_to_a_Direct_Cashback_Deal"),
(0, apiDecorators_1.filterInput)([
"user_guid",
"deal_ref",
"pet_guid",
"child_guid", // A Child guid of the user. This is required if the deal restricted for child limitations. Otherwise it can be empty.
])
], Deals.prototype, "subscribeToDirectCashbackDeal", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Create_direct_cashback_redemption_request"),
(0, apiDecorators_1.filterInput)([
"barcode",
"benefit_id",
"receipt_date",
"receipt_image_mime_type",
"target_currency",
"payment_details",
"benefit_product_ean",
"benefit_product_purchase_value",
"tier_purchase_receipt_image_mime_type", // Mime type of the non product purchased receipt image to verify the purchase. This is required if the purchase is non product based.
])
], Deals.prototype, "createDirectCashbackRedemptionRequest", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Create_direct_cashback_redemption"),
(0, apiDecorators_1.filterInput)([
"barcode",
"transaction_id",
"payment_details", // (Required) Details of the payment, It should be a json object.
])
], Deals.prototype, "createDirectCashbackRedemption", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_user_direct_cashback_redemption_request_list"),
(0, apiDecorators_1.filterInput)([
"user_guid",
"status",
"barcode",
"sort_field",
"sort_order",
"p_length",
"p_page", // (optional) Current page. start at 0
])
], Deals.prototype, "getDirectCashbackRedemptionRequestList", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_user_direct_cashback_redemption_request"),
(0, apiDecorators_1.filterInput)([
"receipt_id", // (optional) Id of the purchase receipt. (see http://doc.omnipartners.be/index.php/Get_user_direct_cashback_purchase_receipt_list).
])
], Deals.prototype, "getDirectCashbackRedemptionRequestDetail", null);
__decorate([
(0, apiDecorators_1.doc)("http://doc.omnipartners.be/index.php/Get_direct_cashback_voucher_approval_history"),
(0, apiDecorators_1.filterInput)([
"barcode",
"lang",
"sort_field",
"sort_order", // (optional) Sort order. possible values are DESC,ASC
])
], Deals.prototype, "getDirectCashbackVoucherApprovalHistory", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php/Get_Voucher_PDF"),
(0, apiDecorators_1.filterInput)(["barcode"])
], Deals.prototype, "getVoucherPDF", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Disable_voucher_redemption"),
(0, apiDecorators_1.filterInput)(["barcode"])
], Deals.prototype, "disableVoucherRedemption", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Send_voucher_email"),
(0, apiDecorators_1.filterInput)(["barcode", "email", "default_lang"])
], Deals.prototype, "sendVoucher", null);
__decorate([
(0, apiDecorators_1.doc)("https://doc.clixray.com/index.php?title=Redeem_with_Receipt"),
(0, apiDecorators_1.filterInput)([
"barcode",
"receipt_date",
"mime_type",
"product_ean_code",
"redemption_partner_extid",
])
], Deals.prototype, "redeemWithReceipt", null);
exports.default = Deals;