UNPKG

@iletimerkezi/iletimerkezi-node

Version:
44 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReportService = void 0; const ReportResponse_1 = require("../responses/ReportResponse"); class ReportService { constructor(httpClient, apiKey, apiHash) { this.httpClient = httpClient; this.apiKey = apiKey; this.apiHash = apiHash; this.lastOrderId = null; this.lastPage = 1; this.rowCount = 1000; } /** * Get report for a specific order */ async get(orderId, page = 1) { this.lastOrderId = orderId; this.lastPage = page; const payload = { request: { authentication: { key: this.apiKey, hash: this.apiHash, }, order: { id: orderId, page: page, rowCount: this.rowCount } }, }; const response = await this.httpClient.post('get-report/json', payload); return new ReportResponse_1.ReportResponse(response.getBody(), response.getStatusCode(), page); } async next() { if (!this.lastOrderId || !this.lastPage) { throw new Error('No previous request found. Call list() first.'); } return this.get(this.lastOrderId, this.lastPage + 1); } } exports.ReportService = ReportService; //# sourceMappingURL=ReportService.js.map