feat: enhance Keepa API integration with additional query parameters and improve test coverage
This commit is contained in:
@@ -57,11 +57,13 @@ function buildProductUrl(
|
||||
options?: {
|
||||
includeStats?: boolean;
|
||||
includeBuybox?: boolean;
|
||||
includeHistory?: boolean;
|
||||
days?: number;
|
||||
},
|
||||
): string {
|
||||
const includeStats = options?.includeStats ?? true;
|
||||
const includeBuybox = options?.includeBuybox ?? true;
|
||||
const includeHistory = options?.includeHistory ?? true;
|
||||
const days = options?.days ?? 90;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
@@ -78,6 +80,10 @@ function buildProductUrl(
|
||||
params.set("buybox", "1");
|
||||
}
|
||||
|
||||
if (!includeHistory) {
|
||||
params.set("history", "0");
|
||||
}
|
||||
|
||||
params.set(queryParam, values.join(","));
|
||||
return `${KEEPA_BASE}/product?${params.toString()}`;
|
||||
}
|
||||
@@ -242,7 +248,8 @@ export async function fetchKeepaDataBatch(
|
||||
const chunk = canonicalAsins.slice(i, i + MAX_ASINS_PER_REQUEST);
|
||||
const url = buildProductUrl("asin", chunk, {
|
||||
includeStats: true,
|
||||
includeBuybox: true,
|
||||
includeBuybox: false,
|
||||
includeHistory: false,
|
||||
days: 90,
|
||||
});
|
||||
|
||||
@@ -302,6 +309,7 @@ export async function lookupKeepaUpcs(
|
||||
const url = buildProductUrl("code", chunk, {
|
||||
includeStats: false,
|
||||
includeBuybox: false,
|
||||
includeHistory: false,
|
||||
});
|
||||
|
||||
console.log(
|
||||
|
||||
Reference in New Issue
Block a user