//native
type Codat = {
encodedKey: string
}
/**
* List data integrity details
* The *List data integrity details* endpoint returns the match result record by record for a given data type, filtered based on a query string in the same way as summary results.
The [details](https://docs.codat.io/lending-api#/schemas/DataIntegrityDetail) are paginated and support ordering, following the same conventions as our other data endpoints.
*/
export async function main(
auth: Codat,
companyId: string,
dataType: 'banking-accounts' | 'banking-transactions' | 'bankAccounts' | 'accountTransactions',
page: string | undefined,
pageSize: string | undefined,
query: string | undefined,
orderBy: string | undefined
) {
const url = new URL(
`https://api.codat.io/data/companies/${companyId}/assess/dataTypes/${dataType}/dataIntegrity/details`
)
for (const [k, v] of [
['page', page],
['pageSize', pageSize],
['query', query],
['orderBy', orderBy]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
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