import {z} from 'zod' export type GetApiDomesticPaymentConsentsConsentIdArgs = {ConsentId: string, 'x-fapi-auth-date'?: string | undefined, 'x-fapi-customer-ip-address'?: string | undefined, 'x-fapi-interaction-id'?: string | undefined, Authorization: string, 'x-customer-user-agent'?: string | undefined, 'x-client-id'?: string | undefined}; export type GetApiDomesticPaymentConsentsConsentIdOptions = {baseUrl: string, TPPOAuth2Security?: string | undefined, fetch?: typeof fetch | undefined}; export const oBInternalConsentStatus2Code = z.enum(["AWAU", "RJCT", "AUTH", "COND"]); export const oBStatusReason = z.object({StatusReasonCode: z.string().min(1).max(4).optional(), StatusReasonDescription: z.string().min(1).max(500).optional(), Path: z.string().min(1).max(500).optional()}); export const oBInternalChargeBearerType1Code = z.enum(["BorneByCreditor", "BorneByDebtor", "FollowingServiceLevel", "Shared"]); export const oBInternalPaymentChargeType1Code = z.string(); export const oBActiveCurrencyAndAmountSimpleType = z.string(); export const activeOrHistoricCurrencyCode = z.string(); export const oBActiveOrHistoricCurrencyAndAmount = z.object({Amount: oBActiveCurrencyAndAmountSimpleType, Currency: activeOrHistoricCurrencyCode}); export const oBInternalLocalInstrument1Code = z.string(); export const oBInternalAccountIdentification4Code = z.string(); export const identification0 = z.string().min(1).max(256); export const secondaryIdentification = z.string().min(1).max(34); export const externalProxyAccountType1Code = z.enum(["TELE", "EMAL", "DNAM", "CINC", "COTX", "COID", "CUST", "DRLC", "EIDN", "EWAL", "PVTX", "LEIC", "MBNO", "NIDN", "CCPT", "SHID", "SOSE", "TOKN", "UBIL", "VIPN", "BIID"]); export const oBProxy1 = z.object({Identification: z.string().min(1).max(2048), Code: externalProxyAccountType1Code, Type: z.string().min(1).max(35).optional()}); export const oBInternalFinancialInstitutionIdentification4Code = z.string(); export const identification1 = z.string().min(1).max(35); export const name = z.string().min(1).max(140); export const lEI = z.string().min(1).max(20); export const oBAddressType2Code = z.enum(["BIZZ", "DLVY", "MLTO", "PBOX", "ADDR", "HOME", "CORR", "STAT"]); export const department = z.string().min(1).max(70); export const subDepartment = z.string().min(1).max(70); export const streetName = z.string().min(1).max(140); export const buildingNumber = z.string().min(1).max(16); export const buildingName = z.string().min(1).max(140); export const floor = z.string().min(1).max(70); export const unitNumber = z.string().min(1).max(16); export const room = z.string().min(1).max(70); export const postBox = z.string().min(1).max(16); export const townName = z.string().min(1).max(140); export const districtName = z.string().min(1).max(140); export const careOf = z.string().min(1).max(140); export const postCode = z.string().min(1).max(16); export const countrySubDivision = z.string().min(1).max(35); export const countryCode = z.string(); export const oBPostalAddress7 = z.object({AddressType: oBAddressType2Code.optional(), Department: department.optional(), SubDepartment: subDepartment.optional(), StreetName: streetName.optional(), BuildingNumber: buildingNumber.optional(), BuildingName: buildingName.optional(), Floor: floor.optional(), UnitNumber: unitNumber.optional(), Room: room.optional(), PostBox: postBox.optional(), TownLocationName: townName.optional(), DistrictName: districtName.optional(), CareOf: careOf.optional(), PostCode: postCode.optional(), TownName: townName.optional(), CountrySubDivision: countrySubDivision.optional(), Country: countryCode.optional(), AddressLine: z.array(z.string().min(1).max(70)).optional()}); export const oBUltimateCreditor1 = z.object({Name: z.string().min(1).max(140).optional(), Identification: z.string().min(1).max(256).optional(), LEI: lEI.optional(), SchemeName: oBInternalAccountIdentification4Code.optional(), PostalAddress: oBPostalAddress7.optional()}); export const oBUltimateDebtor1 = z.object({Name: z.string().min(1).max(140).optional(), Identification: z.string().min(1).max(256).optional(), LEI: lEI.optional(), SchemeName: oBInternalAccountIdentification4Code.optional(), PostalAddress: oBPostalAddress7.optional()}); export const oBRegulatoryAuthority2 = z.object({Name: z.string().min(1).max(140).optional(), CountryCode: countryCode.optional()}); export const iSODateTime = z.string(); export const oBStructuredRegulatoryReporting3 = z.object({Type: z.string().min(1).max(35).optional(), Date: iSODateTime.optional(), Country: countryCode.optional(), Amount: oBActiveOrHistoricCurrencyAndAmount.optional(), Information: z.array(z.string().min(1).max(35)).optional()}); export const oBRegulatoryReporting1 = z.object({DebitCreditReportingIndicator: z.enum(["CRED", "DEBT", "BOTH"]).optional(), Authority: oBRegulatoryAuthority2.optional(), Details: z.array(oBStructuredRegulatoryReporting3).optional()}); export const externalDocumentType1Code = z.enum(["CINV", "CNFA", "CONT", "CREN", "DEBN", "DISP", "DNFA", "HIRI", "INVS", "MSIN", "PROF", "PUOR", "QUOT", "SBIN", "SPRR", "TISH"]).min(1).max(4); export const oBReferredDocumentInformation = z.object({Code: externalDocumentType1Code.optional(), Issuer: z.string().min(1).max(35).optional(), Number: z.string().min(1).max(35).optional(), RelatedDate: z.string().optional(), LineDetails: z.array(z.string().min(1).max(2048)).optional()}); export const externalCreditorReferenceType1Code = z.enum(["DISP", "FXDR", "PUOR", "RPIN", "RADM", "SCOR"]).min(1).max(4); export const identification3 = z.string().min(1).max(256); export const identification4 = z.string().min(1).max(256); export const oBRemittanceInformationStructured = z.object({ReferredDocumentInformation: z.array(oBReferredDocumentInformation).optional(), ReferredDocumentAmount: oBActiveCurrencyAndAmountSimpleType.optional(), CreditorReferenceInformation: z.object({Code: externalCreditorReferenceType1Code.optional(), Issuer: z.string().min(1).max(35).optional(), Reference: z.string().min(1).max(35).optional()}).optional(), Invoicer: identification3.optional(), Invoicee: identification4.optional(), TaxRemittance: z.string().min(1).max(140).optional(), AdditionalRemittanceInformation: z.array(z.string().min(1).max(140)).optional()}); export const oBRemittanceInformation2 = z.object({Structured: z.array(oBRemittanceInformationStructured).optional(), Unstructured: z.array(z.string().min(1).max(140)).optional()}); export const oBSupplementaryData1 = z.record(z.string(), z.unknown()); export const oBSCASupportData1 = z.object({RequestedSCAExemptionType: z.enum(["BillPayment", "ContactlessTravel", "EcommerceGoods", "EcommerceServices", "Kiosk", "Parking", "PartyToParty"]).optional(), AppliedAuthenticationApproach: z.enum(["CA", "SCA"]).max(40).optional(), ReferencePaymentOrderId: z.string().min(1).max(40).optional()}); export const oBCashAccountDebtor4 = z.object({SchemeName: z.string().optional(), Identification: z.string().optional(), Name: z.string().optional(), SecondaryIdentification: z.string().optional(), LEI: lEI.optional()}); export const externalPurpose1Code = z.enum(["BKDF", "BKFE", "BKFM", "BKIP", "BKPP", "CBLK", "CDCB", "CDCD", "CDCS", "CDDP", "CDOC", "CDQC", "ETUP", "FCOL", "MTUP", "ACCT", "CASH", "COLL", "CSDB", "DEPT", "INTC", "INTP", "LIMA", "NETT", "BFWD", "CCIR", "CCPC", "CCPM", "CCSM", "CRDS", "CRPR", "CRSP", "CRTL", "EQPT", "EQUS", "EXPT", "EXTD", "FIXI", "FWBC", "FWCC", "FWSB", "FWSC", "MARG", "MBSB", "MBSC", "MGCC", "MGSC", "OCCC", "OPBC", "OPCC", "OPSB", "OPSC", "OPTN", "OTCD", "REPO", "RPBC", "RPCC", "RPSB", "RPSC", "RVPO", "SBSC", "SCIE", "SCIR", "SCRP", "SHBC", "SHCC", "SHSL", "SLEB", "SLOA", "SWBC", "SWCC", "SWPT", "SWSB", "SWSC", "TBAS", "TBBC", "TBCC", "TRCP", "AGRT", "AREN", "BEXP", "BOCE", "COMC", "CPYR", "GDDS", "GDSV", "GSCB", "LICF", "MP2B", "POPE", "ROYA", "SCVE", "SERV", "SUBS", "SUPP", "TRAD", "CHAR", "COMT", "MP2P", "ECPG", "ECPR", "ECPU", "EPAY", "CLPR", "COMP", "DBTC", "GOVI", "HLRP", "HLST", "INPC", "INPR", "INSC", "INSU", "INTE", "LBRI", "LIFI", "LOAN", "LOAR", "PENO", "PPTI", "RELG", "RINP", "TRFD", "FORW", "FXNT", "ADMG", "ADVA", "BCDM", "BCFG", "BLDM", "BNET", "CBFF", "CBFR", "CCRD", "CDBL", "CFEE", "CGDD", "CORT", "COST", "CPKC", "DCRD", "DSMT", "DVPM", "EDUC", "FACT", "FAND", "FCPM", "FEES", "GIFT", "GOVT", "ICCP", "IDCP", "IHRP", "INSM", "IVPT", "MCDM", "MCFG", "MSVC", "NOWS", "OCDM", "OCFG", "OFEE", "OTHR", "PADD", "PTSP", "RCKE", "RCPT", "REBT", "REFU", "RENT", "REOD", "RIMB", "RPNT", "RRBN", "RRCT", "RRTP", "RVPM", "SLPI", "SPLT", "STDY", "TBAN", "TBIL", "TCSC", "TELI", "TMPG", "TPRI", "TPRP", "TRNC", "TRVC", "WEBI", "IPAY", "IPCA", "IPDO", "IPEA", "IPEC", "IPEW", "IPPS", "IPRT", "IPU2", "IPUW", "ANNI", "CAFI", "CFDI", "CMDT", "DERI", "DIVD", "FREX", "HEDG", "INVS", "PRME", "SAVG", "SECU", "SEPI", "TREA", "UNIT", "FNET", "FUTR", "ANTS", "CVCF", "DMEQ", "DNTS", "HLTC", "HLTI", "HSPC", "ICRF", "LTCF", "MAFC", "MARF", "MDCS", "VIEW", "CDEP", "SWFP", "SWPP", "SWRS", "SWUF", "ADCS", "AEMP", "ALLW", "ALMY", "BBSC", "BECH", "BENE", "BONU", "CCHD", "COMM", "CSLP", "GFRP", "GVEA", "GVEB", "GVEC", "GVED", "GWLT", "HREC", "PAYR", "PEFC", "PENS", "PRCP", "RHBS", "SALA", "SPSP", "SSBE", "LBIN", "LCOL", "LFEE", "LMEQ", "LMFI", "LMRK", "LREB", "LREV", "LSFL", "ESTX", "FWLV", "GSTX", "HSTX", "INTX", "NITX", "PTXP", "RDTX", "TAXS", "VATX", "WHLD", "TAXR", "B112", "BR12", "TLRF", "TLRR", "AIRB", "BUSB", "FERB", "RLWY", "TRPT", "CBTV", "ELEC", "ENRG", "GASB", "NWCH", "NWCM", "OTLC", "PHON", "UBIL", "WTER", "BOND", "CABD", "CAEQ", "CBCR", "DBCR", "DICL", "EQTS", "FLCR", "EFTC", "EFTD", "MOMA", "RAPI", "GAMB", "LOTT", "AMEX", "SASW", "AUCO", "PCOM", "PDEP", "PLDS", "PLRF", "GAFA", "GAHO", "CPEN", "DEPD", "RETL", "DEBT", "CRYP"]).min(1).max(4); export const externalCategoryPurpose1Code = z.enum(["BONU", "CASH", "CBLK", "CCRD", "CGWV", "CIPC", "CONC", "CORT", "DCRD", "DIVI", "DVPM", "EPAY", "FCDT", "FCIN", "FCOL", "GOVT", "GP2P", "HEDG", "ICCP", "IDCP", "INTC", "INTE", "LBOX", "LOAN", "MP2B", "MP2P", "OTHR", "PENS", "RPRE", "RRCT", "RVPM", "SALA", "SECU", "SSBE", "SUPP", "SWEP", "TAXS", "TOPG", "TRAD", "TREA", "VATX", "VOST", "WHLD", "ZABA"]); export const oBInternalExtendedAccountType1Code = z.enum(["Business", "BusinessSavingsAccount", "Charity", "Collection", "Corporate", "Ewallet", "Government", "Investment", "ISA", "JointPersonal", "Pension", "Personal", "PersonalSavingsAccount", "Premier", "Wealth"]); export const oBRisk1 = z.object({PaymentContextCode: z.enum(["BillingGoodsAndServicesInAdvance", "BillingGoodsAndServicesInArrears", "EcommerceMerchantInitiatedPayment", "FaceToFacePointOfSale", "TransferToSelf", "TransferToThirdParty", "BillPayment", "EcommerceGoods", "EcommerceServices", "PartyToParty", "PispPayee", "Other"]).optional(), MerchantCategoryCode: z.string().min(3).max(4).optional(), MerchantCustomerIdentification: z.string().min(1).max(70).optional(), ContractPresentIndicator: z.boolean().optional(), BeneficiaryPrepopulatedIndicator: z.boolean().optional(), PaymentPurposeCode: externalPurpose1Code.optional(), CategoryPurposeCode: externalCategoryPurpose1Code.optional(), BeneficiaryAccountType: oBInternalExtendedAccountType1Code.optional(), DeliveryAddress: oBPostalAddress7.optional()}); export const links = z.object({Self: z.string(), First: z.string().optional(), Prev: z.string().optional(), Next: z.string().optional(), Last: z.string().optional()}); export const meta = z.object({TotalPages: z.number().int().optional(), FirstAvailableDateTime: iSODateTime.optional(), LastAvailableDateTime: iSODateTime.optional()}); export const oBWriteDomesticConsentResponse5 = z.object({Data: z.object({ConsentId: z.string().min(1).max(128), CreationDateTime: z.string(), Status: oBInternalConsentStatus2Code, StatusReason: z.array(oBStatusReason).optional(), StatusUpdateDateTime: z.string(), ReadRefundAccount: z.enum(["No", "Yes"]).optional(), CutOffDateTime: z.string().optional(), ExpectedExecutionDateTime: z.string().optional(), ExpectedSettlementDateTime: z.string().optional(), Charges: z.array(z.object({ChargeBearer: oBInternalChargeBearerType1Code, Type: oBInternalPaymentChargeType1Code, Amount: oBActiveOrHistoricCurrencyAndAmount})).optional(), Initiation: z.object({InstructionIdentification: z.string().min(1).max(35), EndToEndIdentification: z.string().min(1).max(35), LocalInstrument: oBInternalLocalInstrument1Code.optional(), InstructedAmount: z.object({Amount: oBActiveCurrencyAndAmountSimpleType, Currency: activeOrHistoricCurrencyCode}), DebtorAccount: z.object({SchemeName: oBInternalAccountIdentification4Code, Identification: identification0, Name: z.string().min(1).max(350).optional(), SecondaryIdentification: secondaryIdentification.optional(), Proxy: oBProxy1.optional()}).optional(), CreditorAgent: z.object({SchemeName: oBInternalFinancialInstitutionIdentification4Code.optional(), Identification: identification1.optional(), Name: name.optional(), LEI: lEI.optional(), PostalAddress: oBPostalAddress7.optional()}).optional(), CreditorAccount: z.object({SchemeName: oBInternalAccountIdentification4Code, Identification: identification0, Name: z.string().min(1).max(350), SecondaryIdentification: secondaryIdentification.optional(), Proxy: oBProxy1.optional()}), CreditorPostalAddress: oBPostalAddress7.optional(), UltimateCreditor: oBUltimateCreditor1.optional(), UltimateDebtor: oBUltimateDebtor1.optional(), RegulatoryReporting: z.array(oBRegulatoryReporting1).optional(), RemittanceInformation: oBRemittanceInformation2.optional(), SupplementaryData: oBSupplementaryData1.optional()}), Authorisation: z.object({AuthorisationType: z.enum(["Any", "Single", "Multiple"]), CompletionDateTime: z.string().optional()}).optional(), SCASupportData: oBSCASupportData1.optional(), Debtor: oBCashAccountDebtor4.optional()}), Risk: oBRisk1, Links: links.optional(), Meta: meta.optional()}); 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 a Domestic Payment Consent * * GET /domestic-payment-consents/{ConsentId} */ export const getApiDomesticPaymentConsentsConsentId = async (args: GetApiDomesticPaymentConsentsConsentIdArgs, options: GetApiDomesticPaymentConsentsConsentIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, TPPOAuth2Security} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['x-fapi-auth-date'] != null) headers.set("x-fapi-auth-date", String(args['x-fapi-auth-date'])) if (args['x-fapi-customer-ip-address'] != null) headers.set("x-fapi-customer-ip-address", String(args['x-fapi-customer-ip-address'])) if (args['x-fapi-interaction-id'] != null) headers.set("x-fapi-interaction-id", String(args['x-fapi-interaction-id'])) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args['x-customer-user-agent'] != null) headers.set("x-customer-user-agent", String(args['x-customer-user-agent'])) if (args['x-client-id'] != null) headers.set("x-client-id", String(args['x-client-id'])) if (TPPOAuth2Security !== undefined) headers.set('authorization', `Bearer ${TPPOAuth2Security}`) const url = `${baseUrl.replace(/\/+$/, '')}/domestic-payment-consents/${encodeURIComponent(String(args.ConsentId))}${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(oBWriteDomesticConsentResponse5, await res.json()) };