//native
type Phrase = {
token: string
baseUrl: string
}
/**
* List properties
* List all custom metadata properties for an account.
This endpoint is only available to accounts with advanced plans or above.
*/
export async function main(
auth: Phrase,
account_id: string,
data_type:
| 'boolean'
| 'date'
| 'link'
| 'multi_select'
| 'number'
| 'single_select'
| 'string'
| 'text'
| undefined,
project_id: string | undefined,
page: string | undefined,
per_page: string | undefined,
q: string | undefined,
sort: string | undefined,
order: string | undefined
) {
const url = new URL(`${auth.baseUrl}/accounts/${account_id}/custom_metadata/properties`)
for (const [k, v] of [
['data_type', data_type],
['project_id', project_id],
['page', page],
['per_page', per_page],
['q', q],
['sort', sort],
['order', order]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'ApiToken ' + auth.token
},
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