fix(core): update
This commit is contained in:
parent
15889699b4
commit
ea16521ca3
22
test/test.ts
22
test/test.ts
@ -65,4 +65,26 @@ tap.test('should get all tasks for a project', async () => {
|
|||||||
tasks.forEach(taskArg => console.log(taskArg.title));
|
tasks.forEach(taskArg => console.log(taskArg.title));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should get a milestone', async () => {
|
||||||
|
const organizations = await oraInstance.getOrganizations();
|
||||||
|
const losslessOrganization = organizations.find(orgArg => {
|
||||||
|
return orgArg.name.startsWith('Lossless');
|
||||||
|
});
|
||||||
|
const projectsInLosslessOrg = await losslessOrganization.getProjects();
|
||||||
|
const featureProjects = projectsInLosslessOrg.filter(oraProjectArg => {
|
||||||
|
return oraProjectArg.title.includes('Feature');
|
||||||
|
});
|
||||||
|
const layerIoProject = featureProjects.find(oraProjectArg =>
|
||||||
|
oraProjectArg.title.includes('layer.io')
|
||||||
|
);
|
||||||
|
const lists = await layerIoProject.getLists();
|
||||||
|
let tasks: ora.OraTask[] = [];
|
||||||
|
for (const list of lists) {
|
||||||
|
tasks = tasks.concat(await list.getTasks());
|
||||||
|
}
|
||||||
|
console.log('the following tasks are available:');
|
||||||
|
const milestone = await tasks[0].getMilestone();
|
||||||
|
expect(milestone).to.be.instanceOf(ora.OraMilestone);
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -3,3 +3,4 @@ export * from './ora.classes.organization';
|
|||||||
export * from './ora.classes.project';
|
export * from './ora.classes.project';
|
||||||
export * from './ora.classes.list';
|
export * from './ora.classes.list';
|
||||||
export * from './ora.classes.task';
|
export * from './ora.classes.task';
|
||||||
|
export * from './ora.classes.milestone';
|
||||||
|
47
ts/ora.classes.milestone.ts
Normal file
47
ts/ora.classes.milestone.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import * as plugins from './ora.plugins';
|
||||||
|
import { OraProject } from './ora.classes.project';
|
||||||
|
|
||||||
|
export interface IOraMilestone {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
archived: boolean;
|
||||||
|
complete: boolean;
|
||||||
|
deadline: string;
|
||||||
|
color: string;
|
||||||
|
position: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class OraMilestone implements IOraMilestone {
|
||||||
|
// ======
|
||||||
|
// STATIC
|
||||||
|
// ======
|
||||||
|
public static async getAllMilestonesForProject(oraProjectArg: OraProject) {
|
||||||
|
const response = await oraProjectArg.oraOrganizationRef.oraRef.request(`/projects/${oraProjectArg.id}/milestones`, 'GET');
|
||||||
|
const milestones: OraMilestone[] = [];
|
||||||
|
for (const dataObject of response.data) {
|
||||||
|
milestones.push(new OraMilestone(oraProjectArg, dataObject));
|
||||||
|
}
|
||||||
|
return milestones;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========
|
||||||
|
// INSTANCE
|
||||||
|
// ========
|
||||||
|
public id: number;
|
||||||
|
public title: string;
|
||||||
|
public created_at: string;
|
||||||
|
public updated_at: string;
|
||||||
|
public archived: boolean;
|
||||||
|
public complete: boolean;
|
||||||
|
public deadline: string;
|
||||||
|
public color: string;
|
||||||
|
public position: number;
|
||||||
|
|
||||||
|
public oraProjectRef: OraProject;
|
||||||
|
constructor(oraProjectRef: OraProject, creationObjectArg: IOraMilestone) {
|
||||||
|
this.oraProjectRef = oraProjectRef;
|
||||||
|
Object.assign(this, creationObjectArg);
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ import * as plugins from './ora.plugins';
|
|||||||
import { Ora } from './ora.classes.ora';
|
import { Ora } from './ora.classes.ora';
|
||||||
import { OraOrganization } from './ora.classes.organization';
|
import { OraOrganization } from './ora.classes.organization';
|
||||||
import { OraList } from './ora.classes.list';
|
import { OraList } from './ora.classes.list';
|
||||||
|
import { OraMilestone } from './ora.classes.milestone';
|
||||||
|
|
||||||
export interface IOraProject {
|
export interface IOraProject {
|
||||||
archived: boolean;
|
archived: boolean;
|
||||||
@ -81,4 +82,8 @@ export class OraProject implements IOraProject {
|
|||||||
public async getLists(): Promise<OraList[]> {
|
public async getLists(): Promise<OraList[]> {
|
||||||
return OraList.getAllLists(this);
|
return OraList.getAllLists(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getMileStones(): Promise<OraMilestone[]> {
|
||||||
|
return OraMilestone.getAllMilestonesForProject(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as plugins from './ora.plugins';
|
import * as plugins from './ora.plugins';
|
||||||
import { OraList } from './ora.classes.list';
|
import { OraList } from './ora.classes.list';
|
||||||
|
import { OraMilestone } from './ora.classes.milestone';
|
||||||
|
|
||||||
export interface IOraTask {
|
export interface IOraTask {
|
||||||
milestone_id: number;
|
milestone_id: number;
|
||||||
@ -92,4 +93,8 @@ export class OraTask implements IOraTask {
|
|||||||
this.oraListRef = oraListRefArg;
|
this.oraListRef = oraListRefArg;
|
||||||
Object.assign(this, creationObjectArg);
|
Object.assign(this, creationObjectArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getMilestone (): Promise<OraMilestone> {
|
||||||
|
return (await this.oraListRef.oraProjectObjectRef.getMileStones()).find(milestoneArg => milestoneArg.id === this.milestone_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user