shopee-client
Version:
Shoppe Open API Client
93 lines (92 loc) • 4 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var BaseModule_1 = __importDefault(require("../BaseModule"));
var hmac_1 = __importDefault(require("../../helper/hmac"));
var handleReject_1 = __importDefault(require("../../helper/handleReject"));
var PublicModule = /** @class */ (function (_super) {
__extends(PublicModule, _super);
function PublicModule() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Use this call to get basic info of shops which have authorized to the partner.
* @param partner_id Partner ID is assigned upon registration is successful. Required for all requests.
*/
PublicModule.prototype.getShopByPartner = function (partner_id) {
var full_url = this.client.defaults.baseURL + 'shop/get_partner_shop';
var params = {
partner_id: partner_id,
timestamp: Math.round(Date.now() / 1000),
};
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('shop/get_partner_shop', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
/**
* Use this call to get basic info of shops which have authorized to the partner.
* @param request
*/
PublicModule.prototype.getCategoryByCountry = function (request) {
var full_url = this.client.defaults.baseURL + 'item/categories/get_by_country';
var params = __assign(__assign({}, request), { timestamp: Math.round(Date.now() / 1000) });
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('item/categories/get_by_country', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
/**
* The supported payment method list by country
* @param partner_id Partner ID is assigned upon registration is successful. Required for all requests.
* @param country ID/MY/SG/VN/PH/TH/TW
*/
PublicModule.prototype.getPaymentList = function (partner_id, country) {
var full_url = this.client.defaults.baseURL + 'payment/list';
var params = {
partner_id: partner_id,
timestamp: Math.round(Date.now() / 1000),
};
if (country && typeof country == 'string') {
params.country = country;
}
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('payment/list', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
return PublicModule;
}(BaseModule_1.default));
exports.default = PublicModule;