All files / src/Connector JiraGetWorklogsConnector.ts

86.66% Statements 13/15
50% Branches 1/2
100% Functions 2/2
86.66% Lines 13/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 645x 5x   5x   5x   5x   5x     5x       1x 1x   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 ResultCode from '@orchesty/nodejs-sdk/dist/lib/Utils/ResultCode';
 
export const JIRA_GET_WORKLOGS_ENDPOINT = '/rest/api/3/worklog/list';
 
export const NAME = 'jira-get-worklogs';
 
export default class JiraGetWorklogsConnector extends AConnector {
 
    public getName(): string {
        return NAME;
    }
 
    public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto> {
        const appInstall = await this.getApplicationInstallFromProcess(dto);
        const { ids } = dto.getJsonData();
 
        Iif (!ids) {
            dto.setStopProcess(ResultCode.STOP_AND_FAILED, 'Connector is missing required data: "ids".');
            return dto;
        }
 
        const request = await this.getApplication().getRequestDto(
            dto,
            appInstall,
            HttpMethods.POST,
            JIRA_GET_WORKLOGS_ENDPOINT,
            { ids },
        );
        const response = await this.getSender().send<IOutput>(request);
        return dto.setData(response.getBody());
    }
 
}
 
export interface IInput {
    ids: number[];
}
 
export interface IOutput {
    author: Author;
    created: string;
    id: string;
    issueId: string;
    self: string;
    started: string;
    timeSpent: string;
    timeSpentSeconds: number;
    updateAuthor: Author;
    updated: string;
}
 
export interface Author {
    accountId: string;
    accountType: string;
    active: boolean;
    avatarUrls: Record<string, string>;
    displayName: string;
    self: string;
    timeZone: string;
}