UNPKG

@iletimerkezi/iletimerkezi-node

Version:
42 lines 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SummaryService = void 0; const SummaryResponse_1 = require("../responses/SummaryResponse"); class SummaryService { constructor(httpClient, apiKey, apiHash) { this.httpClient = httpClient; this.apiKey = apiKey; this.apiHash = apiHash; this.lastStartDate = ''; this.lastEndDate = ''; this.lastPage = 1; } async list(startDate, endDate, page = 1) { this.lastStartDate = startDate; this.lastEndDate = endDate; this.lastPage = page; const payload = { request: { authentication: { key: this.apiKey, hash: this.apiHash, }, filter: { start: startDate, end: endDate, page: page } } }; const response = await this.httpClient.post('get-reports/json', payload); return new SummaryResponse_1.SummaryResponse(response.getBody(), response.getStatusCode(), page); } async next() { if (!this.lastStartDate || !this.lastEndDate) { throw new Error('No previous request found. Call list() first.'); } return this.list(this.lastStartDate, this.lastEndDate, this.lastPage + 1); } } exports.SummaryService = SummaryService; //# sourceMappingURL=SummaryService.js.map