// 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 { MasspaymentAuthorizeFields } from '../models/MasspaymentAuthorizeFields'; import { MasspaymentAuthorizeResponse } from '../models/MasspaymentAuthorizeResponse'; import { MasspaymentCreateFields } from '../models/MasspaymentCreateFields'; import { MasspaymentCreateResponse } from '../models/MasspaymentCreateResponse'; import { MasspaymentPacksFields } from '../models/MasspaymentPacksFields'; import { MasspaymentPacksResponse } from '../models/MasspaymentPacksResponse'; import { MasspaymentTransfersFields } from '../models/MasspaymentTransfersFields'; import { MasspaymentTransfersResponse } from '../models/MasspaymentTransfersResponse'; /** * no description */ export class MasspaymentsApiRequestFactory extends BaseAPIRequestFactory { /** * This method authorizes the processing of chosen pack of transfers. * authorize * @param apiKey The api key. * @param basicData Transaction data. */ public async apiGwApiKeyMasspaymentAuthorizePost(apiKey: string, basicData?: MasspaymentAuthorizeFields, _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 apiGwApiKeyMasspaymentAuthorizePost.'); } // Path Params const localVarPath = '/api/gw/{api_key}/masspayment/authorize' .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, "MasspaymentAuthorizeFields", ""), contentType ); requestContext.setBody(serializedBody); // Apply auth methods return requestContext; } /** * This method adds a pack of transfers to the Tpay system. After executing a correct operation, you need to request authorize method to confirm payout processing. Transfers are being made once a day on workdays. You can find confirmation code in Merchant Panel, settings tab-> notifications. Variable $seller_id is Merchant’s ID in tpay.com system.

Example CSV file
Each line contains one transfer formatted as in the example below. Columns are separated by a semicolon.
The file does not have a header.

account number (26 digits);receiver (part 1) (35 characters);receiver (part 2) (35 characters);receiver (part 3) (35 characters);receiver (part 4) (35 characters);amount (dot or comma separator);title (part 1) (35 characters);title (part 2) (35 characters);Tpay transaction ID

Place transfer receiver name in 1-4 receiver fields. Each field can be maximum 35 characters long.
If receiver name is for example 40 characters long, you should put 35 in receiver 1 field, and 5 characters in receiver 2 field.
The same rule is valid for title field. The transaction ID field is not required, whithout this field, the file format looks like this:

account number (26 digits);receiver (part 1) (35 characters);receiver (part 2) (35 characters);receiver (part 3) (35 characters);receiver (part 4) (35 characters);amount (dot or comma separator);title (part 1) (35 characters);title (part 2) (35 characters);Transaction ID from merchant system

Example CSV file can be downloaded from:
Download * create * @param apiKey The api key. * @param basicData Transaction data. */ public async apiGwApiKeyMasspaymentCreatePost(apiKey: string, basicData?: MasspaymentCreateFields, _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 apiGwApiKeyMasspaymentCreatePost.'); } // Path Params const localVarPath = '/api/gw/{api_key}/masspayment/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, "MasspaymentCreateFields", ""), contentType ); requestContext.setBody(serializedBody); // Apply auth methods return requestContext; } /** * This method allows browsing through created packages. If none of the parameters has been sent, all packages for the Merchant’s account will be returned. If any records exist, there will be pack objects in pack section representing respective transfer packages. You can send pack_id to browse contents of specific pack or send time range to browse all packages within time range * packs * @param apiKey The api key. * @param basicData Transaction data. */ public async apiGwApiKeyMasspaymentPacksPost(apiKey: string, basicData?: MasspaymentPacksFields, _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 apiGwApiKeyMasspaymentPacksPost.'); } // Path Params const localVarPath = '/api/gw/{api_key}/masspayment/packs' .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, "MasspaymentPacksFields", ""), contentType ); requestContext.setBody(serializedBody); // Apply auth methods return requestContext; } /** * This method allows browsing through transfers within one package. Required parameters (besides those described in mass payments main description), at least 1 is obligatory. If any records exist, there will be transfer objects in transfers section representing several transfers. * transfers * @param apiKey The api key. * @param basicData Transaction data. */ public async apiGwApiKeyMasspaymentTransfersPost(apiKey: string, basicData?: MasspaymentTransfersFields, _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 apiGwApiKeyMasspaymentTransfersPost.'); } // Path Params const localVarPath = '/api/gw/{api_key}/masspayment/transfers' .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, "MasspaymentTransfersFields", ""), contentType ); requestContext.setBody(serializedBody); // Apply auth methods return requestContext; } } export class MasspaymentsApiResponseProcessor { /** * 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 apiGwApiKeyMasspaymentAuthorizePost * @throws ApiException if the response code was not in [200, 299] */ public async apiGwApiKeyMasspaymentAuthorizePost(response: ResponseContext): Promise { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body: MasspaymentAuthorizeResponse = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "MasspaymentAuthorizeResponse", "" ) as MasspaymentAuthorizeResponse; 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: MasspaymentAuthorizeResponse = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "MasspaymentAuthorizeResponse", "" ) as MasspaymentAuthorizeResponse; 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 apiGwApiKeyMasspaymentCreatePost * @throws ApiException if the response code was not in [200, 299] */ public async apiGwApiKeyMasspaymentCreatePost(response: ResponseContext): Promise { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body: MasspaymentCreateResponse = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "MasspaymentCreateResponse", "" ) as MasspaymentCreateResponse; 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: MasspaymentCreateResponse = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "MasspaymentCreateResponse", "" ) as MasspaymentCreateResponse; 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 apiGwApiKeyMasspaymentPacksPost * @throws ApiException if the response code was not in [200, 299] */ public async apiGwApiKeyMasspaymentPacksPost(response: ResponseContext): Promise { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body: MasspaymentPacksResponse = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "MasspaymentPacksResponse", "" ) as MasspaymentPacksResponse; 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: MasspaymentPacksResponse = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "MasspaymentPacksResponse", "" ) as MasspaymentPacksResponse; 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 apiGwApiKeyMasspaymentTransfersPost * @throws ApiException if the response code was not in [200, 299] */ public async apiGwApiKeyMasspaymentTransfersPost(response: ResponseContext): Promise { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body: MasspaymentTransfersResponse = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "MasspaymentTransfersResponse", "" ) as MasspaymentTransfersResponse; 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: MasspaymentTransfersResponse = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "MasspaymentTransfersResponse", "" ) as MasspaymentTransfersResponse; return body; } let body = response.body || ""; throw new ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } }