All files / src/Connector MailstepSendExpeditionConnector.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 2/2
100% Lines 11/11

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 184 185 186 18722x 22x   22x 22x   22x   22x     22x       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 { StatusCodes } from 'http-status-codes';
import { getErrorInResponse, NAME as APPLICATION_NAME } from '../MailstepApplication';
 
export const NAME = `${APPLICATION_NAME}-send-expedition-connector`;
 
export default class MailstepSendExpeditionConnector extends AConnector {
 
    public getName(): string {
        return NAME;
    }
 
    public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
        const { id } = dto.getJsonData();
 
        const requestDto = await this.getApplication().getRequestDto(
            dto,
            await this.getApplicationInstallFromProcess(dto),
            HttpMethods.PUT,
            `expedition/${id}/send`,
        );
 
        const responseDto = await this.getSender().send<IOutput>(requestDto, {
            success: StatusCodes.OK,
            stopAndFail: [StatusCodes.NOT_FOUND, StatusCodes.GONE],
        }, undefined, undefined, getErrorInResponse);
 
        return dto.setNewJsonData(responseDto.getJsonBody());
    }
 
}
 
export interface IInput {
    id: string;
}
 
export interface IOutput {
    /* eslint-disable @typescript-eslint/naming-convention */
    id: string;
    eshop: string;
    warehouse: string;
    wms: string;
    orderNumber: string;
    carrier: string;
    carrierService: string;
    status: string;
    value: string;
    currency: string;
    user?: string;
    partner?: string;
    note?: string;
    billingFirstName?: string;
    billingLastName?: string;
    billingDegree?: string;
    billingCompany?: string;
    billingStreet?: string;
    billingHouseNr?: string;
    billingZip?: number;
    billingCity?: string;
    billingCountry?: string;
    billingState?: string;
    billingEmail?: string;
    billingPhone?: string;
    billingRegistrationNumber?: number;
    billingVatNumber?: string;
    differentDeliveryAddress?: boolean;
    deliveryFirstName?: string;
    deliveryLastName?: string;
    deliveryDegree?: string;
    deliveryCompany?: string;
    deliveryStreet?: string;
    deliveryHouseNr?: string;
    deliveryZip?: number;
    deliveryCity?: string;
    deliveryCountry?: string;
    deliveryState?: string;
    deliveryEmail?: string;
    deliveryPhone?: string;
    requiredExpeditionDate?: string;
    carrierPickupPlace?: string;
    carrierPickupPlaceCode?: string;
    externalCarrierPickupPlace?: string;
    externalCarrierPickupPlaceCode?: string;
    carrierNote?: string;
    trackingNumber?: string;
    trackingUrl?: string;
    genericTrackingUrl?: string;
    externalTrackingNumber?: string;
    externalPackageNumber?: string;
    packagesCount?: number;
    expeditedCompletely?: boolean;
    fragile?: boolean;
    cod?: boolean;
    codValue?: number;
    codCurrency?: string;
    codVariableSymbol?: string;
    customerGroup?: string;
    invoice?: {
        name?: string;
        originalName?: string;
        mimeType?: string;
        size?: number;
    };
    eshopOrderDate?: string;
    createdAt?: string;
    items?: {
        id: string;
        product: string;
        expedition: string;
        position?: number;
        bookStockAdvices?: {
            id: string;
            createdAt?: string;
            stockAdviceItem?: string;
            quantity?: number;
        }[];
        expedited?: number;
        productValue?: number;
        productValueCurrency?: string;
        productLabel?: string;
        quantity?: number;
        booked?: number;
        missing?: number;
        lot?: string;
        assignedLot?: string;
        lifo?: boolean;
        ref1?: string;
        ref2?: string;
        ref3?: string;
        createdAt?: string;
        changedAt?: string;
    }[];
    audits?: {
        id: string;
        statusTo: string;
        createdAt?: string;
        updatedBy?: string;
    }[];
    countOfItems?: number;
    countOfSku?: number;
    sumOfQuantity?: number;
    errors?: {
        message: string;
        propertyPath: string;
        code: string;
        parameters: {
            '{{ value }}'?: string;
        }
    }[];
    packedAt?: string;
    sentAt?: string;
    deliveredAt?: string;
    waitBeforeProcessing?: boolean;
    editBeforeProcessing?: boolean;
    priority?: number;
    ref1?: string;
    ref2?: string;
    ref3?: string;
    foreignPrice?: {
        amount: number;
        currency: string;
    };
    conversionDate?: string;
    modifiedAt?: string;
    removedVirtualProducts?: {
        productId?: string;
        quantity?: number;
    }[];
    ignoreAddressValidation?: boolean;
    addressValidationExecuted?: boolean;
    b2b?: boolean;
    carrierOptions?: {
        recipientIdentificationNumber?: string;
    };
    deliveryCost?: number;
    deliveryCostCurrency?: string;
    invoiceNumber?: string;
    services?: string[];
    changedAt?: string;
    invoiceUrl?: string;
    invoiceOriginalName?: string;
    withComplaint?: string;
    /* eslint-enable @typescript-eslint/naming-convention */
}