fix(amazon-shopping): verify prime and delivery filters
This commit is contained in:
@@ -31,6 +31,9 @@ Options:
|
||||
--min-reviews N Minimum review count
|
||||
--max-price N Maximum displayed product price
|
||||
--max-unit-price N Maximum price per unit
|
||||
--min-width N Minimum product width in inches
|
||||
--require-prime Require Prime delivery verification
|
||||
--delivery-by VALUE Require delivery timing, e.g. today, tomorrow, overnight
|
||||
--max-search-pages N Search result pages to scan, 1-5 (default: 2)
|
||||
--skip-details Do not open product detail pages
|
||||
--dry-run Parse and print the planned request without Amazon network access
|
||||
@@ -66,7 +69,7 @@ export function buildSearchUrl(query: string): string {
|
||||
|
||||
export function parseCliRequest(argv: string[]): SearchProductsRequest {
|
||||
const args = minimist(argv, {
|
||||
boolean: ["help", "json", "markdown", "allow-large-limit", "dry-run", "skip-details"],
|
||||
boolean: ["help", "json", "markdown", "allow-large-limit", "dry-run", "skip-details", "require-prime"],
|
||||
string: [
|
||||
"query",
|
||||
"limit",
|
||||
@@ -75,6 +78,9 @@ export function parseCliRequest(argv: string[]): SearchProductsRequest {
|
||||
"min-reviews",
|
||||
"max-price",
|
||||
"max-unit-price",
|
||||
"min-width",
|
||||
"delivery-by",
|
||||
"sort-by",
|
||||
"max-search-pages"
|
||||
],
|
||||
alias: { h: "help", max: "limit" }
|
||||
@@ -101,10 +107,24 @@ export function parseCliRequest(argv: string[]): SearchProductsRequest {
|
||||
const minReviews = parsePositiveInteger(args["min-reviews"], "min-reviews");
|
||||
const maxPrice = parseNumber(args["max-price"], "max-price");
|
||||
const maxUnitPrice = parseNumber(args["max-unit-price"], "max-unit-price");
|
||||
const minWidth = parseNumber(args["min-width"], "min-width");
|
||||
if (minRating !== undefined) filters.minRating = minRating;
|
||||
if (minReviews !== undefined) filters.minReviews = minReviews;
|
||||
if (maxPrice !== undefined) filters.maxPrice = maxPrice;
|
||||
if (maxUnitPrice !== undefined) filters.maxUnitPrice = maxUnitPrice;
|
||||
if (minWidth !== undefined) {
|
||||
filters.minWidthInches = minWidth;
|
||||
filters.widthComparison = "gte";
|
||||
}
|
||||
if (args["require-prime"]) filters.requirePrime = true;
|
||||
if (args["delivery-by"]) filters.deliveryBy = String(args["delivery-by"]);
|
||||
if (args["sort-by"]) {
|
||||
const sortBy = String(args["sort-by"]);
|
||||
if (sortBy !== "price" && sortBy !== "relevance") {
|
||||
throw new Error("sort-by must be either price or relevance");
|
||||
}
|
||||
filters.sortBy = sortBy;
|
||||
}
|
||||
|
||||
const json = Boolean(args.json);
|
||||
const markdown = Boolean(args.markdown);
|
||||
|
||||
Reference in New Issue
Block a user