All files / src/Batch JamesAndJamesGetOrders.ts

100% Statements 10/10
50% Branches 1/2
100% Functions 2/2
100% Lines 10/10

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 1158x 8x     8x   8x     8x       1x 1x   1x           1x   1x                                                                                                                                                                                    
import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
 
export const NAME = 'james-and-james-get-orders';
 
export default class JamesAndJamesGetOrders extends ABatchNode {
 
    public getName(): string {
        return NAME;
    }
 
    public async processAction(dto: BatchProcessDto<IInput>): Promise<BatchProcessDto<IOutput[]>> {
        const { status } = dto.getJsonData();
        const url = status ? `?statuses[]=${status}` : '';
 
        const req = await this.getApplication().getRequestDto(
            dto,
            await this.getApplicationInstallFromProcess(dto),
            HttpMethods.GET,
            `order${url}`,
        );
        const resp = await this.getSender().send<IResponse>(req, [200]);
 
        return dto.setItemList(resp.getJsonBody().data) as BatchProcessDto<IOutput[]>;
    }
 
}
 
export interface IInput {
    status?: string;
}
 
/* eslint-disable @typescript-eslint/naming-convention */
export interface IOutput {
    id: number;
    brand_id: number;
    type: string;
    status: string;
    fulfilment_status: string;
    incoterm: string;
    reference: string;
    date_placed: string;
    postage_speed: number;
    allow_saturday: boolean;
    signed_for: boolean;
    no_signature: boolean;
    tracked: boolean;
    postage_cost: number;
    currency_code: string;
    tissue_wrap: boolean;
    days_before_bbe: number;
    callback_url:string;
    warehouse_id: number;
    shipping_contact: {
        name: string;
        company: string;
        email: string;
        phone: string;
        address_line_1: string;
        address_line_2: string;
        city: string;
        county: string;
        country: string;
        postcode: string;
    },
    billing_contact: {
        name: string;
        company: string;
        email: string;
        phone: string;
        address_line_1: string;
        address_line_2: string;
        city: string;
        county: string;
        country: string;
        postcode: string;
    },
    total_value: number;
    date_labelled: string;
    date_despatched: string;
    shipping_info: {
        carrier_name: string;
        service_name: string;
        tracking_numbers: string[];
        tracking_links: null,
        branded_tracking_link: string;
        tracking_events:
        {
            title: string;
            date_created: string;
            status: string;
            domain: string;
        }[];
        tracking_events_updated_at: string;
    },
    items:
    {
        id: number;
        product_id: number;
        quantity: number;
        price: number;
        line_reference: string,
        days_before_bbe: number;
        customisation_data: string,
        batch_id: number;
    }[];
}
 
export interface IResponse {
    data: IOutput[];
}
 
/* eslint-enable @typescript-eslint/naming-convention */