Skip to content

Commit d660cd0

Browse files
Merge pull request #13 from zazuko/projects
Adds projects
2 parents 3dff205 + c364df7 commit d660cd0

14 files changed

+774
-0
lines changed

src/constants/Scopes.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ enum Scopes {
2323
MONITORING_EDIT = 'monitoring_edit',
2424
NOTE_SHOW = 'note_show',
2525
NOTE_EDIT = 'note_edit',
26+
PROJECT_SHOW = 'project_show',
27+
PROJECT_EDIT = 'project_edit',
2628
TASK_SHOW = 'task_show',
2729
TASK_EDIT = 'task_edit',
2830
GENERAL = 'general'

src/index.ts

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Scopes from "./constants/Scopes";
22
import OAuth2, { AuthorizationResponse } from "./libs/OAuth2";
3+
import BusinessActivities from "./resources/BusinessActivities";
34
import Contacts from "./resources/Contacts";
45
import ContactTypes from "./resources/ContactTypes";
56
import ContactSectors from "./resources/ContactSectors";
@@ -8,12 +9,16 @@ import ContactRelations from "./resources/ContactRelations";
89
import Expenses from "./resources/Expenses";
910
import Bills from "./resources/Bills";
1011
import Orders from "./resources/Orders";
12+
import Projects from "./resources/Projects";
13+
import ProjectStatuses from "./resources/ProjectStatuses";
14+
import ProjectTypes from "./resources/ProjectTypes";
1115
import request from "request-promise-native";
1216
import { CookieJar } from "request";
1317
import Timetrackings from "./resources/Timetrackings";
1418
import TimetrackingStatuses from "./resources/TimetrackingStatuses";
1519

1620
export * from "./interfaces/BillsStatic";
21+
export * from "./interfaces/BusinessActivitiesStatic";
1722
export * from "./interfaces/CalendarStatic";
1823
export * from "./interfaces/ContactGroupsStatic";
1924
export * from "./interfaces/ContactRelationsStatic";
@@ -23,6 +28,9 @@ export * from "./interfaces/ContactsStatic";
2328
export * from "./interfaces/ExpensesStatic";
2429
export * from "./interfaces/NotesStatic";
2530
export * from "./interfaces/OrdersStatic";
31+
export * from "./interfaces/ProjectsStatic";
32+
export * from "./interfaces/ProjectStatusesStatic";
33+
export * from "./interfaces/ProjectTypesStatic";
2634
export * from "./interfaces/SalesOrderManagementStatic";
2735
export * from "./interfaces/TimetrackingsStatic";
2836
export * from "./interfaces/TimetrackingStatusesStatic";
@@ -37,6 +45,9 @@ export default class Bexio {
3745
private bexioAuth: OAuth2;
3846

3947
// Resources
48+
// Business Activities
49+
public businessActivities: BusinessActivities;
50+
4051
// Contacts
4152
public contacts: Contacts;
4253
public contactTypes: ContactTypes;
@@ -49,6 +60,11 @@ export default class Bexio {
4960
public expenses: Expenses;
5061
public bills: Bills;
5162

63+
// Projects
64+
public projects: Projects;
65+
public projectStatuses: ProjectStatuses;
66+
public projectTypes: ProjectTypes;
67+
5268
// Timesheets
5369
public timetrackings: Timetrackings;
5470
public timetrackingStatuses: TimetrackingStatuses;
@@ -75,12 +91,16 @@ export default class Bexio {
7591
);
7692

7793
// Init resources
94+
this.businessActivities = new BusinessActivities(this.bexioAuth);
7895
this.contacts = new Contacts(this.bexioAuth);
7996
this.contactTypes = new ContactTypes(this.bexioAuth);
8097
this.contactSectors = new ContactSectors(this.bexioAuth);
8198
this.contactGroups = new ContactGroups(this.bexioAuth);
8299
this.contactRelations = new ContactRelations(this.bexioAuth);
83100
this.orders = new Orders(this.bexioAuth);
101+
this.projects = new Projects(this.bexioAuth);
102+
this.projectStatuses = new ProjectStatuses(this.bexioAuth);
103+
this.projectTypes = new ProjectTypes(this.bexioAuth);
84104
this.expenses = new Expenses(this.bexioAuth);
85105
this.bills = new Bills(this.bexioAuth);
86106
this.timetrackings = new Timetrackings(this.bexioAuth);
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export namespace BusinessActivitiesStatic {
2+
export interface BusinessActivity {
3+
id: number;
4+
name: string;
5+
default_is_billable?: boolean;
6+
default_price_per_hour?: string;
7+
account_id?: number;
8+
}
9+
10+
export interface BusinessActivityCreate {
11+
name: string;
12+
default_is_billable?: boolean;
13+
default_price_per_hour?: string;
14+
account_id?: number;
15+
}
16+
17+
export interface BusinessActivityOverwrite {
18+
name: string;
19+
default_is_billable?: boolean;
20+
default_price_per_hour?: string;
21+
account_id?: number;
22+
}
23+
24+
export enum BusinessActivitySearchParameters {
25+
name = "name",
26+
}
27+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export namespace ProjectStatusesStatic {
2+
export interface ProjectStatus {
3+
id: number;
4+
name: string;
5+
}
6+
7+
export enum ProjectStatusSearchParameters {
8+
text = 'text'
9+
}
10+
}

src/interfaces/ProjectTypesStatic.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export namespace ProjectTypesStatic {
2+
export interface ProjectType {
3+
id: number;
4+
name: string;
5+
}
6+
7+
export enum ProjectTypeSearchParameters {
8+
project_type = 'project_type'
9+
}
10+
}

src/interfaces/ProjectsStatic.ts

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
export namespace ProjectsStatic {
2+
export interface Project {
3+
id: number;
4+
nr: string;
5+
name: string;
6+
start_date?: string;
7+
end_date?: string;
8+
comment: string;
9+
pr_state_id: number;
10+
pr_project_type_id: number;
11+
contact_id: number;
12+
contact_sub_id?: number;
13+
pr_invoice_type_id?: number;
14+
pr_invoice_type_amount: number;
15+
pr_budget_type_id?: number;
16+
pr_budget_type_amount: number;
17+
}
18+
19+
export interface ProjectCreate {
20+
contact_id: number;
21+
name: string;
22+
pr_project_type_id: number;
23+
pr_state_id: number;
24+
user_id: number;
25+
comment?: string;
26+
contact_sub_id?: number;
27+
end_date?: string;
28+
pr_budget_type_amount?: number;
29+
pr_budget_type_id?: number;
30+
pr_invoice_type_amount?: number;
31+
pr_invoice_type_id?: number;
32+
pr_sub_state_id?: number;
33+
start_date?: string;
34+
}
35+
36+
export interface ProjectOverwrite {
37+
contact_id: number;
38+
name: string;
39+
pr_project_type_id: number;
40+
pr_state_id: number;
41+
user_id: number;
42+
comment?: string;
43+
contact_sub_id?: number;
44+
end_date?: string;
45+
pr_budget_type_amount?: number;
46+
pr_budget_type_id?: number;
47+
pr_invoice_type_amount?: number;
48+
pr_invoice_type_id?: number;
49+
pr_sub_state_id?: number;
50+
start_date?: string;
51+
}
52+
53+
export enum ProjectSearchParameters {
54+
name = "name",
55+
contact_id = "contact_id",
56+
pr_state_id = "pr_state_id",
57+
}
58+
}

src/resources/BusinessActivities.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { BusinessActivitiesStatic } from "../interfaces/BusinessActivitiesStatic";
2+
import BaseCrud from "./BaseCrud";
3+
import OAuth2 from "../libs/OAuth2";
4+
import Scopes from "../constants/Scopes";
5+
6+
export default class ClientServices extends BaseCrud<
7+
BusinessActivitiesStatic.BusinessActivity,
8+
BusinessActivitiesStatic.BusinessActivity,
9+
BusinessActivitiesStatic.BusinessActivity,
10+
BusinessActivitiesStatic.BusinessActivitySearchParameters,
11+
BusinessActivitiesStatic.BusinessActivityCreate,
12+
BusinessActivitiesStatic.BusinessActivityOverwrite
13+
> {
14+
constructor(bexioAuth: OAuth2) {
15+
super(bexioAuth, "/client_service", Scopes.GENERAL, Scopes.GENERAL);
16+
}
17+
}

src/resources/ProjectStatuses.ts

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import BaseCrud from "./BaseCrud";
2+
import OAuth2 from "../libs/OAuth2";
3+
import { Scopes } from "..";
4+
import { ProjectStatusesStatic } from "../interfaces/ProjectStatusesStatic";
5+
6+
export default class ProjectStatuses extends BaseCrud<
7+
ProjectStatusesStatic.ProjectStatus,
8+
ProjectStatusesStatic.ProjectStatus,
9+
ProjectStatusesStatic.ProjectStatus,
10+
ProjectStatusesStatic.ProjectStatusSearchParameters,
11+
{},
12+
{}
13+
> {
14+
constructor(bexioAuth: OAuth2) {
15+
super(
16+
bexioAuth,
17+
"/pr_project_state",
18+
Scopes.PROJECT_SHOW,
19+
Scopes.PROJECT_EDIT
20+
);
21+
}
22+
23+
/**
24+
* Not implemented by Bexio yet
25+
*
26+
* @param {number} id
27+
* @param {{}} ressource
28+
* @returns {Promise<ProjectStatusesStatic.ProjectStatus>}
29+
* @memberof ProjectStatuses
30+
*/
31+
public async overwrite(
32+
id: number,
33+
ressource: {}
34+
): Promise<ProjectStatusesStatic.ProjectStatus> {
35+
throw new Error("not implemented by Bexio yet");
36+
}
37+
38+
/**
39+
* Not implemented by Bexio yet
40+
*
41+
* @param {number} id
42+
* @param {{}} ressource
43+
* @returns {Promise<ProjectStatusesStatic.ProjectStatus>}
44+
* @memberof ProjectStatuses
45+
*/
46+
public async edit(
47+
id: number,
48+
ressource: {}
49+
): Promise<ProjectStatusesStatic.ProjectStatus> {
50+
throw new Error("not implemented by Bexio yet");
51+
}
52+
53+
/**
54+
* Not implemented by Bexio yet
55+
*
56+
* @param {{}} ressource
57+
* @returns {Promise<ProjectStatusesStatic.ProjectStatus>}
58+
* @memberof ProjectStatuses
59+
*/
60+
public async create(ressource: {}): Promise<
61+
ProjectStatusesStatic.ProjectStatus
62+
> {
63+
throw new Error("not implemented by Bexio yet");
64+
}
65+
66+
/**
67+
* Not implemented by Bexio yet
68+
*
69+
* @param {number} id
70+
* @returns {Promise<boolean>}
71+
* @memberof ProjectStatuses
72+
*/
73+
public async delete(id: number): Promise<boolean> {
74+
throw new Error("not implemented by Bexio yet");
75+
}
76+
}

src/resources/ProjectTypes.ts

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { ProjectTypesStatic } from "../interfaces/ProjectTypesStatic";
2+
import BaseCrud from "./BaseCrud";
3+
import OAuth2 from "../libs/OAuth2";
4+
import Scopes from "../constants/Scopes";
5+
6+
export default class ProjectTypes extends BaseCrud<
7+
ProjectTypesStatic.ProjectType,
8+
ProjectTypesStatic.ProjectType,
9+
ProjectTypesStatic.ProjectType,
10+
ProjectTypesStatic.ProjectTypeSearchParameters,
11+
{},
12+
ProjectTypesStatic.ProjectType
13+
> {
14+
constructor(bexioAuth: OAuth2) {
15+
super(bexioAuth, "/pr_project_type", Scopes.PROJECT_SHOW, Scopes.PROJECT_EDIT);
16+
}
17+
18+
19+
/**
20+
* Not implemented by Bexio yet
21+
*
22+
* @param {{}} ressource
23+
* @returns {Promise<ProjectTypesStatic.ProjectType>}
24+
* @memberof ProjectTypes
25+
*/
26+
public async create(ressource: {}): Promise<ProjectTypesStatic.ProjectType> {
27+
throw new Error('not implemented by Bexio yet')
28+
}
29+
30+
/**
31+
* Not implemented by Bexio yet
32+
*
33+
* @param {number} id
34+
* @param {{}} ressource
35+
* @returns {Promise<ProjectTypesStatic.ProjectType>}
36+
* @memberof ProjectTypes
37+
*/
38+
public async edit(id: number, ressource: {}): Promise<ProjectTypesStatic.ProjectType> {
39+
throw new Error('not implemented by Bexio yet')
40+
}
41+
42+
/**
43+
* Not implemented by Bexio yet
44+
*
45+
* @param {number} id
46+
* @param {{}} ressource
47+
* @returns {Promise<ProjectTypesStatic.ProjectType>}
48+
* @memberof ProjectTypes
49+
*/
50+
public async overwrite(id: number, ressource: {}): Promise<ProjectTypesStatic.ProjectType> {
51+
throw new Error('not implemented by Bexio yet')
52+
}
53+
54+
/**
55+
* Not implemented by Bexio yet
56+
*
57+
* @param {number} id
58+
* @returns {Promise<boolean>}
59+
* @memberof ProjectTypes
60+
*/
61+
public async delete(id: number): Promise<boolean> {
62+
throw new Error('not implemented by Bexio yet')
63+
}
64+
}

src/resources/Projects.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { ProjectsStatic } from "../interfaces/ProjectsStatic";
2+
import BaseCrud from "./BaseCrud";
3+
import OAuth2 from "../libs/OAuth2";
4+
import Scopes from "../constants/Scopes";
5+
6+
export default class Projects extends BaseCrud<
7+
ProjectsStatic.Project,
8+
ProjectsStatic.Project,
9+
ProjectsStatic.Project,
10+
ProjectsStatic.ProjectSearchParameters,
11+
ProjectsStatic.ProjectCreate,
12+
ProjectsStatic.ProjectOverwrite
13+
> {
14+
constructor(bexioAuth: OAuth2) {
15+
super(bexioAuth, "/pr_project", Scopes.PROJECT_SHOW, Scopes.PROJECT_EDIT);
16+
}
17+
}

0 commit comments

Comments
 (0)