//native
/**
* List Usage By App
* Lists aggregated usage information for all apps during a time period.
*/
export async function main(
auth: RT.Mezmo,
from: string | undefined,
to: string | undefined,
limit?: string | undefined,
retention?: string | undefined
) {
const url = new URL(`https://api.mezmo.com/v2/usage/apps`)
for (const [k, v] of [
['from', from],
['to', to],
['limit', limit],
['retention', retention]
]) {
if (v !== undefined && v !== '') {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Token ' + 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