conductor-node 0.1.1 → 0.1.4

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.
@@ -9,4 +9,5 @@ export default class BaseClient {
9
9
  protected readonly verbose: boolean;
10
10
  protected readonly serverURL: string;
11
11
  constructor({ apiKey, verbose, environment, }: BaseClientOptions);
12
+ protected sendAPIRequest<T>(username: string, requestObj: T, apiPath: string): Promise<T>;
12
13
  }
@@ -16,5 +16,28 @@ class BaseClient {
16
16
  this.verbose = verbose;
17
17
  this.serverURL = (0, environment_1.envToBaseServerURL)(environment);
18
18
  }
19
+ async sendAPIRequest(username, requestObj, apiPath) {
20
+ const apiServerURL = `${this.serverURL}/${apiPath}`;
21
+ if (this.verbose) {
22
+ console.log(`Client sent request to ${apiServerURL} for user ${username}:`, JSON.stringify(requestObj, null, 2));
23
+ }
24
+ const response = await fetch(apiServerURL, {
25
+ body: JSON.stringify({ username, requestObj }),
26
+ headers: {
27
+ "Content-Type": "application/json",
28
+ Authorization: `Bearer ${this.apiKey}`,
29
+ },
30
+ method: "POST",
31
+ });
32
+ if (response.status >= 400) {
33
+ const errorMessage = (await response.text()) || response.statusText;
34
+ throw new Error(`Request to ${apiServerURL} failed with status ${response.status}: ${errorMessage}`);
35
+ }
36
+ const responseObj = (await response.json());
37
+ if (this.verbose) {
38
+ console.log(`Client received response for user ${username}:`, JSON.stringify(responseObj, null, 2));
39
+ }
40
+ return responseObj;
41
+ }
19
42
  }
20
43
  exports.default = BaseClient;
