//native
type Codat = {
encodedKey: string
}
/**
* Get create direct cost model
* The *Get create direct cost model* endpoint returns the expected data for the request payload when creating a [direct cost](https://docs.codat.io/lending-api#/schemas/DirectCost) for a given company and integration.
[Direct costs](https://docs.codat.io/lending-api#/schemas/DirectCost) are business expenses that don't impact Accounts Payable.
**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/directCosts`
)
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