All files / src/Connector Orders.ts

100% Statements 7/7
100% Branches 0/0
100% Functions 3/3
100% Lines 7/7

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  16x   16x   16x     16x       1x                                 1x     1x                                                                                                                                                                                                                                        
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
import ABaseConnector from './ABaseConnector';
 
export const NAME = 'orders';
 
export default class Orders extends ABaseConnector<IInput, IOutput> {
 
    public getName(): string {
        return NAME;
    }
 
    protected getMethod(): string {
        return 'getOrders';
    }
 
    // eslint-disable-next-line @typescript-eslint/require-await
    protected async getParameters(dto: ProcessDto<IInput>): Promise<object> {
        const {
            orderId,
            dateConfirmedFrom,
            dateFrom,
            idFrom,
            getUnconfirmedOrders,
            includeCustomExtraFields,
            statusId,
            filterEmail,
            filterOrderSource,
            filterOrderSourceId,
            withCommission,
        } = dto.getJsonData();
 
        /* eslint-disable @typescript-eslint/naming-convention */
        return {
            order_id: orderId,
            date_confirmed_from: dateConfirmedFrom,
            date_from: dateFrom,
            id_from: idFrom,
            get_unconfirmed_orders: getUnconfirmedOrders,
            include_custom_extra_fields: includeCustomExtraFields,
            status_id: statusId,
            filter_email: filterEmail,
            filter_order_source: filterOrderSource,
            filter_order_source_id: filterOrderSourceId,
            with_commission: withCommission,
        };
        /* eslint-enable @typescript-eslint/naming-convention */
    }
 
}
 
export interface IInput {
    orderId?: number;
    dateConfirmedFrom?: number;
    dateFrom?: number;
    idFrom?: number;
    getUnconfirmedOrders?: boolean;
    includeCustomExtraFields?: boolean;
    statusId?: number;
    filterEmail?: string;
    filterOrderSource?: string;
    filterOrderSourceId?: number;
    withCommission?: boolean;
}
 
/* eslint-disable @typescript-eslint/naming-convention */
export interface Order {
    order_id: number;
    shop_order_id: number;
    external_order_id: string;
    order_source: string;
    order_source_id: number;
    order_source_info: string;
    order_status_id: number;
    date_add: number;
    date_confirmed: number;
    date_in_status: number;
    user_login: string;
    phone: string;
    email: string;
    user_comments: string;
    admin_comments: string;
    currency: string;
    payment_method: string;
    payment_method_cod: string;
    payment_done: string;
    delivery_method: string;
    delivery_price: number;
    delivery_package_module: string;
    delivery_package_nr: string;
    delivery_fullname: string;
    delivery_company: string;
    delivery_address: string;
    delivery_city: string;
    delivery_state: string;
    delivery_postcode: string;
    delivery_country: string;
    delivery_country_code: string;
    delivery_point_id: string;
    delivery_point_name: string;
    delivery_point_address: string;
    delivery_point_postcode: string;
    delivery_point_city: string;
    invoice_fullname: string;
    invoice_company: string;
    invoice_nip: string;
    invoice_address: string;
    invoice_city: string;
    invoice_state: string;
    invoice_postcode: string;
    invoice_country: string;
    invoice_country_code: string;
    want_invoice: string;
    extra_field_1: string;
    extra_field_2: string;
    custom_extra_fields: Record<string, string>;
    order_page: string;
    pick_status: string;
    pack_status: string;
    commission: {
        net: number;
        gross: number;
        currency: string;
    },
    products:
    {
        storage: string;
        storage_id: number;
        order_product_id: number;
        product_id: string;
        variant_id: number;
        name: string;
        attributes: string;
        sku: string;
        ean: string;
        location: string;
        auction_id: string;
        price_brutto: number;
        tax_rate: number;
        quantity: number;
        weight: number;
        bundle_id: number;
    }[]
}
/* eslint-enable @typescript-eslint/naming-convention */
 
export interface IOutput {
    orders: Order[]
}