export type AmexCancellationReason = 'derogatory' | 'non_derogatory'; export type AmexSponsoredMerchantEnrollmentArchive = {type: 'amex_sm', reason: AmexCancellationReason}; export type DeleteReason = 'Data Entry Error' | 'Merchant No Longer Participating' | 'Acquirer BIN Change' | 'Acquirer Primary ICA Change' | 'Other'; export type IssmEnrollmentArchive = {type?: 'issm' | undefined, deleteReason?: DeleteReason | undefined}; export type ArchiveEnrollment = AmexSponsoredMerchantEnrollmentArchive | IssmEnrollmentArchive; export type DeleteApiEnrollmentsEnrollmentKeyArgs = {enrollmentKey: string, body: ArchiveEnrollment}; export type DeleteApiEnrollmentsEnrollmentKeyOptions = {baseUrl?: string | undefined, ApiKey?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Archive Enrollment * * DELETE /enrollments/{enrollmentKey} * * Also accepts auth: BearerToken */ export const deleteApiEnrollmentsEnrollmentKey = async (args: DeleteApiEnrollmentsEnrollmentKeyArgs, options?: DeleteApiEnrollmentsEnrollmentKeyOptions) => { const {baseUrl = "https://eu-west-1.api.silverflow.com/v1", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKey !== undefined) headers.set('authorization', `Basic ${btoa(`${ApiKey.username}:${ApiKey.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/enrollments/${encodeURIComponent(String(args.enrollmentKey))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", 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 };