migros-api-wrapper
Version:
Making the api of migros more accessible to the public.
42 lines • 1.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.categoryList = void 0;
const Region_1 = require("../enums/Region");
const Language_1 = require("../enums/Language");
const Algorithm_1 = require("../enums/Algorithm");
const SortOrder_1 = require("../enums/SortOrder");
const requests_1 = require("../../utils/requests");
const apiPaths_1 = require("../apiPaths");
const url = apiPaths_1.migrosApiPaths["onesearch-oc-seapi"].public.v3 + "/search/category";
const defaultCategoryListOptions = {};
const defaultCategoryListBody = {
algorithm: Algorithm_1.Algorithm.DEFAULT,
regionId: Region_1.Region.NATIONAL,
language: Language_1.Language.EN,
productIds: [],
sortFields: [],
sortOrder: SortOrder_1.SortOrder.ASC,
requestSponsoredProducts: false,
from: 0,
categoryId: 0,
};
async function postCategoryListRequest(url, body, options, headers) {
const necessaryHeaders = {
accept: "application/json, text/plain, *!/!*",
// eslint-disable-next-line @typescript-eslint/naming-convention
"content-type": "application/json",
...headers,
};
const response = await (0, requests_1.postRequest)(url, body, options, necessaryHeaders);
return await response.json();
}
async function categoryList(categoryListBody, headers, categoryListOptions) {
categoryListOptions = {
...defaultCategoryListOptions,
...categoryListOptions,
};
categoryListBody = { ...defaultCategoryListBody, ...categoryListBody };
return postCategoryListRequest(url, categoryListBody, categoryListOptions, headers);
}
exports.categoryList = categoryList;
//# sourceMappingURL=category.js.map