//native
type Codat = {
encodedKey: string
}
/**
* Create bank feed account mapping
* The *Create bank account mapping* endpoint creates a new mapping between a source bank account and a potential account in the accounting software (target account).
*/
export async function main(
auth: Codat,
companyId: string,
connectionId: string,
body: {
sourceAccountId: string
targetAccountId?: string
feedStartDate?: string
}
) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/connections/${connectionId}/bankFeedAccounts/mapping`
)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${auth.encodedKey}`
},
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 235 days ago