Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 16x 16x 16x 16x 3x 1x 1x 1x 1x 1x 2x 1x 1x 1x 1x | import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
import { ABaseBatch } from './ABaseBatch';
export const NAME = 'journal-list';
export default class JournalList extends ABaseBatch<IInput> {
public getName(): string {
return NAME;
}
protected getMethod(): string {
return 'getJournalList';
}
// eslint-disable-next-line @typescript-eslint/require-await
protected async getParameters(
dto: BatchProcessDto<IInput>,
_page: number,
_lastRun?: Date|number,
): Promise<object> {
const { lastLogId, logsTypes, orderId } = dto.getJsonData();
const lastLog = Number((lastLogId ?? _lastRun) ?? 0);
/* eslint-disable @typescript-eslint/naming-convention */
return {
last_log_id: lastLog + 1,
logs_types: logsTypes,
order_id: orderId,
};
/* eslint-enable @typescript-eslint/naming-convention */
}
protected prepareLastRun(lastRun: string|null|undefined): Date|number|undefined {
return lastRun ? Number(lastRun) : undefined;
}
// eslint-disable-next-line @typescript-eslint/require-await
protected async processOutputData(dto: BatchProcessDto, body: IOutput): Promise<BatchProcessDto> {
Object.values(body.logs).forEach((log) => {
dto.addItem(log);
});
return dto;
}
protected hasNextPage(_jsonBody: IOutput): boolean {
return false;
}
protected getNewLastRun(_jsonBody: IOutput, _lastRun?: string): string {
const lastLog = Object.values(_jsonBody.logs).pop();
return String(lastLog?.log_id ?? _lastRun ?? 0);
}
}
export interface IInput {
logsTypes: number[];
lastLogId?: number;
orderId?: number;
}
/* eslint-disable @typescript-eslint/naming-convention */
export interface Log {
log_id: number;
log_type: number;
order_id: number;
object_id: number;
date: number;
}
export interface IOutput {
logs: Record<string, Log>
}
/* eslint-enable @typescript-eslint/naming-convention */
|