import {z} from 'zod' export type GetApiScreeningTrlinkCustomersCustomerIdIntegrationsCustomerIntegrationIdArgs = {customerId: string, customerIntegrationId: string}; export type GetApiScreeningTrlinkCustomersCustomerIdIntegrationsCustomerIntegrationIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const tRLinkPartnerResponse = z.object({id: z.string(), ident: z.string(), name: z.string(), description: z.string().nullable().optional(), baseUrl: z.string(), active: z.boolean(), isTest: z.boolean()}); export const tRLinkDiscoverableStatus = z.enum(["anonymous", "hidden", "discoverable"]).nullable(); export const tRLinkGeographicAddressRequest = z.object({addressLine: z.array(z.string().max(70)).nullable().optional(), streetName: z.string().max(70).nullable().optional(), buildingNumber: z.string().max(255).nullable().optional(), floor: z.string().max(70).nullable().optional(), postBox: z.string().max(16).nullable().optional(), postCode: z.string().max(16).nullable().optional(), townName: z.string().max(35).nullable().optional(), districtName: z.string().max(35).nullable().optional(), countrySubDivision: z.string().max(35).nullable().optional(), country: z.string().nullable().optional()}).nullable(); export const tRLinkCustomerResponse = z.object({id: z.string(), discoverable: tRLinkDiscoverableStatus, shortName: z.string(), fullLegalName: z.string(), geographicAddress: tRLinkGeographicAddressRequest.optional(), countryOfRegistration: z.string(), nationalIdentification: z.string().nullable().optional(), dateOfIncorporation: z.string().nullable().optional(), vaults: z.array(z.number().int()).nullable().optional(), trPrimaryPurpose: z.string(), createDate: z.string(), lastUpdate: z.string()}); export const tRLinkCustomerIntegrationResponse = z.object({customerIntegrationId: z.string(), apiKey: z.string().nullable().optional(), secret: z.string().nullable().optional(), createDate: z.string(), lastUpdate: z.string(), partner: tRLinkPartnerResponse, customer: tRLinkCustomerResponse}); 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 customer integration by ID * * GET /screening/trlink/customers/{customerId}/integrations/{customerIntegrationId} */ export const getApiScreeningTrlinkCustomersCustomerIdIntegrationsCustomerIntegrationId = async (args: GetApiScreeningTrlinkCustomersCustomerIdIntegrationsCustomerIntegrationIdArgs, options?: GetApiScreeningTrlinkCustomersCustomerIdIntegrationsCustomerIntegrationIdOptions) => { const {baseUrl = "https://api.fireblocks.io/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/screening/trlink/customers/${encodeURIComponent(String(args.customerId))}/integrations/${encodeURIComponent(String(args.customerIntegrationId))}${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(tRLinkCustomerIntegrationResponse, await res.json()) };