type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Incremental Sample Export
* Use this endpoint to test the incremental export format. It's more strict in terms of rate limiting,
at 10 requests per 20 minutes instead of 10 requests per minute. It also returns only up to 50
results per request. Otherwise, it's identical to the above APIs.
Use the `incremental_resource` parameter to specify the resource. Possible values are "tickets", "ticket_events", "users", or "organizations".
*/
export async function main(
auth: Zendesk,
incremental_resource: string,
start_time: string | undefined
) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/incremental/${incremental_resource}/sample`
);
for (const [k, v] of [["start_time", start_time]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 377 days ago
type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Incremental Sample Export
* Use this endpoint to test the incremental export format. It's more strict in terms of rate limiting,
at 10 requests per 20 minutes instead of 10 requests per minute. It also returns only up to 50
results per request. Otherwise, it's identical to the above APIs.
Use the `incremental_resource` parameter to specify the resource. Possible values are "tickets", "ticket_events", "users", or "organizations".
*/
export async function main(
auth: Zendesk,
incremental_resource: string,
start_time: string | undefined
) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/incremental/${incremental_resource}/sample`
);
for (const [k, v] of [["start_time", start_time]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 923 days ago