All files / src/Batch APohodaGetParameterListBatch.ts

95.23% Statements 20/21
100% Branches 4/4
85.71% Functions 6/7
95.23% Lines 20/21

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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95  18x 18x   18x 18x 18x     18x                 1x       1x         1x 1x   1x 1x   1x 1x   1x   1x   1x               1x                                               18x 18x                                          
import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
import { checkErrorInResponse, ResponseState } from '../PohodaApplication';
import APohodaListBatch from './APohodaListBatch';
 
export enum Filter {
    LAST_CHANGES = 'lastChanges',
    DATE_FROM = 'dateFrom',
}
 
export default abstract class APohodaGetParameterListBatch extends APohodaListBatch<
    unknown,
    IOutput,
    Filter
> {
 
    protected abstract getType(): ParameterType;
 
    protected getKey(): string {
        return 'parameter';
    }
 
    protected getSchema(): string {
        return 'http://www.stormware.cz/schema/version_2/list.xsd';
    }
 
    // @ts-expect-error Intentionally
    protected getItems(response: IResponse): IOutput[] {
        const { responsePack } = response;
        checkErrorInResponse(responsePack);
 
        const { responsePackItem } = responsePack;
        checkErrorInResponse(responsePackItem);
 
        const { listParameter } = responsePackItem;
        checkErrorInResponse(listParameter);
 
        const { parameter } = listParameter;
 
        const { formParameter, itemParameter } = parameter;
 
        return [
            ...formParameter.parameterDef,
            ...itemParameter.parameterDef,
        ];
    }
 
    // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/require-await
    protected async getCustomRequestAttributes(dto: BatchProcessDto): Promise<object> {
        return {
            '@_idsAgenda': this.getType(),
        };
    }
 
    // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/require-await
    protected async getLastRunKey(dto: BatchProcessDto): Promise<string> {
        return this.getType();
    }
 
}
 
export interface IOutput {
    id: number;
    type: string;
    name: string;
    label: string;
    length?: number;
    list?: {
        id: number;
        ids: string;
    };
}
 
export enum ParameterType {
    ORDER = 'objednavky',
}
 
interface IResponse {
    responsePack: {
        responsePackItem: {
            listParameter: {
                parameter: {
                    formParameter: {
                        parameterDef: IOutput[];
                    };
                    itemParameter: {
                        parameterDef: IOutput[];
                    };
                };
            };
        };
        state: ResponseState;
        note: string;
    };
}