shopee-client
Version:
Shoppe Open API Client
138 lines (136 loc) • 6.52 kB
JavaScript
"use strict";
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 CategoryModule = /** @class */ (function (_super) {
__extends(CategoryModule, _super);
function CategoryModule() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Use this call to get list of in-shop categories.
*/
CategoryModule.prototype.getCategory = function (request) {
var full_url = this.client.defaults.baseURL + 'shop_categorys/get';
var params = __assign({ partner_id: Number(this.config.partner_id), shopid: Number(this.config.shop_id), timestamp: Math.round(Date.now() / 1000) }, request);
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('shop_categorys/get', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
/**
* Use this call to add a new collecion
*/
CategoryModule.prototype.addCategory = function (request) {
var full_url = this.client.defaults.baseURL + 'shop_category/add';
var params = __assign({ partner_id: Number(this.config.partner_id), shopid: Number(this.config.shop_id), timestamp: Math.round(Date.now() / 1000) }, request);
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('shop_category/add', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
/**
* Use this call to delete a existing collecion
* @param request
*/
CategoryModule.prototype.deleteCategory = function (request) {
var full_url = this.client.defaults.baseURL + 'shop_category/delete';
var params = __assign({ partner_id: Number(this.config.partner_id), shopid: Number(this.config.shop_id), timestamp: Math.round(Date.now() / 1000) }, request);
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('shop_category/delete', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
/**
* Use this call to update a existing collecion
* @param request
*/
CategoryModule.prototype.updateCategory = function (request) {
var full_url = this.client.defaults.baseURL + 'shop_category/update';
var params = __assign({ partner_id: Number(this.config.partner_id), shopid: Number(this.config.shop_id), timestamp: Math.round(Date.now() / 1000) }, request);
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('shop_category/update', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
/**
* Use this call to add items list to certain shop_category
* @param request
*/
CategoryModule.prototype.addItems = function (request) {
var full_url = this.client.defaults.baseURL + 'shop_category/add/items';
var params = __assign({ partner_id: Number(this.config.partner_id), shopid: Number(this.config.shop_id), timestamp: Math.round(Date.now() / 1000) }, request);
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('shop_category/add/items', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
/**
* Use this call to get items list of certain shop_category
* @param request
*/
CategoryModule.prototype.getItems = function (request) {
var full_url = this.client.defaults.baseURL + 'shop_category/get/items';
var params = __assign({ partner_id: Number(this.config.partner_id), shopid: Number(this.config.shop_id), timestamp: Math.round(Date.now() / 1000) }, request);
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('shop_category/get/items', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
/**
* Use this call to get items list of certain shop_category
* @param request
*/
CategoryModule.prototype.deleteItems = function (request) {
var full_url = this.client.defaults.baseURL + 'shop_category/del/items';
var params = __assign({ partner_id: Number(this.config.partner_id), shopid: Number(this.config.shop_id), timestamp: Math.round(Date.now() / 1000) }, request);
var hmac = hmac_1.default(this.config.partner_key || '', full_url + '|' + JSON.stringify(params));
return this.client.post('shop_category/del/items', params, {
headers: {
Authorization: hmac
}
}).then(handleReject_1.default);
};
return CategoryModule;
}(BaseModule_1.default));
exports.default = CategoryModule;