export type OTPSubmit = {name: string, invoice_type: '1000' | '0100' | '1100', branch_name: string, registered_address: string, business_category: string, otp: string}; export type CreateApiAppsGovSaV1EntrySiloEntryIdOtpArgs = {silo_entry_id: string, body: OTPSubmit}; export type CreateApiAppsGovSaV1EntrySiloEntryIdOtpOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Submit the OTP and obtain the Compliance CSID * * POST /apps/gov-sa/v1/entry/{silo_entry_id}/otp */ export const createApiAppsGovSaV1EntrySiloEntryIdOtp = async (args: CreateApiAppsGovSaV1EntrySiloEntryIdOtpArgs, options?: CreateApiAppsGovSaV1EntrySiloEntryIdOtpOptions) => { const {baseUrl = "https://api.invopop.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/apps/gov-sa/v1/entry/${encodeURIComponent(String(args.silo_entry_id))}/otp${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };