import ProcessDto from '../../lib/Utils/ProcessDto'; import RequestDto from '../../lib/Transport/Curl/RequestDto'; import HttpMethods from '../../lib/Transport/HttpMethods'; import OnRepeatException from '../../lib/Exception/OnRepeatException'; import AConnector from '../../lib/Connector/AConnector'; import { ApplicationInstall } from '../../lib/Application/Database/ApplicationInstall'; export default class TestConnector extends AConnector { public getName = (): string => 'test'; public async getApplicationInstallFromHeaders(dto: ProcessDto): Promise { return this._getApplicationInstallFromHeaders(dto); } public async processAction(_dto: ProcessDto): Promise { const dto = _dto; dto.jsonData = { test: 'ok', processed: Date.now() .toString(), }; await Promise.all( [1, 2, 3].map(async () => { const requestDto = new RequestDto('https://jsonplaceholder.typicode.com/users', HttpMethods.GET, _dto, '', { custom: 'header' }); requestDto.debugInfo = dto; const responseDto = await this._sender.send(requestDto); if (responseDto.responseCode !== 200 && responseDto.responseCode !== 201) { throw new OnRepeatException(); } dto.data = responseDto.body; }), ); return dto; } }