// TODO: better import syntax?
import { BaseAPIRequestFactory, RequiredError } from './baseapi';
import {Configuration} from '../configuration';
import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {isCodeInRange} from '../util';
import { BlikFields } from '../models/BlikFields';
import { BlikResponse } from '../models/BlikResponse';
import { CreateFields } from '../models/CreateFields';
import { CreateResponse } from '../models/CreateResponse';
import { GetFields } from '../models/GetFields';
import { GetResponse } from '../models/GetResponse';
import { RefundAnyFields } from '../models/RefundAnyFields';
import { RefundAnyResponse } from '../models/RefundAnyResponse';
import { RefundStatusResponse } from '../models/RefundStatusResponse';
import { RefundTransactionFields } from '../models/RefundTransactionFields';
import { ReportFields } from '../models/ReportFields';
import { ReportResponse } from '../models/ReportResponse';
/**
* no description
*/
export class TransactionAPIApiRequestFactory extends BaseAPIRequestFactory {
/**
* The method used to refund part of the transaction amount.
NOTICE: This method works only in production mode!
To test this method, you need to create the transaction in production mode with your own API access.
* any
* @param apiKey The api key.
* @param refundAnyData Request body.
*/
public async apiGwApiKeyChargebackAnyPost(apiKey: string, refundAnyData?: RefundAnyFields, _options?: Configuration): Promise {
let _config = _options || this.configuration;
// verify required parameter 'apiKey' is not null or undefined
if (apiKey === null || apiKey === undefined) {
throw new RequiredError('Required parameter apiKey was null or undefined when calling apiGwApiKeyChargebackAnyPost.');
}
// Path Params
const localVarPath = '/api/gw/{api_key}/chargeback/any'
.replace('{' + 'api_key' + '}', encodeURIComponent(String(apiKey)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
// Header Params
// Form Params
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(refundAnyData, "RefundAnyFields", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
return requestContext;
}
/**
* The method used to check transaction refunds statuses.
Some refunds statuses may be not available immediately after calling refund methods due to gathering refund details process.
* status
* @param apiKey The api key.
* @param refundTransactionData Request body.
*/
public async apiGwApiKeyChargebackStatusPost(apiKey: string, refundTransactionData?: RefundTransactionFields, _options?: Configuration): Promise {
let _config = _options || this.configuration;
// verify required parameter 'apiKey' is not null or undefined
if (apiKey === null || apiKey === undefined) {
throw new RequiredError('Required parameter apiKey was null or undefined when calling apiGwApiKeyChargebackStatusPost.');
}
// Path Params
const localVarPath = '/api/gw/{api_key}/chargeback/status'
.replace('{' + 'api_key' + '}', encodeURIComponent(String(apiKey)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
// Header Params
// Form Params
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(refundTransactionData, "RefundTransactionFields", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
return requestContext;
}
/**
* The method used to refund full transaction amount. You can get transaction title from 'create' method when generating the transaction.
NOTICE: This method works only in production mode!
To test this method, you need to create the transaction in production mode with your own API access.
* transaction
* @param apiKey The api key.
* @param refundTransactionData Request body.
*/
public async apiGwApiKeyChargebackTransactionPost(apiKey: string, refundTransactionData?: RefundTransactionFields, _options?: Configuration): Promise {
let _config = _options || this.configuration;
// verify required parameter 'apiKey' is not null or undefined
if (apiKey === null || apiKey === undefined) {
throw new RequiredError('Required parameter apiKey was null or undefined when calling apiGwApiKeyChargebackTransactionPost.');
}
// Path Params
const localVarPath = '/api/gw/{api_key}/chargeback/transaction'
.replace('{' + 'api_key' + '}', encodeURIComponent(String(apiKey)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
// Header Params
// Form Params
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(refundTransactionData, "RefundTransactionFields", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
return requestContext;
}
/**
* This method allows sending a BLIK code in direct communication between merchant and BLIK system. In ‘create’ method you should set 150 as a value for parameter ‘group’, this is a BLIK payment channel. Method returns parameter ‘result’ equal to 1 which means that payment popup has been successfully displayed at customer mobile application. After accepting payment by the customer, tpay.com system sends a standard notification to merchant's endpoint declared in wyn_url parameter (this parameter should be sent in 'create' method.)
NOTICE: to test this method, you need to create the transaction with 'create' method and replace title parameter value with the returned title.
Blik method works with the specific set of parameters depending on payment type case. Please see BLIK workflow section.
* blik
* @param apiKey The api key.
* @param blikData Request body.
*/
public async apiGwApiKeyTransactionBlikPost(apiKey: string, blikData?: BlikFields, _options?: Configuration): Promise {
let _config = _options || this.configuration;
// verify required parameter 'apiKey' is not null or undefined
if (apiKey === null || apiKey === undefined) {
throw new RequiredError('Required parameter apiKey was null or undefined when calling apiGwApiKeyTransactionBlikPost.');
}
// Path Params
const localVarPath = '/api/gw/{api_key}/transaction/blik'
.replace('{' + 'api_key' + '}', encodeURIComponent(String(apiKey)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
// Header Params
// Form Params
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(blikData, "BlikFields", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
return requestContext;
}
/**
* This method allows you to prepare transaction for a customer. The method returns transaction title required for other API methods and redirection link for a customer.
This method also returns account details for manual money transfers.
* create
* @param apiKey The api key.
* @param basicData Transaction data.
*/
public async apiGwApiKeyTransactionCreatePost(apiKey: string, basicData?: CreateFields, _options?: Configuration): Promise {
let _config = _options || this.configuration;
// verify required parameter 'apiKey' is not null or undefined
if (apiKey === null || apiKey === undefined) {
throw new RequiredError('Required parameter apiKey was null or undefined when calling apiGwApiKeyTransactionCreatePost.');
}
// Path Params
const localVarPath = '/api/gw/{api_key}/transaction/create'
.replace('{' + 'api_key' + '}', encodeURIComponent(String(apiKey)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
// Header Params
// Form Params
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(basicData, "CreateFields", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
return requestContext;
}
/**
* This method allows you to get all information about the transaction by sending previously generated title.
* get
* @param apiKey The api key.
* @param getData Request body.
*/
public async apiGwApiKeyTransactionGetPost(apiKey: string, getData?: GetFields, _options?: Configuration): Promise {
let _config = _options || this.configuration;
// verify required parameter 'apiKey' is not null or undefined
if (apiKey === null || apiKey === undefined) {
throw new RequiredError('Required parameter apiKey was null or undefined when calling apiGwApiKeyTransactionGetPost.');
}
// Path Params
const localVarPath = '/api/gw/{api_key}/transaction/get'
.replace('{' + 'api_key' + '}', encodeURIComponent(String(apiKey)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
// Header Params
// Form Params
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(getData, "GetFields", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
return requestContext;
}
/**
* This method returns payments report for the declared time range, generated in CSV format (semicolon separators) and encoded in base64 - the same format as in merchant panel. If you like to arrange result as an associative array, you can use the ready script from Tpay PHP library.
* report
* @param apiKey The api key.
* @param reportData Request body.
*/
public async apiGwApiKeyTransactionReportPost(apiKey: string, reportData?: ReportFields, _options?: Configuration): Promise {
let _config = _options || this.configuration;
// verify required parameter 'apiKey' is not null or undefined
if (apiKey === null || apiKey === undefined) {
throw new RequiredError('Required parameter apiKey was null or undefined when calling apiGwApiKeyTransactionReportPost.');
}
// Path Params
const localVarPath = '/api/gw/{api_key}/transaction/report'
.replace('{' + 'api_key' + '}', encodeURIComponent(String(apiKey)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
// Header Params
// Form Params
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(reportData, "ReportFields", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
return requestContext;
}
}
export class TransactionAPIApiResponseProcessor {
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to apiGwApiKeyChargebackAnyPost
* @throws ApiException if the response code was not in [200, 299]
*/
public async apiGwApiKeyChargebackAnyPost(response: ResponseContext): Promise {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: RefundAnyResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"RefundAnyResponse", ""
) as RefundAnyResponse;
return body;
}
if (isCodeInRange("401", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Api password is incorrect");
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Invalid api key or password");
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: RefundAnyResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"RefundAnyResponse", ""
) as RefundAnyResponse;
return body;
}
let body = response.body || "";
throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to apiGwApiKeyChargebackStatusPost
* @throws ApiException if the response code was not in [200, 299]
*/
public async apiGwApiKeyChargebackStatusPost(response: ResponseContext): Promise {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: RefundStatusResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"RefundStatusResponse", ""
) as RefundStatusResponse;
return body;
}
if (isCodeInRange("401", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Api password is incorrect");
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Invalid api key or password");
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: RefundStatusResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"RefundStatusResponse", ""
) as RefundStatusResponse;
return body;
}
let body = response.body || "";
throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to apiGwApiKeyChargebackTransactionPost
* @throws ApiException if the response code was not in [200, 299]
*/
public async apiGwApiKeyChargebackTransactionPost(response: ResponseContext): Promise {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: RefundAnyResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"RefundAnyResponse", ""
) as RefundAnyResponse;
return body;
}
if (isCodeInRange("401", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Api password is incorrect");
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Invalid api key or password");
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: RefundAnyResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"RefundAnyResponse", ""
) as RefundAnyResponse;
return body;
}
let body = response.body || "";
throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to apiGwApiKeyTransactionBlikPost
* @throws ApiException if the response code was not in [200, 299]
*/
public async apiGwApiKeyTransactionBlikPost(response: ResponseContext): Promise {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: BlikResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"BlikResponse", ""
) as BlikResponse;
return body;
}
if (isCodeInRange("401", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Api password is incorrect");
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Invalid api key or password");
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: BlikResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"BlikResponse", ""
) as BlikResponse;
return body;
}
let body = response.body || "";
throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to apiGwApiKeyTransactionCreatePost
* @throws ApiException if the response code was not in [200, 299]
*/
public async apiGwApiKeyTransactionCreatePost(response: ResponseContext): Promise {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: CreateResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CreateResponse", ""
) as CreateResponse;
return body;
}
if (isCodeInRange("401", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Api password is incorrect");
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Invalid api key or password");
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: CreateResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CreateResponse", ""
) as CreateResponse;
return body;
}
let body = response.body || "";
throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to apiGwApiKeyTransactionGetPost
* @throws ApiException if the response code was not in [200, 299]
*/
public async apiGwApiKeyTransactionGetPost(response: ResponseContext): Promise {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: GetResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"GetResponse", ""
) as GetResponse;
return body;
}
if (isCodeInRange("401", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Api password is incorrect");
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Invalid api key or password");
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: GetResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"GetResponse", ""
) as GetResponse;
return body;
}
let body = response.body || "";
throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to apiGwApiKeyTransactionReportPost
* @throws ApiException if the response code was not in [200, 299]
*/
public async apiGwApiKeyTransactionReportPost(response: ResponseContext): Promise {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: ReportResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ReportResponse", ""
) as ReportResponse;
return body;
}
if (isCodeInRange("401", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Api password is incorrect");
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException(response.httpStatusCode, "Invalid api key or password");
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: ReportResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ReportResponse", ""
) as ReportResponse;
return body;
}
let body = response.body || "";
throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
}
}