//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* Replace Advanced Sync Schedule for Warehouse
* Updates the advanced sync schedule for a Warehouse, replacing the sync schedule with a new schedule.
The rate limit for this endpoint is 2 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.
*/
export async function main(
auth: Segment,
warehouseId: string,
body: {
enabled: false | true;
schedule?: {
times: { hourOfDay: number; enabled: false | true }[];
timezone: string;
};
},
) {
const url = new URL(
`${auth.baseUrl}/warehouses/${warehouseId}/advanced-sync-schedule`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + 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 235 days ago