All files / src/Batch PohodaGetAddressBookListBatch.ts

100% Statements 18/18
75% Branches 3/4
100% Functions 5/5
100% Lines 18/18

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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 11318x 18x   18x   18x   18x 18x 18x 18x     18x     18x       1x       1x         1x 1x   1x 1x   1x   1x                                                                                                                                                      
import { checkErrorInResponse, NAME as APPLICATION_NAME, ResponseState } from '../PohodaApplication';
import APohodaListBatch from './APohodaListBatch';
 
export const NAME = `${APPLICATION_NAME}-get-address-book-list-batch`;
 
export const LAST_RUN_KEY = 'addressBook';
 
export enum Filter {
    LAST_CHANGES = 'lastChanges',
    DATE_FROM = 'dateFrom',
    COMPANY = 'company',
}
 
export default class PohodaGetAddressBookListBatch extends APohodaListBatch<unknown, IOutput, Filter> {
 
    public getName(): string {
        return NAME;
    }
 
    protected getKey(): string {
        return LAST_RUN_KEY;
    }
 
    protected getSchema(): string {
        return 'http://www.stormware.cz/schema/version_2/list_addBook.xsd';
    }
 
    // @ts-expect-error Intentionally
    protected getItems(response: IResponse): IOutput[] {
        const { responsePack } = response;
        checkErrorInResponse(responsePack);
 
        const { responsePackItem } = responsePack;
        checkErrorInResponse(responsePackItem);
 
        const { listAddressBook } = responsePackItem;
 
        return listAddressBook.addressbook ?? [];
    }
 
}
 
export interface IOutput {
    addressbookHeader: {
        id: number;
        identity: {
            address: {
                company: string;
                division: string;
                name: string;
                city: string;
                street: string;
                zip: string;
                ico: number;
                dic: string;
            };
        };
        region: string;
        phone: string;
        mobil: string;
        fax: string;
        email: string;
        web: string;
        adGroup: string;
        adKey: string;
        credit: number;
        priceIDS: string;
        maturity: number;
        paymentType: {
            id: number;
            ids: string;
            paymentType: string;
        };
        number: {
            id: number;
            ids: string;
            numberRequested: string;
        };
        foreignCurrency: {
            id: number;
            ids: string;
        };
        p1: boolean;
        p2: boolean;
        p3: boolean;
        p4: boolean;
        p5: boolean;
        p6: boolean;
    };
    addressbookAccount: {
        accountItem: {
            id: number;
            accountNumber: string;
            symSpec: string;
            bankCode: number;
            defaultAccount: boolean;
        };
    };
    version: number;
}
 
interface IResponse {
    responsePack: {
        responsePackItem: {
            listAddressBook: {
                addressbook: IOutput[];
            };
        };
        state: ResponseState;
        note: string;
    };
}