export type CreditorLegalAddress = {addressLine: string, country: string, countrySubDivision?: string | undefined, postCode?: string | undefined, townName?: string | undefined}; export type OrganisationIdentification = {identification: string, type: string}; export type UpdateCreditorRecord = {dba?: string | undefined, inactiveReason?: string | undefined, isActive?: boolean | undefined, legalBusinessAddress?: CreditorLegalAddress | undefined, organisationIdentifications?: Array | undefined}; export type UpdateApiCreditorAgentsIcaCreditorsCreditorIdArgs = {ica: string, creditor_id: string, body: UpdateCreditorRecord}; export type UpdateApiCreditorAgentsIcaCreditorsCreditorIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a Creditor Registration * * PUT /creditor-agents/{ica}/creditors/{creditor_id} */ export const updateApiCreditorAgentsIcaCreditorsCreditorId = async (args: UpdateApiCreditorAgentsIcaCreditorsCreditorIdArgs, options?: UpdateApiCreditorAgentsIcaCreditorsCreditorIdOptions) => { const {baseUrl = "https://api.mastercard.com/commercial/payments", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/creditor-agents/${encodeURIComponent(String(args.ica))}/creditors/${encodeURIComponent(String(args.creditor_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };