Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
64897e8e0b | |||
530fc59880 | |||
82cf0c2257 | |||
ea16521ca3 | |||
15889699b4 | |||
765e56076d | |||
273821b732 | |||
057cca6f0e | |||
40704efaa4 | |||
c08c708704 | |||
94b313b835 | |||
cafeef4ae5 | |||
a42fdb0260 |
38
package-lock.json
generated
38
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/ora",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.9",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -1134,6 +1134,16 @@
|
||||
"symbol-tree": "^3.2.4"
|
||||
}
|
||||
},
|
||||
"@pushrocks/qenv": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fqenv/-/qenv-4.0.10.tgz",
|
||||
"integrity": "sha512-bQknJrGa9zXDTmohi2W0fi/gZ5H36J1138WsRgdR2u/9D/0gwjBasL0kqBokH9sddcLSYe/H9itGFxbT7i7MCg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartfile": "^7.0.12",
|
||||
"@pushrocks/smartlog": "^2.0.26"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartbrowser": {
|
||||
"version": "1.0.17",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartbrowser/-/smartbrowser-1.0.17.tgz",
|
||||
@ -1371,8 +1381,7 @@
|
||||
"@pushrocks/smartpromise": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
|
||||
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg==",
|
||||
"dev": true
|
||||
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
|
||||
},
|
||||
"@pushrocks/smartpuppeteer": {
|
||||
"version": "1.0.15",
|
||||
@ -1390,7 +1399,6 @@
|
||||
"version": "1.1.47",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.47.tgz",
|
||||
"integrity": "sha512-0AuqtAI14VeWeXl2WpJbgCybVlG03rOjdGchAqy5k5lg9ACLhN3Z4kmoLgpBysWO/L2SjlAKB489SRyV3acykg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^3.0.5",
|
||||
"@types/form-data": "^2.5.0",
|
||||
@ -1672,7 +1680,6 @@
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.5.0.tgz",
|
||||
"integrity": "sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"form-data": "*"
|
||||
}
|
||||
@ -1855,7 +1862,6 @@
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://verdaccio.lossless.one/agentkeepalive/-/agentkeepalive-4.1.3.tgz",
|
||||
"integrity": "sha512-wn8fw19xKZwdGPO47jivonaHRTd+nGOMP1z11sgGeQzDy2xd5FG0R67dIMcKHDE2cJ5y+YXV30XVGUBPRSY7Hg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^4.1.0",
|
||||
"depd": "^1.1.2",
|
||||
@ -1928,8 +1934,7 @@
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://verdaccio.lossless.one/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
|
||||
"dev": true
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||
},
|
||||
"atob": {
|
||||
"version": "2.1.2",
|
||||
@ -2209,7 +2214,6 @@
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://verdaccio.lossless.one/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
@ -2366,7 +2370,6 @@
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://verdaccio.lossless.one/debug/-/debug-4.1.1.tgz",
|
||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
@ -2449,14 +2452,12 @@
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
|
||||
"dev": true
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
|
||||
},
|
||||
"depd": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://verdaccio.lossless.one/depd/-/depd-1.1.2.tgz",
|
||||
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=",
|
||||
"dev": true
|
||||
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
|
||||
},
|
||||
"destroy": {
|
||||
"version": "1.0.4",
|
||||
@ -2763,7 +2764,6 @@
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://verdaccio.lossless.one/form-data/-/form-data-2.5.1.tgz",
|
||||
"integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.6",
|
||||
@ -3013,7 +3013,6 @@
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://verdaccio.lossless.one/humanize-ms/-/humanize-ms-1.2.1.tgz",
|
||||
"integrity": "sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "^2.0.0"
|
||||
}
|
||||
@ -3401,14 +3400,12 @@
|
||||
"mime-db": {
|
||||
"version": "1.44.0",
|
||||
"resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.44.0.tgz",
|
||||
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==",
|
||||
"dev": true
|
||||
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.27",
|
||||
"resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.27.tgz",
|
||||
"integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mime-db": "1.44.0"
|
||||
}
|
||||
@ -3458,8 +3455,7 @@
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://verdaccio.lossless.one/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"mute-stream": {
|
||||
"version": "0.0.8",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/ora",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.9",
|
||||
"private": false,
|
||||
"description": "an api abstraction package for ora.pm",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -9,18 +9,21 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"build": "(tsbuild --web)",
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.11.7",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartrequest": "^1.1.47"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
|
87
test/test.ts
87
test/test.ts
@ -1,8 +1,91 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as qenv from '@pushrocks/qenv';
|
||||
const testQenv = new qenv.Qenv('./', './.nogit');
|
||||
|
||||
import * as ora from '../ts/index';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
console.log(ora.standardExport);
|
||||
let oraInstance: ora.Ora;
|
||||
|
||||
tap.test('should create a valid instance for Ora', async () => {
|
||||
oraInstance = new ora.Ora(testQenv.getEnvVarOnDemand('ORA_APITOKEN'));
|
||||
});
|
||||
|
||||
tap.test('should get all organizations', async () => {
|
||||
const organizations = await oraInstance.getOrganizations();
|
||||
expect(organizations.length).to.equal(2);
|
||||
});
|
||||
|
||||
tap.test('should get all projects of an organization', async () => {
|
||||
const organizations = await oraInstance.getOrganizations();
|
||||
const losslessOrganization = organizations.find(orgArg => {
|
||||
return orgArg.name.startsWith('Lossless');
|
||||
});
|
||||
const projectsInLosslessOrg = await losslessOrganization.getProjects();
|
||||
});
|
||||
|
||||
tap.test('should get all lists 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');
|
||||
});
|
||||
|
||||
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.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);
|
||||
console.log(`Task with title "${tasks[0].title}" is part of milestone "${milestone.title}"`);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -1,3 +1,6 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
|
||||
export let standardExport = 'Hi there! :) This is an exported string';
|
||||
export * from './ora.classes.ora';
|
||||
export * from './ora.classes.organization';
|
||||
export * from './ora.classes.project';
|
||||
export * from './ora.classes.list';
|
||||
export * from './ora.classes.task';
|
||||
export * from './ora.classes.milestone';
|
||||
|
63
ts/ora.classes.list.ts
Normal file
63
ts/ora.classes.list.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
import { OraProject } from './ora.classes.project';
|
||||
import { OraTask } from './ora.classes.task';
|
||||
|
||||
/**
|
||||
* 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
|
||||
// ======
|
||||
public static async getAllLists(oraProjectRef: OraProject) {
|
||||
const response = await oraProjectRef.oraOrganizationRef.oraRef.request(
|
||||
`/projects/${oraProjectRef.id}/lists`,
|
||||
'GET'
|
||||
);
|
||||
const oraLists: OraList[] = [];
|
||||
for (const dataObject of response.data) {
|
||||
oraLists.push(new OraList(oraProjectRef, dataObject));
|
||||
}
|
||||
return oraLists;
|
||||
}
|
||||
|
||||
// ========
|
||||
// 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;
|
||||
|
||||
constructor(oraProjectRefArg: OraProject, creationObjectArg) {
|
||||
this.oraProjectObjectRef = oraProjectRefArg;
|
||||
Object.assign(this, creationObjectArg);
|
||||
}
|
||||
|
||||
public async getTasks() {
|
||||
return OraTask.getAllOraTasks(this);
|
||||
}
|
||||
}
|
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);
|
||||
}
|
||||
}
|
33
ts/ora.classes.ora.ts
Normal file
33
ts/ora.classes.ora.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
import { OraOrganization } from './ora.classes.organization';
|
||||
|
||||
export class Ora {
|
||||
public apiBase: string = 'https://api.ora.pm';
|
||||
private apiToken: string;
|
||||
|
||||
constructor(apiTokenArg: string) {
|
||||
this.apiToken = apiTokenArg;
|
||||
}
|
||||
|
||||
public async getOrganizations() {
|
||||
return await OraOrganization.getAllOrganizations(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* make a request
|
||||
* @param routeArg
|
||||
* @param methodArg
|
||||
* @param payloadArg
|
||||
*/
|
||||
public async request(routeArg: string, methodArg: string, payloadArg?: string) {
|
||||
const response = await plugins.smartrequest.request(this.apiBase + routeArg, {
|
||||
method: methodArg,
|
||||
requestBody: payloadArg,
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
authorization: `Bearer ${this.apiToken}`
|
||||
}
|
||||
});
|
||||
return response.body;
|
||||
}
|
||||
}
|
59
ts/ora.classes.organization.ts
Normal file
59
ts/ora.classes.organization.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
import { Ora } from './ora.classes.ora';
|
||||
import { OraProject } from './ora.classes.project';
|
||||
|
||||
export interface IOraOrganization {
|
||||
created_at: string;
|
||||
description: string;
|
||||
id: number;
|
||||
member_type: number;
|
||||
name: string;
|
||||
org_picture: string;
|
||||
org_type: number;
|
||||
owner_id: number;
|
||||
premium_plan: null;
|
||||
quantity: number;
|
||||
updated_at: string;
|
||||
web: string;
|
||||
}
|
||||
|
||||
export class OraOrganization implements IOraOrganization {
|
||||
// ======
|
||||
// STATIC
|
||||
// ======
|
||||
public static async getAllOrganizations(oraRef: Ora): Promise<OraOrganization[]> {
|
||||
const response = await oraRef.request('/organizations', 'GET');
|
||||
const organizations: OraOrganization[] = [];
|
||||
for (const orgData of response.data) {
|
||||
organizations.push(new OraOrganization(oraRef, orgData));
|
||||
}
|
||||
return organizations;
|
||||
}
|
||||
|
||||
public created_at: string;
|
||||
public description: string;
|
||||
public id: number;
|
||||
public member_type: number;
|
||||
public name: string;
|
||||
public org_picture: string;
|
||||
public org_type: number;
|
||||
public owner_id: number;
|
||||
public premium_plan: null;
|
||||
public quantity: number;
|
||||
public updated_at: string;
|
||||
public web: string;
|
||||
|
||||
// ========
|
||||
// INSTANCE
|
||||
// ========
|
||||
public oraRef: Ora;
|
||||
|
||||
constructor(oraRefArg: Ora, creationObjectArg: IOraOrganization) {
|
||||
this.oraRef = oraRefArg;
|
||||
Object.assign(this, creationObjectArg);
|
||||
}
|
||||
|
||||
public async getProjects(): Promise<OraProject[]> {
|
||||
return OraProject.getAllProjectsForOrganization(this);
|
||||
}
|
||||
}
|
89
ts/ora.classes.project.ts
Normal file
89
ts/ora.classes.project.ts
Normal file
@ -0,0 +1,89 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
import { Ora } from './ora.classes.ora';
|
||||
import { OraOrganization } from './ora.classes.organization';
|
||||
import { OraList } from './ora.classes.list';
|
||||
import { OraMilestone } from './ora.classes.milestone';
|
||||
|
||||
export interface IOraProject {
|
||||
archived: boolean;
|
||||
comment_all: number;
|
||||
commits_visibility: number;
|
||||
created_at: string;
|
||||
default_view: boolean;
|
||||
description: string;
|
||||
id: number;
|
||||
invite_all: boolean;
|
||||
item_name: 'task';
|
||||
items_name: 'tasks';
|
||||
organization_id: number;
|
||||
owner: number;
|
||||
picture: string;
|
||||
prefix: string;
|
||||
project_color: string;
|
||||
project_type: number;
|
||||
seen: boolean;
|
||||
starred: number;
|
||||
tasks: number;
|
||||
title: string;
|
||||
updated_at: string;
|
||||
view_title: 'Backlog';
|
||||
web: string;
|
||||
}
|
||||
|
||||
export class OraProject implements IOraProject {
|
||||
// ======
|
||||
// STATIC
|
||||
// ======
|
||||
public static async getAllProjectsForOrganization(oraOrganizationRef: OraOrganization) {
|
||||
const response = await oraOrganizationRef.oraRef.request('/projects', 'GET');
|
||||
const projects: OraProject[] = [];
|
||||
for (const projectData of response.data) {
|
||||
const oraProject = new OraProject(oraOrganizationRef, projectData);
|
||||
if (oraProject.organization_id === oraOrganizationRef.id) {
|
||||
projects.push(oraProject);
|
||||
}
|
||||
}
|
||||
return projects;
|
||||
}
|
||||
|
||||
// ========
|
||||
// INSTANCE
|
||||
// ========
|
||||
public archived: boolean;
|
||||
public comment_all: number;
|
||||
public commits_visibility: number;
|
||||
public created_at: string;
|
||||
public default_view: boolean;
|
||||
public description: string;
|
||||
public id: number;
|
||||
public invite_all: boolean;
|
||||
public item_name: 'task';
|
||||
public items_name: 'tasks';
|
||||
public organization_id: number;
|
||||
public owner: number;
|
||||
public picture: string;
|
||||
public prefix: string;
|
||||
public project_color: string;
|
||||
public project_type: number;
|
||||
public seen: boolean;
|
||||
public starred: number;
|
||||
public tasks: number;
|
||||
public title: string;
|
||||
public updated_at: string;
|
||||
public view_title: 'Backlog';
|
||||
public web: string;
|
||||
|
||||
public oraOrganizationRef: OraOrganization;
|
||||
constructor(oraOrganiazionRefArg: OraOrganization, creationObjectArg: IOraProject) {
|
||||
this.oraOrganizationRef = oraOrganiazionRefArg;
|
||||
Object.assign(this, creationObjectArg);
|
||||
}
|
||||
|
||||
public async getLists(): Promise<OraList[]> {
|
||||
return OraList.getAllLists(this);
|
||||
}
|
||||
|
||||
public async getMileStones(): Promise<OraMilestone[]> {
|
||||
return OraMilestone.getAllMilestonesForProject(this);
|
||||
}
|
||||
}
|
100
ts/ora.classes.task.ts
Normal file
100
ts/ora.classes.task.ts
Normal file
@ -0,0 +1,100 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
import { OraList } from './ora.classes.list';
|
||||
import { OraMilestone } from './ora.classes.milestone';
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public async getMilestone (): Promise<OraMilestone> {
|
||||
return (await this.oraListRef.oraProjectObjectRef.getMileStones()).find(milestoneArg => milestoneArg.id === this.milestone_id);
|
||||
}
|
||||
}
|
@ -1,2 +1,4 @@
|
||||
const removeme = {};
|
||||
export { removeme };
|
||||
// pushrocks scope
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
|
||||
export { smartrequest };
|
||||
|
Loading…
x
Reference in New Issue
Block a user