All files / src/Connector MoneyS4-5GetCompanies.ts

100% Statements 17/17
100% Branches 2/2
100% Functions 5/5
100% Lines 17/17

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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 1843x 3x       3x   3x   3x     3x       2x 2x   2x 2x 2x 2x       2x       1x   1x 1x     1x                                                                                                                                                                                                                                                                                                      
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
import MoneyS45Base from '../MoneyS45Base';
 
const MONEYS4_GET_COMPANIES = 'v2.0/Company';
 
export const NAME = 'moneys4-get-companies';
 
export default class MoneyS45GetCompanies extends AConnector {
 
    public getName(): string {
        return NAME;
    }
 
    public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IResponse>> {
        const app = this.getApplication<MoneyS45Base>();
        const { filters } = dto.getJsonData();
 
        const appInstall = await this.getApplicationInstallFromProcess(dto);
        const requestDto = await app.getRequestDto(dto, appInstall, HttpMethods.GET, `${MONEYS4_GET_COMPANIES}${filters ? this.prepareFilters(filters) : ''}`);
        const response = await this.getSender().send<IResponse>(requestDto, 200);
        return this.setJsonData<IResponse>(dto, response.getJsonBody());
    }
 
    protected setJsonData<T>(dto: ProcessDto, response: T): ProcessDto<T> {
        return dto.setNewJsonData(response);
    }
 
    private prepareFilters(filters: IFilter[]): string {
        const outputFilters: string[] = [];
 
        filters.forEach((filter) => {
            outputFilters.push(`${filter.PropertyName}~${filter.Operation}~${filter.ExpectedValue}`);
        });
 
        return `?filter=${outputFilters.join('#')}`;
    }
 
}
 
/* eslint-disable @typescript-eslint/naming-convention */
export interface IInput {
    filters?: IFilter[];
}
 
interface IFilter {
    PropertyName: string;
    Operation: string;
    ExpectedValue: number | string;
}
 
/* eslint-enable @typescript-eslint/naming-convention */
 
/* eslint-disable @typescript-eslint/naming-convention */
export interface IResponse {
    PageCount: number;
    RowCount: number;
    Data: ICompany[];
    Status: number;
    Message: string;
    StackTrace: string;
}
 
export interface ICompany {
    CiselnaRada_ID?: string;
    CisloS3?: number;
    CisloZRady?: number;
    DatumPosty?: string;
    DIC?: string;
    Email?: string;
    FyzickaOsoba?: boolean;
    HlavniUcet_ID?: string;
    HodnotaKreditu?: number;
    HodnotaSlevy?: number;
    ICO?: string;
    Kod?: string;
    KodDanovehoUradu?: string;
    Nazev?: string;
    PosilatPostu?: boolean;
    PosledniCisloOsoby?: number;
    PouzivatKredit?: boolean;
    Poznamka?: string;
    PrevzitBankovniSpojeni?: boolean;
    PrevzitObchodniPodminky?: boolean;
    PrevzitObchodniUdaje?: boolean;
    SpecifickySymbol?: string;
    SplatnostPohledavek?: number;
    SplatnostZavazku?: number;
    Spojeni?: string;
    Tel1Cislo?: string;
    Tel1Klapka?: string;
    Tel1MistniCislo?: string;
    Tel1Predvolba?: string;
    Tel1Typ?: number;
    Tel2Cislo?: string;
    Tel2Klapka?: string;
    Tel2MistniCislo?: string;
    Tel2Predvolba?: string;
    Tel2Typ?: number;
    Tel3Cislo?: string;
    Tel3Klapka?: string;
    Tel3MistniCislo?: string;
    Tel3Predvolba?: string;
    Tel3Typ?: number;
    Tel4Cislo?: string;
    Tel4Klapka?: string;
    Tel4MistniCislo?: string;
    Tel4Predvolba?: string;
    Tel4Typ?: number;
    VariabilniSymbol?: string;
    VlastniSleva?: boolean;
    VlastniSplatnostPohledavek?: boolean;
    VlastniSplatnostZavazku?: boolean;
    WWW?: string;
    Zprava?: string;
    FaktMisto?: string;
    FaktNazev?: string;
    FaktPsc?: string;
    FaktStat?: string;
    FaktUlice?: string;
    ObchMisto?: string;
    ObchNazev?: string;
    ObchPsc?: string;
    ObchStat?: string;
    ObchUlice?: string;
    ProvMisto?: string;
    ProvNazev?: string;
    ProvPsc?: string;
    ProvStat?: string;
    ProvUlice?: string;
    FaktStat_ID?: string;
    ObchStat_ID?: string;
    ProvStat_ID?: string;
    OdlisnaAdresaProvozovny?: boolean;
    OdlisnaFakturacniAdresa?: boolean;
    UvadetNaDokladech?: boolean;
    PlatceDPH?: boolean;
    Tel1PredvolbaStat?: string;
    Tel2PredvolbaStat?: string;
    Tel3PredvolbaStat?: string;
    Tel4PredvolbaStat?: string;
    ICDPH?: string;
    ZpusobVyberuCeny?: number;
    EkoKomKlient?: boolean;
    DatumKontrolyDleIC?: string;
    DatumKontolyDIC?: string;
    DatovaSchrankaID?: string;
    DatovaSchrankaNazev?: string;
    DatumUkonceniCinnosti?: string;
    CinnostUkoncena?: boolean;
    VcetnePodrizenych?: boolean;
    FaxCislo?: string;
    FaxKlapka?: string;
    FaxMistniCislo?: string;
    FaxPredvolba?: string;
    FaxPredvolbaStat?: string;
    Attachments?: boolean;
    GpsLat?: number;
    GpsLong?: number;
    EmailSpojeni_ID?: string;
    FaxSpojeni_ID?: string;
    TelefonSpojeni1_ID?: string;
    TelefonSpojeni2_ID?: string;
    PrenestNazev?: boolean;
    ObchodniPodminkyDistributorLihu?: boolean;
    ObchodniPodminkyDistributorLihuRegistracniCislo?: string;
    DatumPosledniKontrolyPlatceDPH?: string;
    StavPlatceDPHVracenyWS_Stav?: number;
    UctyNactenyZRegistruDPH?: boolean;
    StavPlatceDPHComputed?: number;
    AttachmentsList?: unknown[];
    IsNew?: boolean;
    Hidden?: boolean;
    ID?: string;
    Group_ID?: string;
    Deleted?: boolean;
    Locked?: boolean;
    Create_ID?: string;
    Create_Date?: string;
}
 
/* eslint-enable @typescript-eslint/naming-convention */