@tomei/finance 0.0.10 → 0.0.12
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.
- package/configs/config.js +6 -10
- package/dist/account/account.d.ts +2 -4
- package/dist/account/account.js +3 -55
- package/dist/account/account.js.map +1 -1
- package/dist/enum/intuit-client.enum.d.ts +13 -0
- package/dist/enum/intuit-client.enum.js +19 -0
- package/dist/enum/intuit-client.enum.js.map +1 -0
- package/dist/enum/quick-book-client-scopes.enum.d.ts +13 -0
- package/dist/enum/quick-book-client-scopes.enum.js +19 -0
- package/dist/enum/quick-book-client-scopes.enum.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/intuit-client/client.d.ts +14 -0
- package/dist/intuit-client/client.js +44 -0
- package/dist/intuit-client/client.js.map +1 -0
- package/dist/quickbook-client/client.d.ts +17 -0
- package/dist/quickbook-client/client.js +67 -0
- package/dist/quickbook-client/client.js.map +1 -0
- package/dist/quickbook-client/constant.d.ts +1 -0
- package/dist/quickbook-client/constant.js +5 -0
- package/dist/quickbook-client/constant.js.map +1 -0
- package/dist/quickbook-client/index.d.ts +4 -0
- package/dist/quickbook-client/index.js +8 -0
- package/dist/quickbook-client/index.js.map +1 -0
- package/dist/quickbook-client/interfaces/quickbook-client-options.interface.d.ts +8 -0
- package/dist/quickbook-client/interfaces/quickbook-client-options.interface.js +3 -0
- package/dist/quickbook-client/interfaces/quickbook-client-options.interface.js.map +1 -0
- package/dist/quickbook-client/quickbook-client.module-definition.d.ts +2 -0
- package/dist/quickbook-client/quickbook-client.module-definition.js +9 -0
- package/dist/quickbook-client/quickbook-client.module-definition.js.map +1 -0
- package/dist/quickbook-client/quickbook-client.module.d.ts +6 -0
- package/dist/quickbook-client/quickbook-client.module.js +34 -0
- package/dist/quickbook-client/quickbook-client.module.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/src/account/account.ts +9 -85
- package/src/enum/quick-book-client-scopes.enum.ts +14 -0
- package/src/index.ts +1 -3
- package/src/quickbook-client/client.ts +74 -0
- package/src/quickbook-client/constant.ts +1 -0
- package/src/quickbook-client/index.ts +9 -0
- package/src/quickbook-client/interfaces/quickbook-client-options.interface.ts +8 -0
- package/src/quickbook-client/quickbook-client.module-definition.ts +7 -0
- package/src/quickbook-client/quickbook-client.module.ts +24 -0
package/configs/config.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
require('dotenv').config();
|
|
2
|
-
|
|
3
1
|
const config = {
|
|
4
2
|
development: {
|
|
5
|
-
env: 'development',
|
|
6
3
|
accountingSystem: {
|
|
7
4
|
quickbooks: {
|
|
8
5
|
packageName: process.env.PACKAGE_NAME,
|
|
@@ -19,21 +16,20 @@ const config = {
|
|
|
19
16
|
EZC: {
|
|
20
17
|
accountingSystem: 'quickbooks',
|
|
21
18
|
companyName: process.env.COMPANY_NAME,
|
|
22
|
-
API_Key: process.env.
|
|
23
|
-
API_Secret: process.env.
|
|
24
|
-
redirectUrl: process.env.
|
|
19
|
+
API_Key: process.env.QUICKBOOK_API_KEY,
|
|
20
|
+
API_Secret: process.env.QUICKBOOK_API_SECRET,
|
|
21
|
+
redirectUrl: process.env.EZCASH_REDIRECT_URL,
|
|
25
22
|
},
|
|
26
23
|
EZG: {
|
|
27
24
|
accountingSystem: 'xero',
|
|
28
25
|
companyName: process.env.COMPANY_NAME,
|
|
29
|
-
API_Key: process.env.
|
|
30
|
-
API_Secret: process.env.
|
|
31
|
-
redirectUrl: process.env.
|
|
26
|
+
API_Key: process.env.QUICKBOOK_API_KEY,
|
|
27
|
+
API_Secret: process.env.QUICKBOOK_API_SECRET,
|
|
28
|
+
redirectUrl: process.env.EZGOLD_REDIRECT_URL,
|
|
32
29
|
},
|
|
33
30
|
},
|
|
34
31
|
},
|
|
35
32
|
test: {
|
|
36
|
-
env: 'development',
|
|
37
33
|
accountingSystem: {
|
|
38
34
|
quickbooks: {
|
|
39
35
|
packageName: '',
|
|
@@ -2,6 +2,7 @@ import { ObjectBase } from 'src/base/object.base.abstract';
|
|
|
2
2
|
import { PersonBase } from 'src/base/person.base.abstract';
|
|
3
3
|
import { IAccountOptions, ICreateAccountAttr } from './interfaces/account-attr.interface';
|
|
4
4
|
import { IAccountRepository } from './interfaces/account.repository.interface';
|
|
5
|
+
import * as OAuthClient from 'intuit-oauth';
|
|
5
6
|
export declare class Account {
|
|
6
7
|
accountRepository: IAccountRepository;
|
|
7
8
|
intuitClient: any;
|
|
@@ -18,8 +19,5 @@ export declare class Account {
|
|
|
18
19
|
refreshToken: string;
|
|
19
20
|
constructor(accountRepository: IAccountRepository, SysCode: string, options?: IAccountOptions);
|
|
20
21
|
init(params: ICreateAccountAttr): void;
|
|
21
|
-
|
|
22
|
-
connect(): Promise<any>;
|
|
23
|
-
oAuthCallback(url: string): Promise<void>;
|
|
24
|
-
createAccount(): Promise<import(".").AccountModel>;
|
|
22
|
+
create(client: OAuthClient, dbOptions: any): Promise<import(".").AccountModel>;
|
|
25
23
|
}
|
package/dist/account/account.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Account = void 0;
|
|
4
|
-
const OAuthClient = require("intuit-oauth");
|
|
5
|
-
const axios_1 = require("axios");
|
|
6
4
|
class Account {
|
|
7
5
|
constructor(accountRepository, SysCode, options) {
|
|
8
6
|
this.accountRepository = accountRepository;
|
|
@@ -15,18 +13,11 @@ class Account {
|
|
|
15
13
|
this.parentAccount = options.account;
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
|
-
this.intuitClient = new OAuthClient({
|
|
19
|
-
clientId: process.env.API_KEY,
|
|
20
|
-
clientSecret: process.env.API_SECRET,
|
|
21
|
-
environment: 'sandbox',
|
|
22
|
-
redirectUri: process.env.REDIRECT_URL,
|
|
23
|
-
});
|
|
24
16
|
}
|
|
25
17
|
init(params) {
|
|
26
18
|
this.Owner = params.Owner;
|
|
27
19
|
this.RelatedObject = params.RelatedObject;
|
|
28
20
|
const ownerData = this.Owner.getDetails();
|
|
29
|
-
console.log(ownerData, '<<<<<<<<OWNER_DATA');
|
|
30
21
|
if (!ownerData) {
|
|
31
22
|
throw new Error('Please save owner information in the database before creating an account');
|
|
32
23
|
}
|
|
@@ -48,50 +39,7 @@ class Account {
|
|
|
48
39
|
this.RelatedObjectType = 'RelatedObject';
|
|
49
40
|
this.isParamsInitialized = true;
|
|
50
41
|
}
|
|
51
|
-
async
|
|
52
|
-
try {
|
|
53
|
-
const authUrl = this.intuitClient.authorizeUri({
|
|
54
|
-
scope: [OAuthClient.scopes.Accounting, OAuthClient.scopes.OpenId],
|
|
55
|
-
state: 'testState',
|
|
56
|
-
});
|
|
57
|
-
console.log(authUrl, '<<<<<<<<AUTH_URL');
|
|
58
|
-
return authUrl;
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
throw error;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async connect() {
|
|
66
|
-
try {
|
|
67
|
-
const authUrl = this.intuitClient.authorizeUri({
|
|
68
|
-
scope: [OAuthClient.scopes.Accounting, OAuthClient.scopes.OpenId],
|
|
69
|
-
state: 'testState',
|
|
70
|
-
});
|
|
71
|
-
console.log(authUrl, '<<<<<<<<AUTH_URL');
|
|
72
|
-
const response = await axios_1.default.request({
|
|
73
|
-
url: authUrl,
|
|
74
|
-
method: 'GET',
|
|
75
|
-
});
|
|
76
|
-
console.log(response, '<<<<<<<<<<<<<<< FIRST RESPONSE');
|
|
77
|
-
const AuthResponse = await this.intuitClient.createToken(response.config.url);
|
|
78
|
-
console.log(AuthResponse, '<<<<<<<<<<<<<<< SECOND RESPONSE');
|
|
79
|
-
this.accessToken = AuthResponse.getJson().access_token;
|
|
80
|
-
this.refreshToken = AuthResponse.getJson().refresh_token;
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async oAuthCallback(url) {
|
|
88
|
-
const AuthResponse = await this.intuitClient.createToken(url);
|
|
89
|
-
console.log(AuthResponse, '<<<<<<<<<<<<<<< SECOND RESPONSE');
|
|
90
|
-
this.accessToken = AuthResponse.getJson().access_token;
|
|
91
|
-
this.refreshToken = AuthResponse.getJson().refresh_token;
|
|
92
|
-
}
|
|
93
|
-
async createAccount() {
|
|
94
|
-
await this.connect();
|
|
42
|
+
async create(client, dbOptions) {
|
|
95
43
|
if (!this.Owner || !this.RelatedObject) {
|
|
96
44
|
throw new Error('Owner must be set before creating an account." or "RelatedObject must be set before creating an account.');
|
|
97
45
|
}
|
|
@@ -101,8 +49,8 @@ class Account {
|
|
|
101
49
|
const account = await this.accountRepository.create({
|
|
102
50
|
Owner: this.Owner,
|
|
103
51
|
RelatedObject: this.RelatedObject,
|
|
104
|
-
Client:
|
|
105
|
-
});
|
|
52
|
+
Client: client,
|
|
53
|
+
}, dbOptions);
|
|
106
54
|
return account;
|
|
107
55
|
}
|
|
108
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/account/account.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/account/account.ts"],"names":[],"mappings":";;;AAQA,MAAa,OAAO;IAkBlB,YACE,iBAAqC,EACrC,OAAe,EACf,OAAyB;QAEzB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,IAAI,OAAO,EAAE;YACX,IAAI,OAAO,CAAC,MAAM,EAAE;gBAClB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aAC3B;YAED,IAAI,OAAO,CAAC,OAAO,EAAE;gBACnB,IAAI,CAAC,aAAa,GAAG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,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CACjD;YACE,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,MAAM,EAAE,MAAM;SACf,EACD,SAAS,CACV,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA9FD,0BA8FC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientScopes = void 0;
|
|
4
|
+
const OAuthClient = require("intuit-oauth");
|
|
5
|
+
var ClientScopes;
|
|
6
|
+
(function (ClientScopes) {
|
|
7
|
+
ClientScopes[ClientScopes["ACCOUNTING"] = OAuthClient.scopes.Accounting] = "ACCOUNTING";
|
|
8
|
+
ClientScopes[ClientScopes["PAYMENT"] = OAuthClient.scopes.Payment] = "PAYMENT";
|
|
9
|
+
ClientScopes[ClientScopes["PAYROLL"] = OAuthClient.scopes.Payroll] = "PAYROLL";
|
|
10
|
+
ClientScopes[ClientScopes["TIMETRACKING"] = OAuthClient.scopes.TimeTracking] = "TIMETRACKING";
|
|
11
|
+
ClientScopes[ClientScopes["BENEFITS"] = OAuthClient.scopes.Benefits] = "BENEFITS";
|
|
12
|
+
ClientScopes[ClientScopes["PROFILE"] = OAuthClient.scopes.Profile] = "PROFILE";
|
|
13
|
+
ClientScopes[ClientScopes["EMAIL"] = OAuthClient.scopes.Email] = "EMAIL";
|
|
14
|
+
ClientScopes[ClientScopes["PHONE"] = OAuthClient.scopes.Phone] = "PHONE";
|
|
15
|
+
ClientScopes[ClientScopes["ADDRESS"] = OAuthClient.scopes.Address] = "ADDRESS";
|
|
16
|
+
ClientScopes[ClientScopes["OPENID"] = OAuthClient.scopes.OpenId] = "OPENID";
|
|
17
|
+
ClientScopes[ClientScopes["INTUIT_NAME"] = OAuthClient.scopes.Intuit_name] = "INTUIT_NAME";
|
|
18
|
+
})(ClientScopes = exports.ClientScopes || (exports.ClientScopes = {}));
|
|
19
|
+
//# sourceMappingURL=intuit-client.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intuit-client.enum.js","sourceRoot":"","sources":["../../src/enum/intuit-client.enum.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,IAAY,YAYX;AAZD,WAAY,YAAY;IACtB,0CAAa,WAAW,CAAC,MAAM,CAAC,UAAU,gBAAA,CAAA;IAC1C,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,4CAAe,WAAW,CAAC,MAAM,CAAC,YAAY,kBAAA,CAAA;IAC9C,wCAAW,WAAW,CAAC,MAAM,CAAC,QAAQ,cAAA,CAAA;IACtC,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,qCAAQ,WAAW,CAAC,MAAM,CAAC,KAAK,WAAA,CAAA;IAChC,qCAAQ,WAAW,CAAC,MAAM,CAAC,KAAK,WAAA,CAAA;IAChC,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,sCAAS,WAAW,CAAC,MAAM,CAAC,MAAM,YAAA,CAAA;IAClC,2CAAc,WAAW,CAAC,MAAM,CAAC,WAAW,iBAAA,CAAA;AAC9C,CAAC,EAZW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAYvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientScopes = void 0;
|
|
4
|
+
const OAuthClient = require("intuit-oauth");
|
|
5
|
+
var ClientScopes;
|
|
6
|
+
(function (ClientScopes) {
|
|
7
|
+
ClientScopes[ClientScopes["ACCOUNTING"] = OAuthClient.scopes.Accounting] = "ACCOUNTING";
|
|
8
|
+
ClientScopes[ClientScopes["PAYMENT"] = OAuthClient.scopes.Payment] = "PAYMENT";
|
|
9
|
+
ClientScopes[ClientScopes["PAYROLL"] = OAuthClient.scopes.Payroll] = "PAYROLL";
|
|
10
|
+
ClientScopes[ClientScopes["TIMETRACKING"] = OAuthClient.scopes.TimeTracking] = "TIMETRACKING";
|
|
11
|
+
ClientScopes[ClientScopes["BENEFITS"] = OAuthClient.scopes.Benefits] = "BENEFITS";
|
|
12
|
+
ClientScopes[ClientScopes["PROFILE"] = OAuthClient.scopes.Profile] = "PROFILE";
|
|
13
|
+
ClientScopes[ClientScopes["EMAIL"] = OAuthClient.scopes.Email] = "EMAIL";
|
|
14
|
+
ClientScopes[ClientScopes["PHONE"] = OAuthClient.scopes.Phone] = "PHONE";
|
|
15
|
+
ClientScopes[ClientScopes["ADDRESS"] = OAuthClient.scopes.Address] = "ADDRESS";
|
|
16
|
+
ClientScopes[ClientScopes["OPENID"] = OAuthClient.scopes.OpenId] = "OPENID";
|
|
17
|
+
ClientScopes[ClientScopes["INTUIT_NAME"] = OAuthClient.scopes.Intuit_name] = "INTUIT_NAME";
|
|
18
|
+
})(ClientScopes = exports.ClientScopes || (exports.ClientScopes = {}));
|
|
19
|
+
//# sourceMappingURL=quick-book-client-scopes.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-book-client-scopes.enum.js","sourceRoot":"","sources":["../../src/enum/quick-book-client-scopes.enum.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,IAAY,YAYX;AAZD,WAAY,YAAY;IACtB,0CAAa,WAAW,CAAC,MAAM,CAAC,UAAU,gBAAA,CAAA;IAC1C,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,4CAAe,WAAW,CAAC,MAAM,CAAC,YAAY,kBAAA,CAAA;IAC9C,wCAAW,WAAW,CAAC,MAAM,CAAC,QAAQ,cAAA,CAAA;IACtC,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,qCAAQ,WAAW,CAAC,MAAM,CAAC,KAAK,WAAA,CAAA;IAChC,qCAAQ,WAAW,CAAC,MAAM,CAAC,KAAK,WAAA,CAAA;IAChC,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,sCAAS,WAAW,CAAC,MAAM,CAAC,MAAM,YAAA,CAAA;IAClC,2CAAc,WAAW,CAAC,MAAM,CAAC,WAAW,iBAAA,CAAA;AAC9C,CAAC,EAZW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAYvB"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./base"), exports);
|
|
18
18
|
__exportStar(require("./account"), exports);
|
|
19
|
+
__exportStar(require("./quickbook-client"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,4CAA0B;AAC1B,qDAAmC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as OAuthClient from 'intuit-oauth';
|
|
2
|
+
import { ClientScopes } from 'src/enum/intuit-client.enum';
|
|
3
|
+
export declare class IntuitClient {
|
|
4
|
+
private client;
|
|
5
|
+
accessToken: string;
|
|
6
|
+
refreshToken: string;
|
|
7
|
+
constructor();
|
|
8
|
+
connect(scopes: ClientScopes[]): Promise<any>;
|
|
9
|
+
authCallback(url: string): Promise<void>;
|
|
10
|
+
isTokenValid(): any;
|
|
11
|
+
refreshAccessToken(): Promise<void>;
|
|
12
|
+
logout(): Promise<void>;
|
|
13
|
+
getClient(): OAuthClient;
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntuitClient = void 0;
|
|
4
|
+
const OAuthClient = require("intuit-oauth");
|
|
5
|
+
class IntuitClient {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.client = new OAuthClient({
|
|
8
|
+
clientId: process.env.QUICKBOOK_API_KEY,
|
|
9
|
+
clientSecret: process.env.QUICKBOOK_API_SECRET,
|
|
10
|
+
environment: process.env.NODE_ENV === 'production' ? 'production' : 'sandbox',
|
|
11
|
+
redirectUri: process.env.INTUIT_REDIRECT_URL,
|
|
12
|
+
logging: process.env.NODE_ENV === 'production' ? false : true,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
connect(scopes) {
|
|
16
|
+
try {
|
|
17
|
+
const authUrl = this.client.authorizeUri({
|
|
18
|
+
scope: scopes,
|
|
19
|
+
state: 'testState',
|
|
20
|
+
});
|
|
21
|
+
return authUrl;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async authCallback(url) {
|
|
28
|
+
await this.client.createToken(url);
|
|
29
|
+
}
|
|
30
|
+
isTokenValid() {
|
|
31
|
+
return this.client.isAccessTokenValid();
|
|
32
|
+
}
|
|
33
|
+
async refreshAccessToken() {
|
|
34
|
+
await this.client.refresh();
|
|
35
|
+
}
|
|
36
|
+
async logout() {
|
|
37
|
+
await this.client.revokeToken();
|
|
38
|
+
}
|
|
39
|
+
async getClient() {
|
|
40
|
+
return this.client;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.IntuitClient = IntuitClient;
|
|
44
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,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AAS;QACb,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAhDD,oCAgDC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as OAuthClient from 'intuit-oauth';
|
|
2
|
+
import { ClientScopes } from 'src/enum/quick-book-client-scopes.enum';
|
|
3
|
+
import { IQuickBookClientModuleOptions } from './interfaces/quickbook-client-options.interface';
|
|
4
|
+
export declare class QuickBookClient {
|
|
5
|
+
private client;
|
|
6
|
+
accessToken: string;
|
|
7
|
+
refreshToken: string;
|
|
8
|
+
constructor(options: IQuickBookClientModuleOptions);
|
|
9
|
+
connect(scopes: ClientScopes[]): string;
|
|
10
|
+
authCallback(url: string): Promise<void>;
|
|
11
|
+
isTokenValid(): boolean;
|
|
12
|
+
refreshAccessToken(): Promise<void>;
|
|
13
|
+
logout(): Promise<void>;
|
|
14
|
+
getClient(): OAuthClient;
|
|
15
|
+
getCompanyId(): string;
|
|
16
|
+
validateAndRefreshToken(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuickBookClient = void 0;
|
|
4
|
+
const OAuthClient = require("intuit-oauth");
|
|
5
|
+
class QuickBookClient {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.client = new OAuthClient({
|
|
8
|
+
clientId: options.clientId,
|
|
9
|
+
clientSecret: options.clientSecret,
|
|
10
|
+
environment: options.environment,
|
|
11
|
+
redirectUri: options.redirectUri,
|
|
12
|
+
logging: options.logging,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
connect(scopes) {
|
|
16
|
+
try {
|
|
17
|
+
const authUrl = this.client.authorizeUri({
|
|
18
|
+
scope: scopes,
|
|
19
|
+
state: 'testState',
|
|
20
|
+
});
|
|
21
|
+
return authUrl;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async authCallback(url) {
|
|
28
|
+
try {
|
|
29
|
+
await this.client.createToken(url);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
isTokenValid() {
|
|
36
|
+
try {
|
|
37
|
+
return this.client.isAccessTokenValid();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async refreshAccessToken() {
|
|
44
|
+
try {
|
|
45
|
+
await this.client.refresh();
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async logout() {
|
|
52
|
+
await this.client.revokeToken();
|
|
53
|
+
}
|
|
54
|
+
async getClient() {
|
|
55
|
+
return this.client;
|
|
56
|
+
}
|
|
57
|
+
getCompanyId() {
|
|
58
|
+
return this.client.getToken().realmId;
|
|
59
|
+
}
|
|
60
|
+
async validateAndRefreshToken() {
|
|
61
|
+
if (!this.client.isAccessTokenValid()) {
|
|
62
|
+
await this.client.refresh();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.QuickBookClient = QuickBookClient;
|
|
67
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/quickbook-client/client.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAI5C,MAAa,eAAe;IAK1B,YAAY,OAAsC;QAChD,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,OAAO,EAAE,OAAO,CAAC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|
|
1
|
+
export declare const QUICKBOOK_CLIENT = "quickbook-client";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/quickbook-client/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { QuickBookClientModule } from './quickbook-client.module';
|
|
2
|
+
import { IQuickBookClientModuleOptions } from './interfaces/quickbook-client-options.interface';
|
|
3
|
+
import { QUICKBOOK_CLIENT } from './constant';
|
|
4
|
+
export { QuickBookClientModule, IQuickBookClientModuleOptions, QUICKBOOK_CLIENT, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QUICKBOOK_CLIENT = exports.QuickBookClientModule = void 0;
|
|
4
|
+
const quickbook_client_module_1 = require("./quickbook-client.module");
|
|
5
|
+
Object.defineProperty(exports, "QuickBookClientModule", { enumerable: true, get: function () { return quickbook_client_module_1.QuickBookClientModule; } });
|
|
6
|
+
const constant_1 = require("./constant");
|
|
7
|
+
Object.defineProperty(exports, "QUICKBOOK_CLIENT", { enumerable: true, get: function () { return constant_1.QUICKBOOK_CLIENT; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/quickbook-client/index.ts"],"names":[],"mappings":";;;AAAA,uEAAkE;AAKhE,sGALO,+CAAqB,OAKP;AAHvB,yCAA8C;AAK5C,iGALO,2BAAgB,OAKP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quickbook-client-options.interface.js","sourceRoot":"","sources":["../../../src/quickbook-client/interfaces/quickbook-client-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { IQuickBookClientModuleOptions } from './interfaces/quickbook-client-options.interface';
|
|
2
|
+
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<IQuickBookClientModuleOptions, "forRoot", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = void 0;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
_a = new common_1.ConfigurableModuleBuilder()
|
|
7
|
+
.setClassMethodName('forRoot')
|
|
8
|
+
.build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN;
|
|
9
|
+
//# sourceMappingURL=quickbook-client.module-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quickbook-client.module-definition.js","sourceRoot":"","sources":["../../src/quickbook-client/quickbook-client.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAG9C,KACX,IAAI,kCAAyB,EAAiC;KAC3D,kBAAkB,CAAC,SAAS,CAAC;KAC7B,KAAK,EAAE,EAHG,+BAAuB,+BAAE,4BAAoB,2BAG/C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { IQuickBookClientModuleOptions } from './interfaces/quickbook-client-options.interface';
|
|
3
|
+
import { ConfigurableModuleClass } from './quickbook-client.module-definition';
|
|
4
|
+
export declare class QuickBookClientModule extends ConfigurableModuleClass {
|
|
5
|
+
static forRoot(options: IQuickBookClientModuleOptions): DynamicModule;
|
|
6
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var QuickBookClientModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.QuickBookClientModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const client_1 = require("./client");
|
|
13
|
+
const constant_1 = require("./constant");
|
|
14
|
+
const quickbook_client_module_definition_1 = require("./quickbook-client.module-definition");
|
|
15
|
+
let QuickBookClientModule = QuickBookClientModule_1 = class QuickBookClientModule extends quickbook_client_module_definition_1.ConfigurableModuleClass {
|
|
16
|
+
static forRoot(options) {
|
|
17
|
+
const client = new client_1.QuickBookClient(options);
|
|
18
|
+
const QuickBookClientProvider = {
|
|
19
|
+
provide: constant_1.QUICKBOOK_CLIENT,
|
|
20
|
+
useValue: client,
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
module: QuickBookClientModule_1,
|
|
24
|
+
providers: [QuickBookClientProvider],
|
|
25
|
+
exports: [QuickBookClientProvider],
|
|
26
|
+
global: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
QuickBookClientModule = QuickBookClientModule_1 = __decorate([
|
|
31
|
+
(0, common_1.Module)({})
|
|
32
|
+
], QuickBookClientModule);
|
|
33
|
+
exports.QuickBookClientModule = QuickBookClientModule;
|
|
34
|
+
//# sourceMappingURL=quickbook-client.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quickbook-client.module.js","sourceRoot":"","sources":["../../src/quickbook-client/quickbook-client.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAiE;AACjE,qCAA2C;AAC3C,yCAA8C;AAE9C,6FAA+E;AAGxE,IAAM,qBAAqB,6BAA3B,MAAM,qBAAsB,SAAQ,4DAAuB;IAChE,MAAM,CAAC,OAAO,CAAC,OAAsC;QACnD,MAAM,MAAM,GAAG,IAAI,wBAAe,CAAC,OAAO,CAAC,CAAC;QAE5C,MAAM,uBAAuB,GAAa;YACxC,OAAO,EAAE,2BAAgB;YACzB,QAAQ,EAAE,MAAM;SACjB,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,uBAAqB;YAC7B,SAAS,EAAE,CAAC,uBAAuB,CAAC;YACpC,OAAO,EAAE,CAAC,uBAAuB,CAAC;YAClC,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CAgBjC;AAhBY,sDAAqB"}
|