type Shopify = {
token: string;
store_name: string;
};
/**
* Connects an inventory item to a location
* Connects an inventory item to a location by creating an inventory level at that location. When connecting inventory items to locations, it's important to understand the rules around fulfillment service locations.
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
body: {
inventory_item_id?: number;
location_id?: number;
[k: string]: unknown;
}
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/inventory_levels/connect.json`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Access-Token": auth.token,
},
body: JSON.stringify(body),
});
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;
};
/**
* Connects an inventory item to a location
* Connects an inventory item to a location by creating an inventory level at that location. When connecting inventory items to locations, it's important to understand the rules around fulfillment service locations.
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
body: {
inventory_item_id?: number;
location_id?: number;
[k: string]: unknown;
}
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/inventory_levels/connect.json`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Access-Token": auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 942 days ago