pnz-payments-sdk
Version:
PNZ Payments Account and Transaction API
150 lines • 11.3 kB
JavaScript
;
/**
* Account and Transaction API SpecificationLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.TransactionsController = void 0;
var tslib_1 = require("tslib");
var transactionsResponse_1 = require("../models/transactionsResponse");
var schema_1 = require("../schema");
var baseController_1 = require("./baseController");
var core_1 = require("@apimatic/core");
var accountsTransactions400Error_1 = require("../errors/accountsTransactions400Error");
var accountsTransactions403Error_1 = require("../errors/accountsTransactions403Error");
var accountsTransactions500Error_1 = require("../errors/accountsTransactions500Error");
var accountsTransactions503Error_1 = require("../errors/accountsTransactions503Error");
var transactions400Error_1 = require("../errors/transactions400Error");
var transactions403Error_1 = require("../errors/transactions403Error");
var transactions500Error_1 = require("../errors/transactions500Error");
var transactions503Error_1 = require("../errors/transactions503Error");
var TransactionsController = /** @class */ (function (_super) {
tslib_1.__extends(TransactionsController, _super);
function TransactionsController() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* 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
*/
TransactionsController.prototype.getAccountTransactions = function (accountId, fromBookingDateTime, toBookingDateTime, xFapiAuthDate, xFapiCustomerIpAddress, xFapiInteractionId, xMerchantIpAddress, xCustomerUserAgent, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('GET');
mapped = req.prepareArgs({
accountId: [accountId, (0, schema_1.string)()],
fromBookingDateTime: [fromBookingDateTime, (0, schema_1.optional)((0, schema_1.string)())],
toBookingDateTime: [toBookingDateTime, (0, schema_1.optional)((0, schema_1.string)())],
xFapiAuthDate: [xFapiAuthDate, (0, schema_1.optional)((0, schema_1.string)())],
xFapiCustomerIpAddress: [xFapiCustomerIpAddress, (0, schema_1.optional)((0, schema_1.string)())],
xFapiInteractionId: [xFapiInteractionId, (0, schema_1.optional)((0, schema_1.string)())],
xMerchantIpAddress: [xMerchantIpAddress, (0, schema_1.optional)((0, schema_1.string)())],
xCustomerUserAgent: [xCustomerUserAgent, (0, schema_1.optional)((0, schema_1.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(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["/accounts/", "/transactions"], ["/accounts/", "/transactions"])), mapped.accountId);
req.throwOn(400, accountsTransactions400Error_1.AccountsTransactions400Error, 'Bad Request');
req.throwOn(401, core_1.ApiError, 'Unauthorized');
req.throwOn(403, accountsTransactions403Error_1.AccountsTransactions403Error, 'Forbidden');
req.throwOn(405, core_1.ApiError, 'Method Not Allowed');
req.throwOn(406, core_1.ApiError, 'Not Acceptable');
req.throwOn(429, core_1.ApiError, 'Too Many Requests');
req.throwOn(500, accountsTransactions500Error_1.AccountsTransactions500Error, 'Internal Server Error');
req.throwOn(501, core_1.ApiError, 'Not Implemented');
req.throwOn(503, accountsTransactions503Error_1.AccountsTransactions503Error, 'Service Unavailable');
req.authenticate([{ hTTPBearerAuthentication: true }]);
return [2 /*return*/, req.callAsJson(transactionsResponse_1.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
*/
TransactionsController.prototype.getTransactions = function (fromBookingDateTime, toBookingDateTime, xFapiAuthDate, xFapiCustomerIpAddress, xFapiInteractionId, xMerchantIpAddress, xCustomerUserAgent, requestOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var req, mapped;
return tslib_1.__generator(this, function (_a) {
req = this.createRequest('GET', '/transactions');
mapped = req.prepareArgs({
fromBookingDateTime: [fromBookingDateTime, (0, schema_1.optional)((0, schema_1.string)())],
toBookingDateTime: [toBookingDateTime, (0, schema_1.optional)((0, schema_1.string)())],
xFapiAuthDate: [xFapiAuthDate, (0, schema_1.optional)((0, schema_1.string)())],
xFapiCustomerIpAddress: [xFapiCustomerIpAddress, (0, schema_1.optional)((0, schema_1.string)())],
xFapiInteractionId: [xFapiInteractionId, (0, schema_1.optional)((0, schema_1.string)())],
xMerchantIpAddress: [xMerchantIpAddress, (0, schema_1.optional)((0, schema_1.string)())],
xCustomerUserAgent: [xCustomerUserAgent, (0, schema_1.optional)((0, schema_1.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_1.Transactions400Error, 'Bad Request');
req.throwOn(401, core_1.ApiError, 'Unauthorized');
req.throwOn(403, transactions403Error_1.Transactions403Error, 'Forbidden');
req.throwOn(405, core_1.ApiError, 'Method Not Allowed');
req.throwOn(406, core_1.ApiError, 'Not Acceptable');
req.throwOn(429, core_1.ApiError, 'Too Many Requests');
req.throwOn(500, transactions500Error_1.Transactions500Error, 'Internal Server Error');
req.throwOn(501, core_1.ApiError, 'Not Implemented');
req.throwOn(503, transactions503Error_1.Transactions503Error, 'Service Unavailable');
req.authenticate([{ hTTPBearerAuthentication: true }]);
return [2 /*return*/, req.callAsJson(transactionsResponse_1.transactionsResponseSchema, requestOptions)];
});
});
};
return TransactionsController;
}(baseController_1.BaseController));
exports.TransactionsController = TransactionsController;
var templateObject_1;
//# sourceMappingURL=transactionsController.js.map