UNPKG

pnz-payments-sdk

Version:

PNZ Payments Account and Transaction API

155 lines (151 loc) 9.13 kB
/** * Account and Transaction API SpecificationLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ import { ApiResponse, RequestOptions } from '../core'; import { TransactionsResponse, transactionsResponseSchema, } from '../models/transactionsResponse'; import { optional, string } from '../schema'; import { BaseController } from './baseController'; import { ApiError } from '@apimatic/core'; import { AccountsTransactions400Error } from '../errors/accountsTransactions400Error'; import { AccountsTransactions403Error } from '../errors/accountsTransactions403Error'; import { AccountsTransactions500Error } from '../errors/accountsTransactions500Error'; import { AccountsTransactions503Error } from '../errors/accountsTransactions503Error'; import { Transactions400Error } from '../errors/transactions400Error'; import { Transactions403Error } from '../errors/transactions403Error'; import { Transactions500Error } from '../errors/transactions500Error'; import { Transactions503Error } from '../errors/transactions503Error'; export class TransactionsController extends BaseController { /** * Get transactions related to an account * * @param accountId A unique identifier used to identify the account resource. * @param fromBookingDateTime The UTC ISO 8601 Date Time to filter transactions FROM NB Time * component is optional - set to 00:00:00 for just Date. If the Date * Time contains a timezone, the API Provider must ignore the timezone * component. * @param toBookingDateTime The UTC ISO 8601 Date Time to filter transactions TO NB Time * component is optional - set to 00:00:00 for just Date. If the Date * Time contains a timezone, the API Provider must ignore the timezone * component. * @param xFapiAuthDate The time when the Customer last logged in with the Third Party. All * dates in the HTTP headers are represented as RFC 7231 Full Dates. An * example is below: Sun, 10 Sep 2017 19:43:31 UTC * @param xFapiCustomerIpAddress The Customer's IP address if the Customer is currently logged in with * the Third Party. * @param xFapiInteractionId An RFC4122 UID used as a correlation id. * @param xMerchantIpAddress The IP address of the merchant when making account information * requests through a Third Party. * @param xCustomerUserAgent The User-Agent of the application on the customer device that is used * to make the account information request * @return Response from the API call */ async getAccountTransactions( accountId: string, fromBookingDateTime?: string, toBookingDateTime?: string, xFapiAuthDate?: string, xFapiCustomerIpAddress?: string, xFapiInteractionId?: string, xMerchantIpAddress?: string, xCustomerUserAgent?: string, requestOptions?: RequestOptions ): Promise<ApiResponse<TransactionsResponse>> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ accountId: [accountId, string()], fromBookingDateTime: [fromBookingDateTime, optional(string())], toBookingDateTime: [toBookingDateTime, optional(string())], xFapiAuthDate: [xFapiAuthDate, optional(string())], xFapiCustomerIpAddress: [xFapiCustomerIpAddress, optional(string())], xFapiInteractionId: [xFapiInteractionId, optional(string())], xMerchantIpAddress: [xMerchantIpAddress, optional(string())], xCustomerUserAgent: [xCustomerUserAgent, optional(string())], }); req.header('x-fapi-auth-date', mapped.xFapiAuthDate); req.header('x-fapi-customer-ip-address', mapped.xFapiCustomerIpAddress); req.header('x-fapi-interaction-id', mapped.xFapiInteractionId); req.header('x-merchant-ip-address', mapped.xMerchantIpAddress); req.header('x-customer-user-agent', mapped.xCustomerUserAgent); req.query('fromBookingDateTime', mapped.fromBookingDateTime); req.query('toBookingDateTime', mapped.toBookingDateTime); req.appendTemplatePath`/accounts/${mapped.accountId}/transactions`; req.throwOn(400, AccountsTransactions400Error, 'Bad Request'); req.throwOn(401, ApiError, 'Unauthorized'); req.throwOn(403, AccountsTransactions403Error, 'Forbidden'); req.throwOn(405, ApiError, 'Method Not Allowed'); req.throwOn(406, ApiError, 'Not Acceptable'); req.throwOn(429, ApiError, 'Too Many Requests'); req.throwOn(500, AccountsTransactions500Error, 'Internal Server Error'); req.throwOn(501, ApiError, 'Not Implemented'); req.throwOn(503, AccountsTransactions503Error, 'Service Unavailable'); req.authenticate([{ hTTPBearerAuthentication: true }]); return req.callAsJson(transactionsResponseSchema, requestOptions); } /** * Get Transactions * * @param fromBookingDateTime The UTC ISO 8601 Date Time to filter transactions FROM NB Time * component is optional - set to 00:00:00 for just Date. If the Date * Time contains a timezone, the API Provider must ignore the timezone * component. * @param toBookingDateTime The UTC ISO 8601 Date Time to filter transactions TO NB Time * component is optional - set to 00:00:00 for just Date. If the Date * Time contains a timezone, the API Provider must ignore the timezone * component. * @param xFapiAuthDate The time when the Customer last logged in with the Third Party. All * dates in the HTTP headers are represented as RFC 7231 Full Dates. An * example is below: Sun, 10 Sep 2017 19:43:31 UTC * @param xFapiCustomerIpAddress The Customer's IP address if the Customer is currently logged in with * the Third Party. * @param xFapiInteractionId An RFC4122 UID used as a correlation id. * @param xMerchantIpAddress The IP address of the merchant when making account information * requests through a Third Party. * @param xCustomerUserAgent The User-Agent of the application on the customer device that is used * to make the account information request * @return Response from the API call */ async getTransactions( fromBookingDateTime?: string, toBookingDateTime?: string, xFapiAuthDate?: string, xFapiCustomerIpAddress?: string, xFapiInteractionId?: string, xMerchantIpAddress?: string, xCustomerUserAgent?: string, requestOptions?: RequestOptions ): Promise<ApiResponse<TransactionsResponse>> { const req = this.createRequest('GET', '/transactions'); const mapped = req.prepareArgs({ fromBookingDateTime: [fromBookingDateTime, optional(string())], toBookingDateTime: [toBookingDateTime, optional(string())], xFapiAuthDate: [xFapiAuthDate, optional(string())], xFapiCustomerIpAddress: [xFapiCustomerIpAddress, optional(string())], xFapiInteractionId: [xFapiInteractionId, optional(string())], xMerchantIpAddress: [xMerchantIpAddress, optional(string())], xCustomerUserAgent: [xCustomerUserAgent, optional(string())], }); req.header('x-fapi-auth-date', mapped.xFapiAuthDate); req.header('x-fapi-customer-ip-address', mapped.xFapiCustomerIpAddress); req.header('x-fapi-interaction-id', mapped.xFapiInteractionId); req.header('x-merchant-ip-address', mapped.xMerchantIpAddress); req.header('x-customer-user-agent', mapped.xCustomerUserAgent); req.query('fromBookingDateTime', mapped.fromBookingDateTime); req.query('toBookingDateTime', mapped.toBookingDateTime); req.throwOn(400, Transactions400Error, 'Bad Request'); req.throwOn(401, ApiError, 'Unauthorized'); req.throwOn(403, Transactions403Error, 'Forbidden'); req.throwOn(405, ApiError, 'Method Not Allowed'); req.throwOn(406, ApiError, 'Not Acceptable'); req.throwOn(429, ApiError, 'Too Many Requests'); req.throwOn(500, Transactions500Error, 'Internal Server Error'); req.throwOn(501, ApiError, 'Not Implemented'); req.throwOn(503, Transactions503Error, 'Service Unavailable'); req.authenticate([{ hTTPBearerAuthentication: true }]); return req.callAsJson(transactionsResponseSchema, requestOptions); } }