//native
type Kustomer = {
apiKey: string;
};
/**
* Get custom attribute metadata
* Retrieves the [metadata properties](https://developer.kustomer.com/kustomer-apps-platform/docs/klasses#metadataproperties) for the custom attributes of a specific resource (for example, Company, Conversation, Customer, Message, and KObject (custom Object)).
Any one of the following roles is required for this endpoint:
|Legacy Role|Equivalent Permission Set Role|
|-----|--------|
|org.user.metadata.read|org.permission.metadata.read|
|org.admin.metadata.read||
*/
export async function main(auth: Kustomer, resource: string) {
const url = new URL(`https://api.kustomerapp.com/v1/metadata/${resource}`);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago