UNPKG

migros-api-wrapper

Version:

Making the api of migros more accessible to the public.

44 lines 1.95 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getProductPromotionSearch = void 0; const StoreType_1 = require("../enums/StoreType"); const Region_1 = require("../enums/Region"); const requests_1 = require("../../utils/requests"); const apiPaths_1 = require("../apiPaths"); const deepmerge_1 = __importDefault(require("deepmerge")); const Language_1 = require("../enums/Language"); const SortFields_1 = require("../enums/SortFields"); const SortOrder_1 = require("../enums/SortOrder"); const url = apiPaths_1.migrosApiPaths["product-display"].public.web.v2 + "/products/promotion/search"; const defaultProductCardsOptions = { storeType: StoreType_1.StoreType.OFFLINE, period: "CURRENT", language: Language_1.Language.EN, filters: {}, sortFields: [SortFields_1.SortFields.CATEGORYLEVEL], sortOrder: SortOrder_1.SortOrder.ASC, from: 0, until: 100, region: Region_1.Region.NATIONAL, warehouse: "1", }; async function getProductPromotionSearchRequest(url, body, 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.postRequestBypass)(url, body, {}, necessaryHeaders); return await response.data; } async function getProductPromotionSearch(productPromotionSearchOptions, headers) { productPromotionSearchOptions = (0, deepmerge_1.default)(defaultProductCardsOptions, productPromotionSearchOptions); return getProductPromotionSearchRequest(url, productPromotionSearchOptions, headers); } exports.getProductPromotionSearch = getProductPromotionSearch; //# sourceMappingURL=product-promotion.js.map