//native
type Codat = {
encodedKey: string
}
/**
* Get create/update invoice model
* The *Get create/update invoice model* endpoint returns the expected data for the request payload when creating and updating an [invoice](https://docs.codat.io/accounting-api#/schemas/Invoice) for a given company and integration.
[Invoices](https://docs.codat.io/accounting-api#/schemas/Invoice) are itemized records of goods sold or services provided to a customer.
**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/invoices`
)
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