type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Create Or Update Organization
* Creates an organization if it doesn't already exist, or updates
an existing organization. Using this method means one less call
to check if an organization exists before creating it. You need
to specify the id or external id when updating
an organization to avoid a duplicate error response. Name is
not available as a matching criteria.
#### Allowed For
* Agents, with restrictions on certain actions
*/
export async function main(auth: Zendesk) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/organizations/create_or_update`
);
const response = await fetch(url, {
method: "POST",
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;
};
/**
* Create Or Update Organization
* Creates an organization if it doesn't already exist, or updates
an existing organization. Using this method means one less call
to check if an organization exists before creating it. You need
to specify the id or external id when updating
an organization to avoid a duplicate error response. Name is
not available as a matching criteria.
#### Allowed For
* Agents, with restrictions on certain actions
*/
export async function main(auth: Zendesk) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/organizations/create_or_update`
);
const response = await fetch(url, {
method: "POST",
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