type Shopify = {
token: string;
store_name: string;
};
/**
* Retrieves a count of fulfillments associated with a specific order
* Retrieves a count of fulfillments associated with a specific order
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
order_id: string,
created_at_min: string | undefined,
created_at_max: string | undefined,
updated_at_min: string | undefined,
updated_at_max: string | undefined
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/orders/${order_id}/fulfillments/count.json`
);
for (const [k, v] of [
["created_at_min", created_at_min],
["created_at_max", created_at_max],
["updated_at_min", updated_at_min],
["updated_at_max", updated_at_max],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"X-Shopify-Access-Token": auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 396 days ago
type Shopify = {
token: string;
store_name: string;
};
/**
* Retrieves a count of fulfillments associated with a specific order
* Retrieves a count of fulfillments associated with a specific order
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
order_id: string,
created_at_min: string | undefined,
created_at_max: string | undefined,
updated_at_min: string | undefined,
updated_at_max: string | undefined
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/orders/${order_id}/fulfillments/count.json`
);
for (const [k, v] of [
["created_at_min", created_at_min],
["created_at_max", created_at_max],
["updated_at_min", updated_at_min],
["updated_at_max", updated_at_max],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"X-Shopify-Access-Token": auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 942 days ago