//native
type Kustomer = {
apiKey: string;
};
/**
* Update search by ID
* Updates the definition of an existing saved search by its ID.
*/
export async function main(
auth: Kustomer,
id: string,
body: {
name?: string;
data?: {
queryContext?: string;
and?: {} | {}[];
or?: {} | {}[];
not?: {} | {}[];
sort?: {} | {}[];
fields?: {}[];
};
icon?: string;
badgeColor?: string;
showBadge?: false | true;
position?: number;
routing?: { concurrencyLimit: number; timeout: number };
deleted?: false | true;
defaultVisibility?: "all" | "search" | "autopilot" | "none";
userVisibilities?: {
id?: string;
visibility?: "all" | "search" | "autopilot" | "none";
}[];
teamVisibilities?: {
id?: string;
visibility?: "all" | "search" | "autopilot" | "none";
}[];
private?: false | true;
accessTeams?: string[];
accessUsers?: string[];
externalId?: string;
timeZone?: string;
folderId?: string;
},
) {
const url = new URL(
`https://api.kustomerapp.com/v1/customers/searches/${id}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
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