node-paymo-api 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/abstract.d.ts +23 -0
  2. package/dist/abstract.js +210 -0
  3. package/dist/index.d.ts +6 -0
  4. package/dist/index.js +18 -0
  5. package/dist/remote.d.ts +9 -0
  6. package/dist/remote.js +80 -0
  7. package/dist/resources/_template_/index.d.ts +18 -0
  8. package/dist/resources/_template_/index.js +34 -0
  9. package/dist/resources/_template_/types.d.ts +25 -0
  10. package/dist/resources/_template_/types.js +2 -0
  11. package/dist/resources/bookings/index.d.ts +18 -0
  12. package/dist/resources/bookings/index.js +49 -0
  13. package/dist/resources/bookings/types.d.ts +49 -0
  14. package/dist/resources/bookings/types.js +2 -0
  15. package/dist/resources/clientcontacts/index.d.ts +18 -0
  16. package/dist/resources/clientcontacts/index.js +34 -0
  17. package/dist/resources/clientcontacts/types.d.ts +59 -0
  18. package/dist/resources/clientcontacts/types.js +2 -0
  19. package/dist/resources/clients/index.d.ts +18 -0
  20. package/dist/resources/clients/index.js +34 -0
  21. package/dist/resources/clients/types.d.ts +71 -0
  22. package/dist/resources/clients/types.js +2 -0
  23. package/dist/resources/comments/Comments.d.ts +18 -0
  24. package/dist/resources/comments/Comments.js +34 -0
  25. package/dist/resources/comments/Threads.d.ts +28 -0
  26. package/dist/resources/comments/Threads.js +25 -0
  27. package/dist/resources/comments/index.d.ts +2 -0
  28. package/dist/resources/comments/index.js +7 -0
  29. package/dist/resources/comments/types.d.ts +77 -0
  30. package/dist/resources/comments/types.js +2 -0
  31. package/dist/resources/company/index.d.ts +12 -0
  32. package/dist/resources/company/index.js +25 -0
  33. package/dist/resources/company/types.d.ts +44 -0
  34. package/dist/resources/company/types.js +2 -0
  35. package/dist/resources/discussions/index.d.ts +18 -0
  36. package/dist/resources/discussions/index.js +34 -0
  37. package/dist/resources/discussions/types.d.ts +43 -0
  38. package/dist/resources/discussions/types.js +2 -0
  39. package/dist/resources/entries/index.d.ts +18 -0
  40. package/dist/resources/entries/index.js +47 -0
  41. package/dist/resources/entries/types.d.ts +53 -0
  42. package/dist/resources/entries/types.js +2 -0
  43. package/dist/resources/estimates/EstimateItem.d.ts +3 -0
  44. package/dist/resources/estimates/EstimateItem.js +5 -0
  45. package/dist/resources/estimates/Estimates.d.ts +18 -0
  46. package/dist/resources/estimates/Estimates.js +34 -0
  47. package/dist/resources/estimates/index.d.ts +2 -0
  48. package/dist/resources/estimates/index.js +7 -0
  49. package/dist/resources/estimates/types.d.ts +76 -0
  50. package/dist/resources/estimates/types.js +2 -0
  51. package/dist/resources/estimatetemplates/index.d.ts +18 -0
  52. package/dist/resources/estimatetemplates/index.js +34 -0
  53. package/dist/resources/estimatetemplates/types.d.ts +34 -0
  54. package/dist/resources/estimatetemplates/types.js +2 -0
  55. package/dist/resources/expenses/index.d.ts +18 -0
  56. package/dist/resources/expenses/index.js +34 -0
  57. package/dist/resources/expenses/types.d.ts +46 -0
  58. package/dist/resources/expenses/types.js +2 -0
  59. package/dist/resources/files/index.d.ts +18 -0
  60. package/dist/resources/files/index.js +45 -0
  61. package/dist/resources/files/types.d.ts +44 -0
  62. package/dist/resources/files/types.js +2 -0
  63. package/dist/resources/index.d.ts +117 -0
  64. package/dist/resources/index.js +200 -0
  65. package/dist/resources/invoices/InvoiceItem.d.ts +3 -0
  66. package/dist/resources/invoices/InvoiceItem.js +5 -0
  67. package/dist/resources/invoices/Invoices.d.ts +18 -0
  68. package/dist/resources/invoices/Invoices.js +34 -0
  69. package/dist/resources/invoices/index.d.ts +2 -0
  70. package/dist/resources/invoices/index.js +7 -0
  71. package/dist/resources/invoices/types.d.ts +87 -0
  72. package/dist/resources/invoices/types.js +2 -0
  73. package/dist/resources/invoicetemplates/index.d.ts +18 -0
  74. package/dist/resources/invoicetemplates/index.js +34 -0
  75. package/dist/resources/invoicetemplates/types.d.ts +34 -0
  76. package/dist/resources/invoicetemplates/types.js +2 -0
  77. package/dist/resources/milestones/index.d.ts +18 -0
  78. package/dist/resources/milestones/index.js +34 -0
  79. package/dist/resources/milestones/types.d.ts +40 -0
  80. package/dist/resources/milestones/types.js +2 -0
  81. package/dist/resources/projects/index.d.ts +20 -0
  82. package/dist/resources/projects/index.js +39 -0
  83. package/dist/resources/projects/types.d.ts +86 -0
  84. package/dist/resources/projects/types.js +14 -0
  85. package/dist/resources/projectstatuses/index.d.ts +18 -0
  86. package/dist/resources/projectstatuses/index.js +34 -0
  87. package/dist/resources/projectstatuses/types.d.ts +32 -0
  88. package/dist/resources/projectstatuses/types.js +2 -0
  89. package/dist/resources/projecttemplates/index.d.ts +18 -0
  90. package/dist/resources/projecttemplates/index.js +34 -0
  91. package/dist/resources/projecttemplates/types.d.ts +29 -0
  92. package/dist/resources/projecttemplates/types.js +2 -0
  93. package/dist/resources/reports/index.d.ts +18 -0
  94. package/dist/resources/reports/index.js +34 -0
  95. package/dist/resources/reports/types.d.ts +90 -0
  96. package/dist/resources/reports/types.js +2 -0
  97. package/dist/resources/sessions/index.d.ts +18 -0
  98. package/dist/resources/sessions/index.js +35 -0
  99. package/dist/resources/sessions/types.d.ts +28 -0
  100. package/dist/resources/sessions/types.js +2 -0
  101. package/dist/resources/tasklists/index.d.ts +18 -0
  102. package/dist/resources/tasklists/index.js +34 -0
  103. package/dist/resources/tasklists/types.d.ts +35 -0
  104. package/dist/resources/tasklists/types.js +2 -0
  105. package/dist/resources/tasks/index.d.ts +18 -0
  106. package/dist/resources/tasks/index.js +34 -0
  107. package/dist/resources/tasks/types.d.ts +64 -0
  108. package/dist/resources/tasks/types.js +2 -0
  109. package/dist/resources/users/index.d.ts +22 -0
  110. package/dist/resources/users/index.js +40 -0
  111. package/dist/resources/users/types.d.ts +86 -0
  112. package/dist/resources/users/types.js +2 -0
  113. package/dist/resources/usertasks/index.d.ts +18 -0
  114. package/dist/resources/usertasks/index.js +41 -0
  115. package/dist/resources/usertasks/types.d.ts +31 -0
  116. package/dist/resources/usertasks/types.js +2 -0
  117. package/dist/resources/workflows/index.d.ts +18 -0
  118. package/dist/resources/workflows/index.js +34 -0
  119. package/dist/resources/workflows/types.d.ts +31 -0
  120. package/dist/resources/workflows/types.js +2 -0
  121. package/dist/resources/workflowstatuses/index.d.ts +18 -0
  122. package/dist/resources/workflowstatuses/index.js +34 -0
  123. package/dist/resources/workflowstatuses/types.d.ts +35 -0
  124. package/dist/resources/workflowstatuses/types.js +2 -0
  125. package/dist/types.d.ts +25 -0
  126. package/dist/types.js +2 -0
  127. package/package.json +6 -6
  128. package/src/abstract.ts +8 -12
  129. package/src/remote.ts +1 -1
  130. package/yarn-error.log +0 -126
