Skip to content

Commit

Permalink
Merge pull request #13 from zazuko/projects
Browse files Browse the repository at this point in the history
Adds projects
  • Loading branch information
mathewmeconry authored Oct 13, 2019
2 parents 3dff205 + c364df7 commit d660cd0
Show file tree
Hide file tree
Showing 14 changed files with 774 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/constants/Scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ enum Scopes {
MONITORING_EDIT = 'monitoring_edit',
NOTE_SHOW = 'note_show',
NOTE_EDIT = 'note_edit',
PROJECT_SHOW = 'project_show',
PROJECT_EDIT = 'project_edit',
TASK_SHOW = 'task_show',
TASK_EDIT = 'task_edit',
GENERAL = 'general'
Expand Down
20 changes: 20 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Scopes from "./constants/Scopes";
import OAuth2, { AuthorizationResponse } from "./libs/OAuth2";
import BusinessActivities from "./resources/BusinessActivities";
import Contacts from "./resources/Contacts";
import ContactTypes from "./resources/ContactTypes";
import ContactSectors from "./resources/ContactSectors";
Expand All @@ -8,12 +9,16 @@ import ContactRelations from "./resources/ContactRelations";
import Expenses from "./resources/Expenses";
import Bills from "./resources/Bills";
import Orders from "./resources/Orders";
import Projects from "./resources/Projects";
import ProjectStatuses from "./resources/ProjectStatuses";
import ProjectTypes from "./resources/ProjectTypes";
import request from "request-promise-native";
import { CookieJar } from "request";
import Timetrackings from "./resources/Timetrackings";
import TimetrackingStatuses from "./resources/TimetrackingStatuses";

export * from "./interfaces/BillsStatic";
export * from "./interfaces/BusinessActivitiesStatic";
export * from "./interfaces/CalendarStatic";
export * from "./interfaces/ContactGroupsStatic";
export * from "./interfaces/ContactRelationsStatic";
Expand All @@ -23,6 +28,9 @@ export * from "./interfaces/ContactsStatic";
export * from "./interfaces/ExpensesStatic";
export * from "./interfaces/NotesStatic";
export * from "./interfaces/OrdersStatic";
export * from "./interfaces/ProjectsStatic";
export * from "./interfaces/ProjectStatusesStatic";
export * from "./interfaces/ProjectTypesStatic";
export * from "./interfaces/SalesOrderManagementStatic";
export * from "./interfaces/TimetrackingsStatic";
export * from "./interfaces/TimetrackingStatusesStatic";
Expand All @@ -37,6 +45,9 @@ export default class Bexio {
private bexioAuth: OAuth2;

// Resources
// Business Activities
public businessActivities: BusinessActivities;

// Contacts
public contacts: Contacts;
public contactTypes: ContactTypes;
Expand All @@ -49,6 +60,11 @@ export default class Bexio {
public expenses: Expenses;
public bills: Bills;

// Projects
public projects: Projects;
public projectStatuses: ProjectStatuses;
public projectTypes: ProjectTypes;

// Timesheets
public timetrackings: Timetrackings;
public timetrackingStatuses: TimetrackingStatuses;
Expand All @@ -75,12 +91,16 @@ export default class Bexio {
);

// Init resources
this.businessActivities = new BusinessActivities(this.bexioAuth);
this.contacts = new Contacts(this.bexioAuth);
this.contactTypes = new ContactTypes(this.bexioAuth);
this.contactSectors = new ContactSectors(this.bexioAuth);
this.contactGroups = new ContactGroups(this.bexioAuth);
this.contactRelations = new ContactRelations(this.bexioAuth);
this.orders = new Orders(this.bexioAuth);
this.projects = new Projects(this.bexioAuth);
this.projectStatuses = new ProjectStatuses(this.bexioAuth);
this.projectTypes = new ProjectTypes(this.bexioAuth);
this.expenses = new Expenses(this.bexioAuth);
this.bills = new Bills(this.bexioAuth);
this.timetrackings = new Timetrackings(this.bexioAuth);
Expand Down
27 changes: 27 additions & 0 deletions src/interfaces/BusinessActivitiesStatic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export namespace BusinessActivitiesStatic {
export interface BusinessActivity {
id: number;
name: string;
default_is_billable?: boolean;
default_price_per_hour?: string;
account_id?: number;
}

export interface BusinessActivityCreate {
name: string;
default_is_billable?: boolean;
default_price_per_hour?: string;
account_id?: number;
}

export interface BusinessActivityOverwrite {
name: string;
default_is_billable?: boolean;
default_price_per_hour?: string;
account_id?: number;
}

export enum BusinessActivitySearchParameters {
name = "name",
}
}
10 changes: 10 additions & 0 deletions src/interfaces/ProjectStatusesStatic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export namespace ProjectStatusesStatic {
export interface ProjectStatus {
id: number;
name: string;
}

export enum ProjectStatusSearchParameters {
text = 'text'
}
}
10 changes: 10 additions & 0 deletions src/interfaces/ProjectTypesStatic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export namespace ProjectTypesStatic {
export interface ProjectType {
id: number;
name: string;
}

export enum ProjectTypeSearchParameters {
project_type = 'project_type'
}
}
58 changes: 58 additions & 0 deletions src/interfaces/ProjectsStatic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export namespace ProjectsStatic {
export interface Project {
id: number;
nr: string;
name: string;
start_date?: string;
end_date?: string;
comment: string;
pr_state_id: number;
pr_project_type_id: number;
contact_id: number;
contact_sub_id?: number;
pr_invoice_type_id?: number;
pr_invoice_type_amount: number;
pr_budget_type_id?: number;
pr_budget_type_amount: number;
}

export interface ProjectCreate {
contact_id: number;
name: string;
pr_project_type_id: number;
pr_state_id: number;
user_id: number;
comment?: string;
contact_sub_id?: number;
end_date?: string;
pr_budget_type_amount?: number;
pr_budget_type_id?: number;
pr_invoice_type_amount?: number;
pr_invoice_type_id?: number;
pr_sub_state_id?: number;
start_date?: string;
}

export interface ProjectOverwrite {
contact_id: number;
name: string;
pr_project_type_id: number;
pr_state_id: number;
user_id: number;
comment?: string;
contact_sub_id?: number;
end_date?: string;
pr_budget_type_amount?: number;
pr_budget_type_id?: number;
pr_invoice_type_amount?: number;
pr_invoice_type_id?: number;
pr_sub_state_id?: number;
start_date?: string;
}

export enum ProjectSearchParameters {
name = "name",
contact_id = "contact_id",
pr_state_id = "pr_state_id",
}
}
17 changes: 17 additions & 0 deletions src/resources/BusinessActivities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BusinessActivitiesStatic } from "../interfaces/BusinessActivitiesStatic";
import BaseCrud from "./BaseCrud";
import OAuth2 from "../libs/OAuth2";
import Scopes from "../constants/Scopes";

export default class ClientServices extends BaseCrud<
BusinessActivitiesStatic.BusinessActivity,
BusinessActivitiesStatic.BusinessActivity,
BusinessActivitiesStatic.BusinessActivity,
BusinessActivitiesStatic.BusinessActivitySearchParameters,
BusinessActivitiesStatic.BusinessActivityCreate,
BusinessActivitiesStatic.BusinessActivityOverwrite
> {
constructor(bexioAuth: OAuth2) {
super(bexioAuth, "/client_service", Scopes.GENERAL, Scopes.GENERAL);
}
}
76 changes: 76 additions & 0 deletions src/resources/ProjectStatuses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import BaseCrud from "./BaseCrud";
import OAuth2 from "../libs/OAuth2";
import { Scopes } from "..";
import { ProjectStatusesStatic } from "../interfaces/ProjectStatusesStatic";

export default class ProjectStatuses extends BaseCrud<
ProjectStatusesStatic.ProjectStatus,
ProjectStatusesStatic.ProjectStatus,
ProjectStatusesStatic.ProjectStatus,
ProjectStatusesStatic.ProjectStatusSearchParameters,
{},
{}
> {
constructor(bexioAuth: OAuth2) {
super(
bexioAuth,
"/pr_project_state",
Scopes.PROJECT_SHOW,
Scopes.PROJECT_EDIT
);
}

/**
* Not implemented by Bexio yet
*
* @param {number} id
* @param {{}} ressource
* @returns {Promise<ProjectStatusesStatic.ProjectStatus>}
* @memberof ProjectStatuses
*/
public async overwrite(
id: number,
ressource: {}
): Promise<ProjectStatusesStatic.ProjectStatus> {
throw new Error("not implemented by Bexio yet");
}

/**
* Not implemented by Bexio yet
*
* @param {number} id
* @param {{}} ressource
* @returns {Promise<ProjectStatusesStatic.ProjectStatus>}
* @memberof ProjectStatuses
*/
public async edit(
id: number,
ressource: {}
): Promise<ProjectStatusesStatic.ProjectStatus> {
throw new Error("not implemented by Bexio yet");
}

/**
* Not implemented by Bexio yet
*
* @param {{}} ressource
* @returns {Promise<ProjectStatusesStatic.ProjectStatus>}
* @memberof ProjectStatuses
*/
public async create(ressource: {}): Promise<
ProjectStatusesStatic.ProjectStatus
> {
throw new Error("not implemented by Bexio yet");
}

/**
* Not implemented by Bexio yet
*
* @param {number} id
* @returns {Promise<boolean>}
* @memberof ProjectStatuses
*/
public async delete(id: number): Promise<boolean> {
throw new Error("not implemented by Bexio yet");
}
}
64 changes: 64 additions & 0 deletions src/resources/ProjectTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { ProjectTypesStatic } from "../interfaces/ProjectTypesStatic";
import BaseCrud from "./BaseCrud";
import OAuth2 from "../libs/OAuth2";
import Scopes from "../constants/Scopes";

export default class ProjectTypes extends BaseCrud<
ProjectTypesStatic.ProjectType,
ProjectTypesStatic.ProjectType,
ProjectTypesStatic.ProjectType,
ProjectTypesStatic.ProjectTypeSearchParameters,
{},
ProjectTypesStatic.ProjectType
> {
constructor(bexioAuth: OAuth2) {
super(bexioAuth, "/pr_project_type", Scopes.PROJECT_SHOW, Scopes.PROJECT_EDIT);
}


/**
* Not implemented by Bexio yet
*
* @param {{}} ressource
* @returns {Promise<ProjectTypesStatic.ProjectType>}
* @memberof ProjectTypes
*/
public async create(ressource: {}): Promise<ProjectTypesStatic.ProjectType> {
throw new Error('not implemented by Bexio yet')
}

/**
* Not implemented by Bexio yet
*
* @param {number} id
* @param {{}} ressource
* @returns {Promise<ProjectTypesStatic.ProjectType>}
* @memberof ProjectTypes
*/
public async edit(id: number, ressource: {}): Promise<ProjectTypesStatic.ProjectType> {
throw new Error('not implemented by Bexio yet')
}

/**
* Not implemented by Bexio yet
*
* @param {number} id
* @param {{}} ressource
* @returns {Promise<ProjectTypesStatic.ProjectType>}
* @memberof ProjectTypes
*/
public async overwrite(id: number, ressource: {}): Promise<ProjectTypesStatic.ProjectType> {
throw new Error('not implemented by Bexio yet')
}

/**
* Not implemented by Bexio yet
*
* @param {number} id
* @returns {Promise<boolean>}
* @memberof ProjectTypes
*/
public async delete(id: number): Promise<boolean> {
throw new Error('not implemented by Bexio yet')
}
}
17 changes: 17 additions & 0 deletions src/resources/Projects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ProjectsStatic } from "../interfaces/ProjectsStatic";
import BaseCrud from "./BaseCrud";
import OAuth2 from "../libs/OAuth2";
import Scopes from "../constants/Scopes";

export default class Projects extends BaseCrud<
ProjectsStatic.Project,
ProjectsStatic.Project,
ProjectsStatic.Project,
ProjectsStatic.ProjectSearchParameters,
ProjectsStatic.ProjectCreate,
ProjectsStatic.ProjectOverwrite
> {
constructor(bexioAuth: OAuth2) {
super(bexioAuth, "/pr_project", Scopes.PROJECT_SHOW, Scopes.PROJECT_EDIT);
}
}
Loading

0 comments on commit d660cd0

Please sign in to comment.