fix(core): update
This commit is contained in:
@ -1,3 +1,2 @@
|
||||
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';
|
||||
|
5
ts/ora.classes.list.ts
Normal file
5
ts/ora.classes.list.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
|
||||
export class OraList {
|
||||
|
||||
}
|
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;
|
||||
}
|
||||
}
|
56
ts/ora.classes.organization.ts
Normal file
56
ts/ora.classes.organization.ts
Normal file
@ -0,0 +1,56 @@
|
||||
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 {
|
||||
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;
|
||||
|
||||
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
|
||||
// ========
|
||||
public oraRef: Ora;
|
||||
|
||||
constructor(oraRefArg: Ora, creationObjectArg: IOraOrganization) {
|
||||
this.oraRef = oraRefArg;
|
||||
Object.assign(this, creationObjectArg);
|
||||
}
|
||||
|
||||
public async getAllProjects(): Promise<OraProject[]> {
|
||||
return OraProject.getAllProjectsForOrganization(this);
|
||||
}
|
||||
}
|
74
ts/ora.classes.project.ts
Normal file
74
ts/ora.classes.project.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import * as plugins from './ora.plugins';
|
||||
import { Ora } from './ora.classes.ora';
|
||||
import { OraOrganization } from './ora.classes.organization';
|
||||
|
||||
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 {
|
||||
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 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;
|
||||
}
|
||||
}
|
@ -1,2 +1,6 @@
|
||||
const removeme = {};
|
||||
export { removeme };
|
||||
// pushrocks scope
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
|
||||
export {
|
||||
smartrequest
|
||||
};
|
||||
|
Reference in New Issue
Block a user