fix(core): update
This commit is contained in:
parent
273821b732
commit
765e56076d
@ -36,4 +36,4 @@
|
|||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
]
|
]
|
||||||
}
|
}
|
35
test/test.ts
35
test/test.ts
@ -30,8 +30,39 @@ tap.test('should get all lists for a project', async () => {
|
|||||||
});
|
});
|
||||||
const projectsInLosslessOrg = await losslessOrganization.getProjects();
|
const projectsInLosslessOrg = await losslessOrganization.getProjects();
|
||||||
const featureProjects = projectsInLosslessOrg.filter(oraProjectArg => {
|
const featureProjects = projectsInLosslessOrg.filter(oraProjectArg => {
|
||||||
return oraProjectArg.title
|
return oraProjectArg.title.includes('Feature');
|
||||||
})
|
});
|
||||||
|
|
||||||
|
console.log('The following Feature Boards are available:');
|
||||||
|
featureProjects.forEach(oraProjectArg => console.log(oraProjectArg.title));
|
||||||
|
const layerIoProject = featureProjects.find(oraProjectArg =>
|
||||||
|
oraProjectArg.title.includes('layer.io')
|
||||||
|
);
|
||||||
|
|
||||||
|
const lists = await layerIoProject.getLists();
|
||||||
|
console.log('\nThe following lists are available');
|
||||||
|
lists.forEach(listArg => console.log(listArg.title));
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should get all tasks for a project', 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:');
|
||||||
|
tasks.forEach(taskArg => console.log(taskArg.title));
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
export * from './ora.classes.ora';
|
export * from './ora.classes.ora';
|
||||||
export * from './ora.classes.organization';
|
export * from './ora.classes.organization';
|
||||||
|
export * from './ora.classes.project';
|
||||||
|
export * from './ora.classes.list';
|
||||||
|
export * from './ora.classes.task';
|
||||||
|
@ -1,12 +1,33 @@
|
|||||||
import * as plugins from './ora.plugins';
|
import * as plugins from './ora.plugins';
|
||||||
import { OraProject } from './ora.classes.project';
|
import { OraProject } from './ora.classes.project';
|
||||||
|
import { OraTask } from './ora.classes.task';
|
||||||
|
|
||||||
export class OraList {
|
/**
|
||||||
|
* the interface for an ora list
|
||||||
|
*/
|
||||||
|
export interface IOraList {
|
||||||
|
actions: number;
|
||||||
|
archived: false;
|
||||||
|
color: string;
|
||||||
|
id: number;
|
||||||
|
list_type: number;
|
||||||
|
position: number;
|
||||||
|
project_id: number;
|
||||||
|
public: boolean;
|
||||||
|
title: string;
|
||||||
|
updated_at: string;
|
||||||
|
view_id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class OraList implements IOraList {
|
||||||
// ======
|
// ======
|
||||||
// STATIC
|
// STATIC
|
||||||
// ======
|
// ======
|
||||||
public static async getAllLists(oraProjectRef: OraProject) {
|
public static async getAllLists(oraProjectRef: OraProject) {
|
||||||
const response = await oraProjectRef.oraOrganizationRef.oraRef.request(`/projects/${oraProjectRef.id}/lists`, 'GET');
|
const response = await oraProjectRef.oraOrganizationRef.oraRef.request(
|
||||||
|
`/projects/${oraProjectRef.id}/lists`,
|
||||||
|
'GET'
|
||||||
|
);
|
||||||
const oraLists: OraList[] = [];
|
const oraLists: OraList[] = [];
|
||||||
for (const dataObject of response.data) {
|
for (const dataObject of response.data) {
|
||||||
oraLists.push(new OraList(oraProjectRef, dataObject));
|
oraLists.push(new OraList(oraProjectRef, dataObject));
|
||||||
@ -17,6 +38,17 @@ export class OraList {
|
|||||||
// ========
|
// ========
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
// ========
|
// ========
|
||||||
|
public actions: number;
|
||||||
|
public archived: false;
|
||||||
|
public color: string;
|
||||||
|
public id: number;
|
||||||
|
public list_type: number;
|
||||||
|
public position: number;
|
||||||
|
public project_id: number;
|
||||||
|
public public: boolean;
|
||||||
|
public title: string;
|
||||||
|
public updated_at: string;
|
||||||
|
public view_id: number;
|
||||||
|
|
||||||
public oraProjectObjectRef: OraProject;
|
public oraProjectObjectRef: OraProject;
|
||||||
|
|
||||||
@ -24,4 +56,8 @@ export class OraList {
|
|||||||
this.oraProjectObjectRef = oraProjectRefArg;
|
this.oraProjectObjectRef = oraProjectRefArg;
|
||||||
Object.assign(this, creationObjectArg);
|
Object.assign(this, creationObjectArg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public async getTasks() {
|
||||||
|
return OraTask.getAllOraTasks(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -9,25 +9,25 @@ export class Ora {
|
|||||||
this.apiToken = apiTokenArg;
|
this.apiToken = apiTokenArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getOrganizations () {
|
public async getOrganizations() {
|
||||||
return await OraOrganization.getAllOrganizations(this);
|
return await OraOrganization.getAllOrganizations(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* make a request
|
* make a request
|
||||||
* @param routeArg
|
* @param routeArg
|
||||||
* @param methodArg
|
* @param methodArg
|
||||||
* @param payloadArg
|
* @param payloadArg
|
||||||
*/
|
*/
|
||||||
public async request (routeArg: string, methodArg: string, payloadArg?: string) {
|
public async request(routeArg: string, methodArg: string, payloadArg?: string) {
|
||||||
const response = await plugins.smartrequest.request(this.apiBase + routeArg, {
|
const response = await plugins.smartrequest.request(this.apiBase + routeArg, {
|
||||||
method: methodArg,
|
method: methodArg,
|
||||||
requestBody: payloadArg,
|
requestBody: payloadArg,
|
||||||
headers: {
|
headers: {
|
||||||
accept: "application/json",
|
accept: 'application/json',
|
||||||
authorization: `Bearer ${this.apiToken}`
|
authorization: `Bearer ${this.apiToken}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return response.body;
|
return response.body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,6 @@ export class OraProject implements IOraProject {
|
|||||||
public view_title: 'Backlog';
|
public view_title: 'Backlog';
|
||||||
public web: string;
|
public web: string;
|
||||||
|
|
||||||
|
|
||||||
public oraOrganizationRef: OraOrganization;
|
public oraOrganizationRef: OraOrganization;
|
||||||
constructor(oraOrganiazionRefArg: OraOrganization, creationObjectArg: IOraProject) {
|
constructor(oraOrganiazionRefArg: OraOrganization, creationObjectArg: IOraProject) {
|
||||||
this.oraOrganizationRef = oraOrganiazionRefArg;
|
this.oraOrganizationRef = oraOrganiazionRefArg;
|
||||||
|
95
ts/ora.classes.task.ts
Normal file
95
ts/ora.classes.task.ts
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
import * as plugins from './ora.plugins';
|
||||||
|
import { OraList } from './ora.classes.list';
|
||||||
|
|
||||||
|
export interface IOraTask {
|
||||||
|
milestone_id: number;
|
||||||
|
task_type: number;
|
||||||
|
creator: number;
|
||||||
|
second_id: number;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
last_picture: string;
|
||||||
|
last_picture_external_url: string;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
deadline: string;
|
||||||
|
archived: boolean;
|
||||||
|
color: string;
|
||||||
|
estimated: string;
|
||||||
|
time_tracked: string;
|
||||||
|
public: boolean;
|
||||||
|
state: string;
|
||||||
|
cover_width: number;
|
||||||
|
cover_height: number;
|
||||||
|
checklist: string;
|
||||||
|
comments: number;
|
||||||
|
public_comments: number;
|
||||||
|
likes: number;
|
||||||
|
attachments: number;
|
||||||
|
commits: number;
|
||||||
|
support_tickets: number;
|
||||||
|
value: number;
|
||||||
|
points: number;
|
||||||
|
points_done: number;
|
||||||
|
sprint_id: number;
|
||||||
|
position: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class OraTask implements IOraTask {
|
||||||
|
// ======
|
||||||
|
// STATIC
|
||||||
|
// ======
|
||||||
|
public static async getAllOraTasks(oraListArg: OraList): Promise<OraTask[]> {
|
||||||
|
const response = await oraListArg.oraProjectObjectRef.oraOrganizationRef.oraRef.request(
|
||||||
|
`/projects/${oraListArg.oraProjectObjectRef.id}/lists/${oraListArg.id}/tasks`,
|
||||||
|
'GET'
|
||||||
|
);
|
||||||
|
const oraTasks: OraTask[] = [];
|
||||||
|
for (const dataObject of response.data) {
|
||||||
|
oraTasks.push(new OraTask(oraListArg, dataObject));
|
||||||
|
}
|
||||||
|
return oraTasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========
|
||||||
|
// INSTANCE
|
||||||
|
// ========
|
||||||
|
public milestone_id: number;
|
||||||
|
public task_type: number;
|
||||||
|
public creator: number;
|
||||||
|
public second_id: number;
|
||||||
|
public title: string;
|
||||||
|
public description: string;
|
||||||
|
public last_picture: string;
|
||||||
|
public last_picture_external_url: string;
|
||||||
|
public created_at: string;
|
||||||
|
public updated_at: string;
|
||||||
|
public deadline: string;
|
||||||
|
public archived: boolean;
|
||||||
|
public color: string;
|
||||||
|
public estimated: string;
|
||||||
|
public time_tracked: string;
|
||||||
|
public public: boolean;
|
||||||
|
public state: string;
|
||||||
|
public cover_width: number;
|
||||||
|
public cover_height: number;
|
||||||
|
public checklist: string;
|
||||||
|
public comments: number;
|
||||||
|
public public_comments: number;
|
||||||
|
public likes: number;
|
||||||
|
public attachments: number;
|
||||||
|
public commits: number;
|
||||||
|
public support_tickets: number;
|
||||||
|
public value: number;
|
||||||
|
public points: number;
|
||||||
|
public points_done: number;
|
||||||
|
public sprint_id: number;
|
||||||
|
public position: number;
|
||||||
|
|
||||||
|
public oraListRef: OraList;
|
||||||
|
|
||||||
|
constructor(oraListRefArg: OraList, creationObjectArg: IOraTask) {
|
||||||
|
this.oraListRef = oraListRefArg;
|
||||||
|
Object.assign(this, creationObjectArg);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,4 @@
|
|||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
|
||||||
export {
|
export { smartrequest };
|
||||||
smartrequest
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user