@@ -11,26 +11,7 @@ class ClientQBD extends BaseClient_1.default {
11
11
  * Available APIs: https://developer.intuit.com/app/developer/qbdesktop/docs/api-reference/qbdesktop
12
12
  */
13
13
  async sendRequest(qbwcUsername, requestObj) {
14
- const apiServerURL = `${this.serverURL}/qbd`;
15
- if (this.verbose) {
16
- console.log(`Client sent request to ${apiServerURL} for user ${qbwcUsername}:`, JSON.stringify(requestObj, null, 2));
17
- }
18
- const response = await fetch(apiServerURL, {
19
- body: JSON.stringify({ qbwcUsername, requestObj }),
20
- headers: {
21
- "Content-Type": "application/json",
22
- Authorization: `Bearer ${this.apiKey}`,
23
- },
24
- method: "POST",
25
- });
26
- if (response.status >= 400) {
27
- throw new Error(`Request to ${apiServerURL} failed with status ${response.status}: ${response.statusText}`);
28
- }
29
- const responseObj = (await response.json());
30
- if (this.verbose) {
31
- console.log(`Client received response for user ${qbwcUsername}:`, JSON.stringify(responseObj, null, 2));
32
- }
33
- return responseObj;
14
+ return this.sendAPIRequest(qbwcUsername, requestObj, "qbd");
34
15
  }
35
16
  /**
36
17
  * Perform the same activities as a user does in the QB New Account form,
@@ -79,7 +79,7 @@ export interface AccountAdd {
79
79
  /**
80
80
  * The date when an opening balance was entered for this account.
81
81
  */
82
- OpenBalanceDate?: Date;
82
+ OpenBalanceDate?: string;
83
83
  /**
84
84
  * Each item on a sales form is assigned a sales-tax code that indicates
85
85
  * whether the item is taxable or non-taxable, and why. Two general codes,
@@ -117,11 +117,6 @@ export interface AccountAdd {
117
117
  export interface AccountQueryRq {
118
118
  ListID?: string;
119
119
  FullName?: string;
120
- /**
121
- * Limits the number of objects that a query returns. (To get a count of how
122
- * many objects could possibly be returned, use the metaData query attribute.)
123
- * If you include a `MaxReturned` value, it must be at least 1.
124
- */
125
120
  /**
126
121
  * Limits the number of objects that a query returns. (To get a count of how
127
122
  * many objects could possibly be returned, use the metaData query attribute.)
@@ -146,7 +141,7 @@ export interface AccountQueryRq {
146
141
  * (2003-02-14T00:00:00). If you omit `FromModifiedDate`, it will be set to
147
142
  * 1970-01-01T00:00:00 (1969-12-31T16:00:00-08:00 PST).
148
143
  */
149
- FromModifiedDate?: Date;
144
+ FromModifiedDate?: string;
150
145
  /**
151
146
  * Selects objects modified on or before this date.
152
147
  *
@@ -159,7 +154,7 @@ export interface AccountQueryRq {
159
154
  * day (2003-02-14T23:59:59). If you omit `ToModifiedDate` altogether, it will
160
155
  * be set to 2038-01-19T03:14:07 (2038-01-18T19:14:07-08:00 PST).
161
156
  */
162
- ToModifiedDate?: Date;
157
+ ToModifiedDate?: string;
163
158
  /**
164
159
  * Filters according to the object’s `Name`.
165
160
  */
@@ -26,7 +26,7 @@ export interface CustomerQueryRq {
26
26
  * (2003-02-14T00:00:00). If you omit `FromModifiedDate`, it will be set to
27
27
  * 1970-01-01T00:00:00 (1969-12-31T16:00:00-08:00 PST).
28
28
  */
29
- FromModifiedDate?: Date;
29
+ FromModifiedDate?: string;
30
30
  /**
31
31
  * Selects objects modified on or before this date.
32
32
  *
@@ -39,7 +39,7 @@ export interface CustomerQueryRq {
39
39
  * day (2003-02-14T23:59:59). If you omit `ToModifiedDate` altogether, it will
40
40
  * be set to 2038-01-19T03:14:07 (2038-01-18T19:14:07-08:00 PST).
41
41
  */
42
- ToModifiedDate?: Date;
42
+ ToModifiedDate?: string;
43
43
  /**
44
44
  * Filters according to the object’s `Name`.
45
45
  */
@@ -93,8 +93,8 @@ export interface CustomerQueryRs {
93
93
  }
94
94
  export interface CustomerRet {
95
95
  ListID: string;
96
- TimeCreated: Date;
97
- TimeModified: Date;
96
+ TimeCreated: string;
97
+ TimeModified: string;
98
98
  EditSequence: string;
99
99
  Name: string;
100
100
  FullName: string;
@@ -136,9 +136,9 @@ export interface CustomerRet {
136
136
  PreferredPaymentMethodRef?: PreferredPaymentMethodRef;
137
137
  CreditCardInfo?: CreditCardInfo;
138
138
  JobStatus?: JobStatus;
139
- JobStartDate?: Date;
140
- JobProjectedEndDate?: Date;
141
- JobEndDate?: Date;
139
+ JobStartDate?: string;
140
+ JobProjectedEndDate?: string;
141
+ JobEndDate?: string;
142
142
  JobDesc?: string;
143
143
  JobTypeRef?: JobTypeRef;
144
144
  Notes?: string;
@@ -66,7 +66,7 @@ export interface EmployeeQueryRq {
66
66
  * (2003-02-14T00:00:00). If you omit `FromModifiedDate`, it will be set to
67
67
  * 1970-01-01T00:00:00 (1969-12-31T16:00:00-08:00 PST).
68
68
  */
69
- FromModifiedDate?: Date;
69
+ FromModifiedDate?: string;
70
70
  /**
71
71
  * Selects objects modified on or before this date.
72
72
  *
@@ -79,7 +79,7 @@ export interface EmployeeQueryRq {
79
79
  * day (2003-02-14T23:59:59). If you omit `ToModifiedDate` altogether, it will
80
80
  * be set to 2038-01-19T03:14:07 (2038-01-18T19:14:07-08:00 PST).
81
81
  */
82
- ToModifiedDate?: Date;
82
+ ToModifiedDate?: string;
83
83
  /**
84
84
  * Filters according to the object’s `Name`.
85
85
  */
@@ -254,23 +254,23 @@ export interface EmployeeAdd {
254
254
  /**
255
255
  * An employee’s date of hire.
256
256
  */
257
- HiredDate?: Date;
257
+ HiredDate?: string;
258
258
  /**
259
259
  * Original hire date the employee was hired.
260
260
  */
261
- OriginalHireDate?: Date;
261
+ OriginalHireDate?: string;
262
262
  /**
263
263
  * Adjusted service date for the employee.
264
264
  */
265
- AdjustedServiceDate?: Date;
265
+ AdjustedServiceDate?: string;
266
266
  /**
267
267
  * The date on which this person’s employment with the company ended.
268
268
  */
269
- ReleasedDate?: Date;
269
+ ReleasedDate?: string;
270
270
  /**
271
271
  * Date of birth.
272
272
  */
273
- BirthDate?: Date;
273
+ BirthDate?: string;
274
274
  /**
275
275
  * Is employee a US citizen?
276
276
  */
@@ -294,7 +294,7 @@ export interface EmployeeAdd {
294
294
  /**
295
295
  * Date the employee’s work authorization expires.
296
296
  */
297
- WorkAuthExpireDate?: Date;
297
+ WorkAuthExpireDate?: string;
298
298
  /**
299
299
  * Is employee a US veteran?
300
300
  */
@@ -328,8 +328,8 @@ export interface EmployeeAdd {
328
328
  }
329
329
  export interface EmployeeRet {
330
330
  ListID: string;
331
- TimeCreated: Date;
332
- TimeModified: Date;
331
+ TimeCreated: string;
332
+ TimeModified: string;
333
333
  EditSequence: string;
334
334
  Name: string;
335
335
  IsActive?: boolean;
@@ -359,17 +359,17 @@ export interface EmployeeRet {
359
359
  Exempt?: Exempt;
360
360
  KeyEmployee?: KeyEmployee;
361
361
  Gender?: Gender;
362
- HiredDate?: Date;
363
- OriginalHireDate?: Date;
364
- AdjustedServiceDate?: Date;
365
- ReleasedDate?: Date;
366
- BirthDate?: Date;
362
+ HiredDate?: string;
363
+ OriginalHireDate?: string;
364
+ AdjustedServiceDate?: string;
365
+ ReleasedDate?: string;
366
+ BirthDate?: string;
367
367
  USCitizen?: USCitizen;
368
368
  Ethnicity?: Ethnicity;
369
369
  Disabled?: Disabled;
370
370
  DisabilityDesc?: string;
371
371
  OnFile?: OnFile;
372
- WorkAuthExpireDate?: Date;
372
+ WorkAuthExpireDate?: string;
373
373
  USVeteran?: USVeteran;
374
374
  MilitaryStatus?: MilitaryStatus;
375
375
  AccountNumber?: string;
@@ -408,17 +408,17 @@ export interface EmployeeMod {
408
408
  PartOrFullTime?: PartOrFullTime;
409
409
  Exempt?: Exempt;
410
410
  KeyEmployee?: KeyEmployee;
411
- HiredDate?: Date;
412
- OriginalHireDate?: Date;
413
- AdjustedServiceDate?: Date;
414
- ReleasedDate?: Date;
415
- BirthDate?: Date;
411
+ HiredDate?: string;
412
+ OriginalHireDate?: string;
413
+ AdjustedServiceDate?: string;
414
+ ReleasedDate?: string;
415
+ BirthDate?: string;
416
416
  USCitizen?: USCitizen;
417
417
  Ethnicity?: Ethnicity;
418
418
  Disabled?: Disabled;
419
419
  DisabilityDesc?: string;
420
420
  OnFile?: OnFile;
421
- WorkAuthExpireDate?: Date;
421
+ WorkAuthExpireDate?: string;
422
422
  USVeteran?: USVeteran;
423
423
  MilitaryStatus?: MilitaryStatus;
424
424
  AccountNumber?: string;
@@ -575,7 +575,7 @@ interface SickHours {
575
575
  * date on which sick leave or vacation hours in the current year began to
576
576
  * accrue.
577
577
  */
578
- AccrualStartDate?: Date;
578
+ AccrualStartDate?: string;
579
579
  }
580
580
  declare type AccrualPeriod = "BeginningOfYear" | "EveryHourOnPaycheck" | "EveryPaycheck";
581
581
  interface VacationHours {
@@ -585,6 +585,6 @@ interface VacationHours {
585
585
  MaximumHours?: string;
586
586
  IsResettingHoursEachNewYear?: boolean;
587
587
  HoursUsed?: string;
588
- AccrualStartDate?: Date;
588
+ AccrualStartDate?: string;
589
589
  }
590
590
  export {};
@@ -26,7 +26,7 @@ export interface VendorQueryRq {
26
26
  * (2003-02-14T00:00:00). If you omit `FromModifiedDate`, it will be set to
27
27
  * 1970-01-01T00:00:00 (1969-12-31T16:00:00-08:00 PST).
28
28
  */
29
- FromModifiedDate?: Date;
29
+ FromModifiedDate?: string;
30
30
  /**
31
31
  * Selects objects modified on or before this date.
32
32
  *
@@ -39,7 +39,7 @@ export interface VendorQueryRq {
39
39
  * day (2003-02-14T23:59:59). If you omit `ToModifiedDate` altogether, it will
40
40
  * be set to 2038-01-19T03:14:07 (2038-01-18T19:14:07-08:00 PST).
41
41
  */
42
- ToModifiedDate?: Date;
42
+ ToModifiedDate?: string;
43
43
  /**
44
44
  * Filters according to the object’s `Name`.
45
45
  */
@@ -101,8 +101,8 @@ export interface VendorQueryRs {
101
101
  }
102
102
  export interface VendorRet {
103
103
  ListID: string;
104
- TimeCreated: Date;
105
- TimeModified: Date;
104
+ TimeCreated: string;
105
+ TimeModified: string;
106
106
  EditSequence: string;
107
107
  Name: string;
108
108
  /**
@@ -46,7 +46,7 @@ export interface AdditionalContactRef {
46
46
  }
47
47
  export interface AdditionalNotesRet {
48
48
  NoteID: number;
49
- Date: Date;
49
+ Date: string;
50
50
  Note: string;
51
51
  }
52
52
  export interface BillingRateRef {
@@ -90,8 +90,8 @@ export interface ShipAddress {
90
90
  }
91
91
  export interface ContactsRet {
92
92
  ListID: string;
93
- TimeCreated: Date;
94
- TimeModified: Date;
93
+ TimeCreated: string;
94
+ TimeModified: string;
95
95
  EditSequence: string;
96
96
  Contact?: string;
97
97
  Salutation?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Conductor API wrapper",
5
5
  "author": "Danny Nemer <hi@DannyNemer.com>",
6
6
  "license": "MIT",