import {z} from 'zod' export type GetApiV1CustomersCustomerIdRfiCasesCaseIdArgs = {customer_id: string, case_id: string}; export type GetApiV1CustomersCustomerIdRfiCasesCaseIdOptions = {baseUrl?: string | undefined, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; export const rfiCaseId = z.string(); export const rfiCaseStatus = z.enum(["ACTION_REQUIRED", "PENDING_REVIEW", "ANSWERED", "REJECTED", "CLOSED"]); export const orderId = z.string(); export const cpid = z.string(); export const rfiSubject = z.discriminatedUnion("type", [z.object({type: z.literal("TRANSACTION"), id: orderId, transaction_type: z.string()}), z.object({type: z.literal("RECIPIENT"), id: cpid})]); export const rfiRequirementId = z.string(); export const rfiRequirementType = z.enum(["FILE", "TEXT"]); export const rfiDocumentType = z.enum(["INVOICE", "CONTRACT_AGREEMENT", "CONTRACT", "SETTLEMENT_STATEMENT", "STATEMENT_OF_ACCOUNT", "PURCHASE_ORDER", "PAYMENT_ORDER_INSTRUCTION", "BENEFICIARY_BANK_DETAILS", "WIRE_INSTRUCTIONS", "COUNTERPARTY_KYC_DOCUMENT", "PROOF_OF_RELATIONSHIP", "COUNTERPARTY_EVIDENCE", "BANK_STATEMENT", "TRADING_INVESTMENT_STATEMENT", "CAPITAL_CONTRIBUTION_EVIDENCE", "DISTRIBUTION_REPAYMENT_EVIDENCE", "SOURCE_OF_FUNDS_EXPLANATION", "WALLET_OWNERSHIP_EVIDENCE", "TRANSACTION_HASH", "EXCHANGE_STATEMENT", "STABLECOIN_MINT_REDEMPTION_EVIDENCE", "BLOCKCHAIN_TRANSACTION_SUPPORT", "REVISED_INVOICE_AGREEMENT", "EXPLANATION_LETTER", "DISCREPANCY_EXPLANATION", "UPDATED_PAYMENT_REFERENCE", "OTHER_SUPPORTING_DOCUMENT", "DELIVERY_SLIP", "CUSTOMS_DECLARATION", "BILL_OF_LADING", "IDENTIFICATION_DOCUMENTS", "PROOF_OF_ADDRESS", "REGISTRATION_DOCUMENTS", "INVOICE_FOR_FLIGHT_TICKET", "VISA", "HOTEL_BOOKING", "DELIVERY_SLIP-LOGISTIC_BILL", "DELIVERY_SLIP-CUSTOMS_DECLARATION", "DELIVERY_SLIP-BILL_OF_LADING", "PURCHASE_ORDER-FLIGHT_TICKET", "TRAVEL_DOCUMENT", "PURCHASE_ORDER-HOTEL_BOOKING", "STANDARD_RECIPIENT_INFORMATION", "RECIPIENT_BUSINESS_DETAILS", "RECIPIENT_ADDRESS_REGISTRATION", "RECIPIENT_CONTACT_DETAILS"]); export const rfiRequirementStatus = z.enum(["ACTION_REQUIRED", "ANSWERED"]); export const rfiSubmissionId = z.string(); export const rfiSubmissionType = z.enum(["FILE", "TEXT"]); export const rfiSubmittedBy = z.enum(["CUSTOMER", "COMPLIANCE"]); export const rfiSubmissionView = z.object({submission_id: rfiSubmissionId, type: rfiSubmissionType, document_type: z.enum(["INVOICE", "CONTRACT_AGREEMENT", "CONTRACT", "SETTLEMENT_STATEMENT", "STATEMENT_OF_ACCOUNT", "PURCHASE_ORDER", "PAYMENT_ORDER_INSTRUCTION", "BENEFICIARY_BANK_DETAILS", "WIRE_INSTRUCTIONS", "COUNTERPARTY_KYC_DOCUMENT", "PROOF_OF_RELATIONSHIP", "COUNTERPARTY_EVIDENCE", "BANK_STATEMENT", "TRADING_INVESTMENT_STATEMENT", "CAPITAL_CONTRIBUTION_EVIDENCE", "DISTRIBUTION_REPAYMENT_EVIDENCE", "SOURCE_OF_FUNDS_EXPLANATION", "WALLET_OWNERSHIP_EVIDENCE", "TRANSACTION_HASH", "EXCHANGE_STATEMENT", "STABLECOIN_MINT_REDEMPTION_EVIDENCE", "BLOCKCHAIN_TRANSACTION_SUPPORT", "REVISED_INVOICE_AGREEMENT", "EXPLANATION_LETTER", "DISCREPANCY_EXPLANATION", "UPDATED_PAYMENT_REFERENCE", "OTHER_SUPPORTING_DOCUMENT", "DELIVERY_SLIP", "CUSTOMS_DECLARATION", "BILL_OF_LADING", "IDENTIFICATION_DOCUMENTS", "PROOF_OF_ADDRESS", "REGISTRATION_DOCUMENTS", "INVOICE_FOR_FLIGHT_TICKET", "VISA", "HOTEL_BOOKING", "DELIVERY_SLIP-LOGISTIC_BILL", "DELIVERY_SLIP-CUSTOMS_DECLARATION", "DELIVERY_SLIP-BILL_OF_LADING", "PURCHASE_ORDER-FLIGHT_TICKET", "TRAVEL_DOCUMENT", "PURCHASE_ORDER-HOTEL_BOOKING", "STANDARD_RECIPIENT_INFORMATION", "RECIPIENT_BUSINESS_DETAILS", "RECIPIENT_ADDRESS_REGISTRATION", "RECIPIENT_CONTACT_DETAILS", "null"]).nullable().optional(), text: z.string().nullable().optional(), note: z.string().nullable().optional(), file_name: z.string().nullable().optional(), submitted_by: rfiSubmittedBy, submitted_at: z.string()}); export const rfiRequirementView = z.object({requirement_id: rfiRequirementId, type: rfiRequirementType, accepted_document_types: z.array(rfiDocumentType), required: z.boolean(), status: rfiRequirementStatus, note: z.string(), submissions: z.array(rfiSubmissionView)}); export const rfiCaseResponse = z.object({case_id: rfiCaseId, case_class: z.string(), rfi_status: rfiCaseStatus, subject: rfiSubject, requirements: z.array(rfiRequirementView), created_at: z.string(), updated_at: z.string()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * GET /v1/customers/{customer_id}/rfi-cases/{case_id} */ export const getApiV1CustomersCustomerIdRfiCasesCaseId = async (args: GetApiV1CustomersCustomerIdRfiCasesCaseIdArgs, options?: GetApiV1CustomersCustomerIdRfiCasesCaseIdOptions) => { const {baseUrl = "https://api.1money.com", fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (Authorization !== undefined) headers.set('authorization', `Bearer ${Authorization}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/customers/${encodeURIComponent(String(args.customer_id))}/rfi-cases/${encodeURIComponent(String(args.case_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(rfiCaseResponse, await res.json()) };