fix(core): update
This commit is contained in:
parent
40704efaa4
commit
057cca6f0e
14
test/test.ts
14
test/test.ts
@ -20,8 +20,18 @@ tap.test('should get all projects of an organization', async () => {
|
||||
const losslessOrganization = organizations.find(orgArg => {
|
||||
return orgArg.name.startsWith('Lossless');
|
||||
});
|
||||
const projectsInLosslessOrg = await losslessOrganization.getAllProjects();
|
||||
console.log(projectsInLosslessOrg);
|
||||
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
|
||||
})
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -1,5 +1,27 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
import { OraProject } from './ora.classes.project';
|
||||
|
||||
export class OraList {
|
||||
// ======
|
||||
// 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 oraProjectObjectRef: OraProject;
|
||||
|
||||
constructor(oraProjectRefArg: OraProject, creationObjectArg) {
|
||||
this.oraProjectObjectRef = oraProjectRefArg;
|
||||
Object.assign(this, creationObjectArg);
|
||||
}
|
||||
}
|
@ -18,6 +18,18 @@ export interface IOraOrganization {
|
||||
}
|
||||
|
||||
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;
|
||||
@ -31,15 +43,6 @@ export class OraOrganization implements IOraOrganization {
|
||||
public updated_at: string;
|
||||
public web: string;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// ========
|
||||
// INSTANCE
|
||||
// ========
|
||||
@ -50,7 +53,7 @@ export class OraOrganization implements IOraOrganization {
|
||||
Object.assign(this, creationObjectArg);
|
||||
}
|
||||
|
||||
public async getAllProjects(): Promise<OraProject[]> {
|
||||
public async getProjects(): Promise<OraProject[]> {
|
||||
return OraProject.getAllProjectsForOrganization(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
import { Ora } from './ora.classes.ora';
|
||||
import { OraOrganization } from './ora.classes.organization';
|
||||
import { OraList } from './ora.classes.list';
|
||||
|
||||
export interface IOraProject {
|
||||
archived: boolean;
|
||||
@ -29,6 +30,24 @@ export interface IOraProject {
|
||||
}
|
||||
|
||||
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;
|
||||
@ -60,15 +79,7 @@ export class OraProject implements IOraProject {
|
||||
Object.assign(this, creationObjectArg);
|
||||
}
|
||||
|
||||
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;
|
||||
public async getLists(): Promise<OraList[]> {
|
||||
return OraList.getAllLists(this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user