UNPKG

migros-api-wrapper

Version:

Making the api of migros more accessible to the public.

42 lines 1.77 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getProductCards = 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 url = apiPaths_1.migrosApiPaths["product-display"].public.v4 + "/product-cards"; const defaultProductCardsOptions = { productFilter: { uids: [], }, offerFilter: { storeType: StoreType_1.StoreType.OFFLINE, region: Region_1.Region.NATIONAL, }, }; async function getProductCardsRequest(url, body, headers) { var _a; if (body.offerFilter && !((_a = body.offerFilter) === null || _a === void 0 ? void 0 : _a.ongoingOfferDate)) { body.offerFilter.ongoingOfferDate = new Date().toISOString().split("T")[0] + "T00:00:00"; } 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 getProductCards(productCardOptions, headers) { productCardOptions = (0, deepmerge_1.default)(defaultProductCardsOptions, productCardOptions); return getProductCardsRequest(url, productCardOptions, headers); } exports.getProductCards = getProductCards; //# sourceMappingURL=product-cards.js.map