type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Get sources by target
* Returns a list of source objects whose values are populated with the id of a related target object. For example,
if you have a lookup field called "Success Manager" on a ticket, this endpoint can answer the question,
"What tickets (sources) is this user (found by `target_type` and `target_id`)
assigned as the 'Success Manager' (field referenced by `field_id`)?"
#### Allowed For
* Agents
*/
export async function main(
auth: Zendesk,
target_type: string,
target_id: string,
field_id: string,
source_type: string
) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/${target_type}/${target_id}/relationship_fields/${field_id}/${source_type}`
);
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;
};
/**
* Get sources by target
* Returns a list of source objects whose values are populated with the id of a related target object. For example,
if you have a lookup field called "Success Manager" on a ticket, this endpoint can answer the question,
"What tickets (sources) is this user (found by `target_type` and `target_id`)
assigned as the 'Success Manager' (field referenced by `field_id`)?"
#### Allowed For
* Agents
*/
export async function main(
auth: Zendesk,
target_type: string,
target_id: string,
field_id: string,
source_type: string
) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/${target_type}/${target_id}/relationship_fields/${field_id}/${source_type}`
);
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