//native
type Codat = {
encodedKey: string
}
/**
* Get direct income
* The *Get direct income* endpoint returns a single direct income for a given directIncomeId.
[Direct incomes](https://docs.codat.io/lending-api#/schemas/DirectIncome) are incomes received directly from the business' operations at the point of the sale.
Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/lending-api#/operations/refresh-company-data).
*/
export async function main(
auth: Codat,
companyId: string,
connectionId: string,
directIncomeId: string
) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/directIncomes/${directIncomeId}`
)
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