@@ -0,0 +1,23 @@
1
+ import { AuthInterface, GenericListConfig } from "./types";
2
+ export interface AbstractResourceInterface {
3
+ }
4
+ export declare class AbstractResource {
5
+ protected auth: AuthInterface;
6
+ protected resourceKey: string | null;
7
+ protected responseKey: string | null;
8
+ protected filterDates: string[];
9
+ constructor(auth: AuthInterface, resourceKey: string, responseKey?: string | null);
10
+ private constructUrl;
11
+ private constructAuth;
12
+ private constructHeaders;
13
+ private isTimestampKey;
14
+ private toTimestamp;
15
+ private processCustomFilters;
16
+ private constructFilter;
17
+ private constructInclude;
18
+ baseGet: (id: number | null) => Promise<object | null>;
19
+ baseList: (config?: GenericListConfig) => Promise<object[]>;
20
+ baseCreate: (data: object) => Promise<any>;
21
+ baseUpdate: (id: number | null, data: object) => Promise<any>;
22
+ baseDelete: (id: number) => Promise<boolean>;
23
+ }
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AbstractResource = void 0;
16
+ const remote_1 = __importDefault(require("./remote"));
17
+ class AbstractResource {
18
+ constructor(auth, resourceKey, responseKey = null) {
19
+ this.auth = { userApi: '', password: '' };
20
+ this.resourceKey = null;
21
+ this.responseKey = null;
22
+ this.filterDates = [];
23
+ this.constructUrl = (id) => {
24
+ return this.resourceKey + (id ? '/' + id : '');
25
+ };
26
+ this.constructAuth = () => {
27
+ return {
28
+ username: this.auth.userApi,
29
+ password: this.auth.password || 'apiKey',
30
+ };
31
+ };
32
+ this.constructHeaders = () => {
33
+ return {
34
+ Accept: 'application/json',
35
+ };
36
+ };
37
+ this.isTimestampKey = (k) => {
38
+ return ['created_on', 'updated_on'].findIndex(i => k === i) > -1;
39
+ };
40
+ this.toTimestamp = (dt) => {
41
+ return Math.round((new Date(dt)).getTime() / 1000);
42
+ };
43
+ this.processCustomFilters = (filters) => {
44
+ const whereVar = Object.keys(filters).map(k => {
45
+ const f = filters[k];
46
+ const fVal = f.value;
47
+ const rKey = f.key ? f.key : k;
48
+ const rOp = f.operator ? f.operator : '=';
49
+ const rVal = this.isTimestampKey(rKey) && typeof fVal === 'string'
50
+ ? this.toTimestamp(fVal)
51
+ : fVal;
52
+ switch (f.operator) {
53
+ case 'in':
54
+ case 'not in':
55
+ const v = Array.isArray(rVal) ? rVal : [rVal];
56
+ return rKey + ' ' + rOp + ' (' + v.join(',') + ')';
57
+ case 'like':
58
+ case 'not like':
59
+ return rKey + ' ' + rOp + ' "' + rVal + '"';
60
+ default:
61
+ return rKey + rOp + rVal;
62
+ }
63
+ }).filter(s => s !== '').join(' and ');
64
+ return whereVar.trim();
65
+ };
66
+ this.constructFilter = (filters) => {
67
+ const whereVar = Object.keys(filters).map(k => {
68
+ const f = filters[k];
69
+ if (k === '_custom') {
70
+ return this.processCustomFilters(f);
71
+ }
72
+ else if (Array.isArray(f)) {
73
+ return (k + ' in (' + f.join(',') + ')');
74
+ }
75
+ else if (f === null || typeof f === 'string' || typeof f === 'number' || typeof f === 'boolean') {
76
+ const v = this.isTimestampKey(k) && typeof f === 'string' ? this.toTimestamp(f) : f;
77
+ return (k + '=' + f).trim();
78
+ }
79
+ return '';
80
+ }).filter(s => s !== '').join(' and ');
81
+ return whereVar.trim();
82
+ };
83
+ this.constructInclude = (includes) => {
84
+ if (!includes.length) {
85
+ return null;
86
+ }
87
+ return includes.join(',');
88
+ };
89
+ this.baseGet = (id) => __awaiter(this, void 0, void 0, function* () {
90
+ const response = yield remote_1.default.get({
91
+ url: this.constructUrl(id),
92
+ config: {
93
+ auth: this.constructAuth(),
94
+ headers: this.constructHeaders(),
95
+ },
96
+ });
97
+ const responseKey = this.responseKey !== null ? this.responseKey : this.resourceKey;
98
+ if (responseKey &&
99
+ response &&
100
+ response.status >= 200 &&
101
+ response.status < 300 &&
102
+ response.data.hasOwnProperty(responseKey)) {
103
+ console.log('RESPONSE KEY', responseKey, response.data);
104
+ const data = response.data[responseKey];
105
+ if (Array.isArray(data)) {
106
+ console.log('AXIOS RESPONSE', data[0]);
107
+ return data.length > 0 ? data[0] : null;
108
+ }
109
+ else if (data) {
110
+ return data;
111
+ }
112
+ }
113
+ return null;
114
+ });
115
+ this.baseList = (...args_1) => __awaiter(this, [...args_1], void 0, function* (config = {}) {
116
+ const filter = this.constructFilter(config.filter ? config.filter : {});
117
+ const include = this.constructInclude(config.include ? config.include : []);
118
+ const response = yield remote_1.default.get({
119
+ url: this.constructUrl(),
120
+ config: {
121
+ auth: this.constructAuth(),
122
+ headers: this.constructHeaders(),
123
+ params: filter || include
124
+ ? {
125
+ where: filter || undefined,
126
+ include: include || undefined,
127
+ }
128
+ : undefined,
129
+ },
130
+ });
131
+ const responseKey = this.responseKey !== null ? this.responseKey : this.resourceKey;
132
+ if (responseKey &&
133
+ response &&
134
+ response.status >= 200 &&
135
+ response.status < 300 &&
136
+ response.data.hasOwnProperty(responseKey)) {
137
+ const data = response.data[responseKey];
138
+ console.log('AXIOS RESPONSE', data);
139
+ return data;
140
+ }
141
+ return [];
142
+ });
143
+ this.baseCreate = (data) => __awaiter(this, void 0, void 0, function* () {
144
+ const response = yield remote_1.default.post({
145
+ url: this.constructUrl(),
146
+ config: {
147
+ auth: this.constructAuth(),
148
+ headers: this.constructHeaders(),
149
+ },
150
+ data: data,
151
+ });
152
+ const responseKey = this.responseKey !== null ? this.responseKey : this.resourceKey;
153
+ if (responseKey &&
154
+ response &&
155
+ response.status >= 200 &&
156
+ response.status < 300 &&
157
+ response.data.hasOwnProperty(responseKey)) {
158
+ const data = response.data[responseKey];
159
+ if (Array.isArray(data)) {
160
+ console.log('AXIOS RESPONSE', data[0]);
161
+ return data.length > 0 ? data[0] : null;
162
+ }
163
+ else if (data) {
164
+ return data;
165
+ }
166
+ }
167
+ return null;
168
+ });
169
+ this.baseUpdate = (id, data) => __awaiter(this, void 0, void 0, function* () {
170
+ const response = yield remote_1.default.put({
171
+ url: this.constructUrl(id),
172
+ config: {
173
+ auth: this.constructAuth(),
174
+ headers: this.constructHeaders(),
175
+ },
176
+ data: data,
177
+ });
178
+ const responseKey = this.responseKey !== null ? this.responseKey : this.resourceKey;
179
+ if (responseKey &&
180
+ response &&
181
+ response.status >= 200 &&
182
+ response.status < 300 &&
183
+ response.data.hasOwnProperty(responseKey)) {
184
+ const data = response.data[responseKey];
185
+ if (Array.isArray(data)) {
186
+ console.log('AXIOS RESPONSE', data[0]);
187
+ return data.length > 0 ? data[0] : null;
188
+ }
189
+ else if (data) {
190
+ return data;
191
+ }
192
+ }
193
+ return null;
194
+ });
195
+ this.baseDelete = (id) => __awaiter(this, void 0, void 0, function* () {
196
+ const response = yield remote_1.default.delete({
197
+ url: this.constructUrl(id),
198
+ config: {
199
+ auth: this.constructAuth(),
200
+ headers: this.constructHeaders(),
201
+ },
202
+ });
203
+ return !!(response && response.status >= 200 && response.status < 300);
204
+ });
205
+ this.auth = auth;
206
+ this.resourceKey = resourceKey;
207
+ this.responseKey = responseKey;
208
+ }
209
+ }
210
+ exports.AbstractResource = AbstractResource;
@@ -0,0 +1,6 @@
1
+ import { PaymoResourceHandlerInterface } from "./resources";
2
+ declare class Paymo {
3
+ static instances: PaymoResourceHandlerInterface[];
4
+ static connect: (userOrApi: string, password?: string | null) => PaymoResourceHandlerInterface;
5
+ }
6
+ export default Paymo;
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const resources_1 = __importDefault(require("./resources"));
7
+ class Paymo {
8
+ }
9
+ Paymo.instances = [];
10
+ Paymo.connect = (userOrApi, password = null) => {
11
+ let handler = Paymo.instances.find(i => i.isApiUser(userOrApi));
12
+ if (!handler) {
13
+ handler = new resources_1.default(userOrApi, password);
14
+ Paymo.instances.push(handler);
15
+ }
16
+ return handler;
17
+ };
18
+ exports.default = Paymo;
@@ -0,0 +1,9 @@
1
+ import { AxiosResponse } from "axios";
2
+ declare class XhrWrapper {
3
+ static get: (d: any) => Promise<AxiosResponse | null>;
4
+ static post: (d: any) => Promise<AxiosResponse<any, any>>;
5
+ static put: (d: any) => Promise<AxiosResponse<any, any>>;
6
+ static delete: (d: any) => Promise<AxiosResponse | null>;
7
+ static test: () => Promise<void>;
8
+ }
9
+ export default XhrWrapper;
package/dist/remote.js ADDED
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ var _a;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const axios_1 = __importDefault(require("axios"));
17
+ // export interface XhrWrapperInterface {
18
+ // get:()=>void
19
+ // post:()=>void
20
+ // put:()=>void
21
+ // delete:()=>void
22
+ // }
23
+ const paymoAxios = axios_1.default.create({
24
+ baseURL: 'https://app.paymoapp.com/api/',
25
+ headers: { Accept: 'application/json' },
26
+ });
27
+ class XhrWrapper {
28
+ }
29
+ _a = XhrWrapper;
30
+ XhrWrapper.get = (d) => __awaiter(void 0, void 0, void 0, function* () {
31
+ console.log('AXIOS GET CALL', d);
32
+ return yield paymoAxios.get(d.url, d.config).catch((e) => {
33
+ console.log('ERROR:', e.message);
34
+ throw new Error('PAYMO GET FAILED :' + e);
35
+ });
36
+ });
37
+ XhrWrapper.post = (d) => __awaiter(void 0, void 0, void 0, function* () {
38
+ console.log('AXIOS POST CALL', d);
39
+ return yield paymoAxios.post(d.url, d.data, d.config).catch((e) => {
40
+ console.log('ERROR:', e.message);
41
+ throw new Error('PAYMO POST FAILED :' + e);
42
+ });
43
+ });
44
+ XhrWrapper.put = (d) => __awaiter(void 0, void 0, void 0, function* () {
45
+ console.log('AXIOS PUT CALL', d);
46
+ return yield paymoAxios.put(d.url, d.data, d.config).catch((e) => {
47
+ console.log('ERROR:', e.message);
48
+ throw new Error('PAYMO PUT FAILED :' + e);
49
+ });
50
+ });
51
+ XhrWrapper.delete = (d) => __awaiter(void 0, void 0, void 0, function* () {
52
+ console.log('AXIOS DELETE CALL', d);
53
+ return yield paymoAxios.delete(d.url, d.config).catch((e) => {
54
+ console.log('ERROR:', e.message);
55
+ throw new Error('PAYMO DELETE FAILED :' + e);
56
+ });
57
+ });
58
+ XhrWrapper.test = () => __awaiter(void 0, void 0, void 0, function* () {
59
+ const PAYMOAPI = 'YOUR_PAYMO_API_KEY';
60
+ const url = 'projects?include=client,tasks.entries';
61
+ const d = {
62
+ auth: {
63
+ username: PAYMOAPI,
64
+ password: 'abc123',
65
+ },
66
+ headers: {
67
+ Accept: 'application/json',
68
+ },
69
+ };
70
+ const instance = axios_1.default.create();
71
+ instance.defaults.headers.common = {};
72
+ instance.defaults.headers.common.accept = 'application/json';
73
+ //const { data } = await instance.get(generatedUrl);
74
+ console.log('AXIOS DEL CALL', d);
75
+ const response = yield instance.get(url, d).catch((e) => {
76
+ throw new Error('GET PAYMO FAILED :' + e);
77
+ });
78
+ console.log('DEL PAYMO RESPONSE', response);
79
+ });
80
+ exports.default = XhrWrapper;
@@ -0,0 +1,18 @@
1
+ import { AbstractResource, AbstractResourceInterface } from '../../abstract';
2
+ import { AuthInterface } from "../../types";
3
+ import { _Template_ListConfig, _Template_TypeCreate, _Template_TypeResponse, _Template_TypeUpdate } from "./types";
4
+ export interface _Template_Handler extends AbstractResourceInterface {
5
+ get: (id: number) => Promise<_Template_TypeResponse | null>;
6
+ list: (config?: _Template_ListConfig) => Promise<_Template_TypeResponse[]>;
7
+ create: (d: _Template_TypeCreate) => Promise<_Template_TypeResponse | null>;
8
+ update: (id: number, data: _Template_TypeUpdate) => Promise<_Template_TypeResponse | null>;
9
+ delete: (id: number) => Promise<boolean>;
10
+ }
11
+ export declare class _Template_ extends AbstractResource implements _Template_Handler {
12
+ constructor(auth: AuthInterface);
13
+ get: (id: number) => Promise<_Template_TypeResponse | null>;
14
+ list: (config?: _Template_ListConfig) => Promise<_Template_TypeResponse[]>;
15
+ create: (data: _Template_TypeCreate) => Promise<_Template_TypeResponse | null>;
16
+ update: (id: number, data: _Template_TypeUpdate) => Promise<_Template_TypeResponse | null>;
17
+ delete: (id: number) => Promise<boolean>;
18
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports._Template_ = void 0;
13
+ const abstract_1 = require("../../abstract");
14
+ class _Template_ extends abstract_1.AbstractResource {
15
+ constructor(auth) {
16
+ super(auth, '_template_');
17
+ this.get = (id) => __awaiter(this, void 0, void 0, function* () {
18
+ return (yield this.baseGet(id));
19
+ });
20
+ this.list = (...args_1) => __awaiter(this, [...args_1], void 0, function* (config = {}) {
21
+ return (yield this.baseList(config));
22
+ });
23
+ this.create = (data) => __awaiter(this, void 0, void 0, function* () {
24
+ return (yield this.baseCreate(data));
25
+ });
26
+ this.update = (id, data) => __awaiter(this, void 0, void 0, function* () {
27
+ return (yield this.baseUpdate(id, data));
28
+ });
29
+ this.delete = (id) => __awaiter(this, void 0, void 0, function* () {
30
+ return yield this.baseDelete(id);
31
+ });
32
+ }
33
+ }
34
+ exports._Template_ = _Template_;
@@ -0,0 +1,25 @@
1
+ import { FilterOperator, GenericListConfig, Merge } from "../../types";
2
+ export interface _Template_TypeRead {
3
+ readonly id: number;
4
+ readonly created_on: string;
5
+ readonly updated_on: string;
6
+ }
7
+ export interface _Template_TypeUpdate {
8
+ }
9
+ export type _Template_TypeResponse = Merge<_Template_TypeUpdate, Merge<_Template_TypeRead, {}>>;
10
+ export interface _Template_TypeCreate extends _Template_TypeUpdate {
11
+ }
12
+ export interface _Template_TypeFilter {
13
+ }
14
+ export interface _Template_FilterCondition extends _Template_TypeFilter {
15
+ _custom?: {
16
+ [k: string]: {
17
+ key?: Extract<keyof _Template_TypeFilter, string>;
18
+ operator?: FilterOperator;
19
+ value: string | number | boolean | null | number[];
20
+ };
21
+ };
22
+ }
23
+ export interface _Template_ListConfig extends GenericListConfig {
24
+ filter?: _Template_FilterCondition;
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ import { AbstractResource, AbstractResourceInterface } from '../../abstract';
2
+ import { AuthInterface } from '../../types';
3
+ import { BookingsListConfig, BookingsTypeCreate, BookingsTypeResponse, BookingsTypeUpdate } from './types';
4
+ export interface BookingsHandler extends AbstractResourceInterface {
5
+ get: (id: number) => Promise<BookingsTypeResponse | null>;
6
+ list: (config?: BookingsListConfig) => Promise<BookingsTypeResponse[]>;
7
+ create: (d: BookingsTypeCreate) => Promise<BookingsTypeResponse | null>;
8
+ update: (id: number, data: BookingsTypeUpdate) => Promise<BookingsTypeResponse | null>;
9
+ delete: (id: number) => Promise<boolean>;
10
+ }
11
+ export declare class Bookings extends AbstractResource implements BookingsHandler {
12
+ constructor(auth: AuthInterface);
13
+ get: (id: number) => Promise<BookingsTypeResponse | null>;
14
+ list: (config?: BookingsListConfig) => Promise<BookingsTypeResponse[]>;
15
+ create: (data: BookingsTypeCreate) => Promise<BookingsTypeResponse | null>;
16
+ update: (id: number, data: BookingsTypeUpdate) => Promise<BookingsTypeResponse | null>;
17
+ delete: (id: number) => Promise<boolean>;
18
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Bookings = void 0;
13
+ const abstract_1 = require("../../abstract");
14
+ class Bookings extends abstract_1.AbstractResource {
15
+ constructor(auth) {
16
+ super(auth, 'bookings');
17
+ this.get = (id) => __awaiter(this, void 0, void 0, function* () {
18
+ return (yield this.baseGet(id));
19
+ });
20
+ this.list = (...args_1) => __awaiter(this, [...args_1], void 0, function* (config = {}) {
21
+ const validConfig = !!config &&
22
+ config.filter &&
23
+ (config.filter.user_task_id ||
24
+ config.filter.task_id ||
25
+ config.filter.user_id ||
26
+ config.filter.project_id ||
27
+ (config.filter.date_interval &&
28
+ Array.isArray(config.filter.date_interval) &&
29
+ config.filter.date_interval.length === 2) ||
30
+ (config.filter.start_date && config.filter.end_date));
31
+ if (!validConfig) {
32
+ console.log('Booking list requires at least one valid filter condition');
33
+ return [];
34
+ }
35
+ return (yield this.baseList(config));
36
+ });
37
+ this.create = (data) => __awaiter(this, void 0, void 0, function* () {
38
+ return (yield this.baseCreate(data));
39
+ });
40
+ this.update = (id, data) => __awaiter(this, void 0, void 0, function* () {
41
+ return (yield this.baseUpdate(id, data));
42
+ });
43
+ this.delete = (id) => __awaiter(this, void 0, void 0, function* () {
44
+ return yield this.baseDelete(id);
45
+ });
46
+ this.filterDates = ['start_date', 'end_date'];
47
+ }
48
+ }
49
+ exports.Bookings = Bookings;
@@ -0,0 +1,49 @@
1
+ import { FilterOperator, GenericListConfig, Merge } from "../../types";
2
+ export interface BookingsTypeRead {
3
+ readonly id: number;
4
+ readonly created_on: string;
5
+ readonly updated_on: string;
6
+ readonly creator_id: number;
7
+ }
8
+ export interface BookingsTypeUpdate {
9
+ user_task_id?: number;
10
+ start_date?: string;
11
+ end_date?: string;
12
+ hours_per_day?: number;
13
+ description?: string;
14
+ }
15
+ export type BookingsTypeResponse = Merge<BookingsTypeUpdate, Merge<BookingsTypeRead, {
16
+ booked_hours: any | null;
17
+ start_date: string;
18
+ start_time: string | null;
19
+ end_date: string;
20
+ end_time: string | null;
21
+ }>>;
22
+ export interface BookingsTypeCreate extends BookingsTypeUpdate {
23
+ user_task_id: number;
24
+ start_date: string;
25
+ end_date: string;
26
+ hours_per_day: number;
27
+ }
28
+ export interface BookingsTypeFilter {
29
+ user_task_id?: number;
30
+ task_id?: number;
31
+ user_id?: number;
32
+ project_id?: number;
33
+ date_interval?: string[];
34
+ hours_per_day?: number;
35
+ start_date?: string;
36
+ end_date?: string;
37
+ }
38
+ export interface BookingsFilterCondition extends BookingsTypeFilter {
39
+ _custom?: {
40
+ [k: string]: {
41
+ key?: Extract<keyof BookingsTypeFilter, string>;
42
+ operator?: FilterOperator;
43
+ value: string | number | boolean | null | number[];
44
+ };
45
+ };
46
+ }
47
+ export interface BookingsListConfig extends GenericListConfig {
48
+ filter?: BookingsFilterCondition;
49
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ import { AbstractResource, AbstractResourceInterface } from '../../abstract';
2
+ import { AuthInterface } from "../../types";
3
+ import { ClientContactsListConfig, ClientContactsTypeCreate, ClientContactsTypeResponse, ClientContactsTypeUpdate } from "./types";
4
+ export interface ClientContactsHandler extends AbstractResourceInterface {
5
+ get: (id: number) => Promise<ClientContactsTypeResponse | null>;
6
+ list: (config?: ClientContactsListConfig) => Promise<ClientContactsTypeResponse[]>;
7
+ create: (d: ClientContactsTypeCreate) => Promise<ClientContactsTypeResponse | null>;
8
+ update: (id: number, data: ClientContactsTypeUpdate) => Promise<ClientContactsTypeResponse | null>;
9
+ delete: (id: number) => Promise<boolean>;
10
+ }
11
+ export declare class ClientContacts extends AbstractResource implements ClientContactsHandler {
12
+ constructor(auth: AuthInterface);
13
+ get: (id: number) => Promise<ClientContactsTypeResponse | null>;
14
+ list: (config?: ClientContactsListConfig) => Promise<ClientContactsTypeResponse[]>;
15
+ create: (data: ClientContactsTypeCreate) => Promise<ClientContactsTypeResponse | null>;
16
+ update: (id: number, data: ClientContactsTypeUpdate) => Promise<ClientContactsTypeResponse | null>;
17
+ delete: (id: number) => Promise<boolean>;
18
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ClientContacts = void 0;
13
+ const abstract_1 = require("../../abstract");
14
+ class ClientContacts extends abstract_1.AbstractResource {
15
+ constructor(auth) {
16
+ super(auth, 'clientcontacts');
17
+ this.get = (id) => __awaiter(this, void 0, void 0, function* () {
18
+ return (yield this.baseGet(id));
19
+ });
20
+ this.list = (...args_1) => __awaiter(this, [...args_1], void 0, function* (config = {}) {
21
+ return (yield this.baseList(config));
22
+ });
23
+ this.create = (data) => __awaiter(this, void 0, void 0, function* () {
24
+ return (yield this.baseCreate(data));
25
+ });
26
+ this.update = (id, data) => __awaiter(this, void 0, void 0, function* () {
27
+ return (yield this.baseUpdate(id, data));
28
+ });
29
+ this.delete = (id) => __awaiter(this, void 0, void 0, function* () {
30
+ return yield this.baseDelete(id);
31
+ });
32
+ }
33
+ }
34
+ exports.ClientContacts = ClientContacts;