All files / src/Batch RecruiteeGetOffersBatch.ts

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

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 1012x 2x 2x   2x   2x   2x     2x       1x 1x 1x           1x 1x   1x 1x   1x                                                                                                                                              
import CoreFormsEnum from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
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';
import { YOUR_COMPANY } from '../RecruiteeApplication';
 
export const NAME = 'recruitee-get-offers-batch';
 
export default class RecruiteeGetOffersBatch extends ABatchNode {
 
    public getName(): string {
        return NAME;
    }
 
    public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
        const appInstall = await this.getApplicationInstallFromProcess(dto);
        const yourCompany = appInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM][YOUR_COMPANY];
        const req = await this.getApplication().getRequestDto(
            dto,
            appInstall,
            HttpMethods.GET,
            `${yourCompany}.recruitee.com/api/offers/`,
        );
        const resp = await this.getSender().send<IResponse>(req, [200]);
        const response = resp.getJsonBody();
 
        dto.setItemList(response.offers ?? []);
        dto.removeBatchCursor();
 
        return dto;
    }
 
}
 
/* eslint-disable @typescript-eslint/naming-convention */
 
interface IResponse {
    offers: IOutput[];
}
 
export interface IOutput {
    id: number;
    slug: string;
    position: number;
    status: string;
    options_phone: string;
    options_photo: string;
    options_cover_letter: string;
    options_cv: string;
    remote: boolean;
    country_code: string;
    state_code: string;
    postal_code: string;
    min_hours: number;
    max_hours: number;
    title: string;
    description: string;
    requirements: string;
    location: string;
    city: string;
    country: string;
    careers_url: string;
    careers_apply_url: string;
    company_name: string;
    department: string;
    created_at: string;
    updated_at: string;
    published_at: string;
    close_at: string;
    employment_type_code: string;
    category_code: string;
    experience_code: string;
    education_code: string;
    tags: string[];
    translations: {
        en: {
            title: string;
            description: string;
            requirements: string;
        };
    };
    open_questions: {
        id: number;
        kind: string;
        required: boolean;
        position: number;
        body: string;
        translations: {
            en: {
                body: string;
            };
        };
        open_question_options: [];
        options: {
            length: number;
        };
    }[];
}
 
/* eslint-enable @typescript-eslint/naming-convention */