//native
type Motimate = {
token: string
}
export async function main(
auth: Motimate,
body: {
external_id?: string
kind?: 'country' | 'custom' | 'organization' | 'region' | 'store'
name?: string
excluded_from_scoreboard?: false | true
imported?: false | true
parent_id?: number
parent_external_id?: number
}
) {
const url = new URL(`https://motimateapp.com/public_api/groups`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
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 581 days ago