//native
type Codat = {
encodedKey: string
}
/**
* Get create item model
* The *Get create item model* endpoint returns the expected data for the request payload when creating an [item](https://docs.codat.io/accounting-api#/schemas/Item) for a given company and integration.
[Items](https://docs.codat.io/accounting-api#/schemas/Item) allow your customers to save and track details of the products and services that they buy and sell.
**Integration-specific behaviour**
See the *response examples* for integration-specific indicative models.
*/
export async function main(auth: Codat, companyId: string, connectionId: string) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/connections/${connectionId}/options/items`
)
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Basic ${auth.encodedKey}`
},
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