//native
type Codat = {
encodedKey: string
}
/**
* Get dispute
* The *Get dispute* endpoint returns a single dispute for a given disputeId.
[Disputes](https://docs.codat.io/lending-api#/schemas/Dispute) are created when a customer is unsatisfied with their purchase or believe they have been charged incorrectly.
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,
disputeId: string
) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/commerce-disputes/${disputeId}`
)
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