bkper-js 1.9.2 → 1.10.0
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/lib/index.d.ts +67 -3
- package/lib/model/Bkper.js +13 -0
- package/lib/model/Connection.js +31 -1
- package/lib/model/Integration.js +65 -0
- package/lib/service/http-api-request.js +1 -1
- package/lib/service/integration-service.js +1 -3
- package/lib/service/user-service.js +6 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -436,6 +436,14 @@ export declare class Bkper {
|
|
|
436
436
|
* @returns The retrieved User, for chaining
|
|
437
437
|
*/
|
|
438
438
|
static getUser(): Promise<User>;
|
|
439
|
+
/**
|
|
440
|
+
* Gets the URL to redirect the User to the billing portal.
|
|
441
|
+
*
|
|
442
|
+
* @param returnUrl - The URL to return to after the User has been redirected to the billing portal
|
|
443
|
+
*
|
|
444
|
+
* @returns The URL to redirect the User to the billing portal
|
|
445
|
+
*/
|
|
446
|
+
static getBillingPortalUrl(returnUrl: string): Promise<string | undefined>;
|
|
439
447
|
/**
|
|
440
448
|
* Sets the API [[Config]] object.
|
|
441
449
|
*
|
|
@@ -845,6 +853,8 @@ export declare interface Config {
|
|
|
845
853
|
}>;
|
|
846
854
|
/**
|
|
847
855
|
* Custom request error handler
|
|
856
|
+
*
|
|
857
|
+
* @param error - The error object of the failed request.
|
|
848
858
|
*/
|
|
849
859
|
requestErrorHandler?: (error: any) => any;
|
|
850
860
|
/**
|
|
@@ -854,10 +864,10 @@ export declare interface Config {
|
|
|
854
864
|
* It provides the HTTP status code, error message, and the number of retry attempts made so far.
|
|
855
865
|
*
|
|
856
866
|
* @param code - The HTTP status code of the failed request.
|
|
857
|
-
* @param
|
|
867
|
+
* @param error - The error object of the failed request.
|
|
858
868
|
* @param attempt - The number of retry attempts made so far.
|
|
859
869
|
*/
|
|
860
|
-
requestRetryHandler?: (status?: number,
|
|
870
|
+
requestRetryHandler?: (status?: number, error?: any, attempt?: number) => Promise<void>;
|
|
861
871
|
/**
|
|
862
872
|
* Sets the base api url. Default to https://app.bkper.com/_ah/api/bkper
|
|
863
873
|
*/
|
|
@@ -902,6 +912,18 @@ export declare class Connection {
|
|
|
902
912
|
* @returns The Connection name
|
|
903
913
|
*/
|
|
904
914
|
getName(): string | undefined;
|
|
915
|
+
/**
|
|
916
|
+
* Gets the logo of the Connection.
|
|
917
|
+
*
|
|
918
|
+
* @returns The Connection logo
|
|
919
|
+
*/
|
|
920
|
+
getLogo(): string | undefined;
|
|
921
|
+
/**
|
|
922
|
+
* Gets the date when the Connection was added.
|
|
923
|
+
*
|
|
924
|
+
* @returns The Connection add date in milliseconds
|
|
925
|
+
*/
|
|
926
|
+
getDateAddedMs(): string | undefined;
|
|
905
927
|
/**
|
|
906
928
|
* Gets the email of the owner of the Connection.
|
|
907
929
|
*
|
|
@@ -1006,9 +1028,15 @@ export declare class Connection {
|
|
|
1006
1028
|
/**
|
|
1007
1029
|
* Performs create new Connection.
|
|
1008
1030
|
*
|
|
1009
|
-
* @returns The Connection, for chaining
|
|
1031
|
+
* @returns The created Connection, for chaining
|
|
1010
1032
|
*/
|
|
1011
1033
|
create(): Promise<Connection>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Performs remove Connection.
|
|
1036
|
+
*
|
|
1037
|
+
* @returns The removed Connection object
|
|
1038
|
+
*/
|
|
1039
|
+
remove(): Promise<Connection>;
|
|
1012
1040
|
}
|
|
1013
1041
|
|
|
1014
1042
|
/**
|
|
@@ -1241,6 +1269,36 @@ export declare class Integration {
|
|
|
1241
1269
|
* @returns The Integration's name
|
|
1242
1270
|
*/
|
|
1243
1271
|
getName(): string | undefined;
|
|
1272
|
+
/**
|
|
1273
|
+
* Gets the name of the user who added the Integration.
|
|
1274
|
+
*
|
|
1275
|
+
* @returns The user name of who added the Integration
|
|
1276
|
+
*/
|
|
1277
|
+
getAddedBy(): string | undefined;
|
|
1278
|
+
/**
|
|
1279
|
+
* Gets the agent id of the Integration.
|
|
1280
|
+
*
|
|
1281
|
+
* @returns The Integration's agent id
|
|
1282
|
+
*/
|
|
1283
|
+
getAgentId(): string | undefined;
|
|
1284
|
+
/**
|
|
1285
|
+
* Gets the logo of the Integration.
|
|
1286
|
+
*
|
|
1287
|
+
* @returns The Integration's logo
|
|
1288
|
+
*/
|
|
1289
|
+
getLogo(): string | undefined;
|
|
1290
|
+
/**
|
|
1291
|
+
* Gets the date when the Integration was added.
|
|
1292
|
+
*
|
|
1293
|
+
* @returns The Integration add date in milliseconds
|
|
1294
|
+
*/
|
|
1295
|
+
getDateAddedMs(): string | undefined;
|
|
1296
|
+
/**
|
|
1297
|
+
* Gets the date when the Integration was last updated.
|
|
1298
|
+
*
|
|
1299
|
+
* @returns The Integration last update date in milliseconds
|
|
1300
|
+
*/
|
|
1301
|
+
getLastUpdateMs(): string | undefined;
|
|
1244
1302
|
/**
|
|
1245
1303
|
* Gets the custom properties stored in the Integration.
|
|
1246
1304
|
*
|
|
@@ -1284,6 +1342,12 @@ export declare class Integration {
|
|
|
1284
1342
|
* @returns The Integration, for chainning
|
|
1285
1343
|
*/
|
|
1286
1344
|
deleteProperty(key: string): Integration;
|
|
1345
|
+
/**
|
|
1346
|
+
* Performs remove Integration.
|
|
1347
|
+
*
|
|
1348
|
+
* @returns The removed Integration object
|
|
1349
|
+
*/
|
|
1350
|
+
remove(): Promise<Integration>;
|
|
1287
1351
|
}
|
|
1288
1352
|
|
|
1289
1353
|
/**
|
package/lib/model/Bkper.js
CHANGED
|
@@ -108,6 +108,19 @@ export class Bkper {
|
|
|
108
108
|
return new User(user);
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Gets the URL to redirect the User to the billing portal.
|
|
113
|
+
*
|
|
114
|
+
* @param returnUrl - The URL to return to after the User has been redirected to the billing portal
|
|
115
|
+
*
|
|
116
|
+
* @returns The URL to redirect the User to the billing portal
|
|
117
|
+
*/
|
|
118
|
+
static getBillingPortalUrl(returnUrl) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
let url = yield UserService.getBillingPortalUrl(returnUrl);
|
|
121
|
+
return url.url;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
111
124
|
/**
|
|
112
125
|
* Sets the API [[Config]] object.
|
|
113
126
|
*
|
package/lib/model/Connection.js
CHANGED
|
@@ -59,6 +59,22 @@ export class Connection {
|
|
|
59
59
|
getName() {
|
|
60
60
|
return this.payload.name;
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Gets the logo of the Connection.
|
|
64
|
+
*
|
|
65
|
+
* @returns The Connection logo
|
|
66
|
+
*/
|
|
67
|
+
getLogo() {
|
|
68
|
+
return this.payload.logo;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the date when the Connection was added.
|
|
72
|
+
*
|
|
73
|
+
* @returns The Connection add date in milliseconds
|
|
74
|
+
*/
|
|
75
|
+
getDateAddedMs() {
|
|
76
|
+
return this.payload.dateAddedMs;
|
|
77
|
+
}
|
|
62
78
|
/**
|
|
63
79
|
* Gets the email of the owner of the Connection.
|
|
64
80
|
*
|
|
@@ -223,7 +239,7 @@ export class Connection {
|
|
|
223
239
|
/**
|
|
224
240
|
* Performs create new Connection.
|
|
225
241
|
*
|
|
226
|
-
* @returns The Connection, for chaining
|
|
242
|
+
* @returns The created Connection, for chaining
|
|
227
243
|
*/
|
|
228
244
|
create() {
|
|
229
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -231,5 +247,19 @@ export class Connection {
|
|
|
231
247
|
return this;
|
|
232
248
|
});
|
|
233
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Performs remove Connection.
|
|
252
|
+
*
|
|
253
|
+
* @returns The removed Connection object
|
|
254
|
+
*/
|
|
255
|
+
remove() {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
const connectionId = this.getId();
|
|
258
|
+
if (connectionId) {
|
|
259
|
+
this.payload = yield ConnectionService.deleteConnection(connectionId);
|
|
260
|
+
}
|
|
261
|
+
return this;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
234
264
|
}
|
|
235
265
|
//# sourceMappingURL=Connection.js.map
|
package/lib/model/Integration.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as IntegrationService from '../service/integration-service.js';
|
|
1
11
|
/**
|
|
2
12
|
* This class defines a Integration from an [[User]] to an external service.
|
|
3
13
|
*
|
|
@@ -37,6 +47,46 @@ export class Integration {
|
|
|
37
47
|
getName() {
|
|
38
48
|
return this.payload.name;
|
|
39
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets the name of the user who added the Integration.
|
|
52
|
+
*
|
|
53
|
+
* @returns The user name of who added the Integration
|
|
54
|
+
*/
|
|
55
|
+
getAddedBy() {
|
|
56
|
+
return this.payload.addedBy;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gets the agent id of the Integration.
|
|
60
|
+
*
|
|
61
|
+
* @returns The Integration's agent id
|
|
62
|
+
*/
|
|
63
|
+
getAgentId() {
|
|
64
|
+
return this.payload.agentId;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Gets the logo of the Integration.
|
|
68
|
+
*
|
|
69
|
+
* @returns The Integration's logo
|
|
70
|
+
*/
|
|
71
|
+
getLogo() {
|
|
72
|
+
return this.payload.logo;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets the date when the Integration was added.
|
|
76
|
+
*
|
|
77
|
+
* @returns The Integration add date in milliseconds
|
|
78
|
+
*/
|
|
79
|
+
getDateAddedMs() {
|
|
80
|
+
return this.payload.dateAddedMs;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Gets the date when the Integration was last updated.
|
|
84
|
+
*
|
|
85
|
+
* @returns The Integration last update date in milliseconds
|
|
86
|
+
*/
|
|
87
|
+
getLastUpdateMs() {
|
|
88
|
+
return this.payload.lastUpdateMs;
|
|
89
|
+
}
|
|
40
90
|
/**
|
|
41
91
|
* Gets the custom properties stored in the Integration.
|
|
42
92
|
*
|
|
@@ -105,5 +155,20 @@ export class Integration {
|
|
|
105
155
|
this.setProperty(key, null);
|
|
106
156
|
return this;
|
|
107
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Performs remove Integration.
|
|
160
|
+
*
|
|
161
|
+
* @returns The removed Integration object
|
|
162
|
+
*/
|
|
163
|
+
remove() {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
const bookId = this.getBookId();
|
|
166
|
+
const integrationId = this.getId();
|
|
167
|
+
if (bookId && integrationId) {
|
|
168
|
+
this.payload = yield IntegrationService.deleteIntegration(bookId, integrationId);
|
|
169
|
+
}
|
|
170
|
+
return this;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
108
173
|
}
|
|
109
174
|
//# sourceMappingURL=Integration.js.map
|
|
@@ -52,7 +52,7 @@ export class HttpApiRequest extends HttpRequest {
|
|
|
52
52
|
}
|
|
53
53
|
return yield this.fetch();
|
|
54
54
|
}
|
|
55
|
-
throw this.handleError(errorResp);
|
|
55
|
+
throw this.handleError(errorResp.data);
|
|
56
56
|
}
|
|
57
57
|
else if (error.request) {
|
|
58
58
|
// The request was made but no response was received
|
|
@@ -37,9 +37,7 @@ export function updateIntegration(bookId, integration) {
|
|
|
37
37
|
}
|
|
38
38
|
export function deleteIntegration(bookId, id) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const res = yield new HttpBooksApiV5Request(`${bookId}/integrations/${id}`)
|
|
41
|
-
.setMethod('DELETE')
|
|
42
|
-
.fetch();
|
|
40
|
+
const res = yield new HttpBooksApiV5Request(`${bookId}/integrations/${id}`).setMethod('DELETE').fetch();
|
|
43
41
|
return res.data;
|
|
44
42
|
});
|
|
45
43
|
}
|
|
@@ -14,4 +14,10 @@ export function getUser() {
|
|
|
14
14
|
return res.data;
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
+
export function getBillingPortalUrl(returnUrl) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const res = yield new HttpApiV5Request(`user/billing/portal`).addParam('returnUrl', returnUrl).fetch();
|
|
20
|
+
return res.data;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
17
23
|
//# sourceMappingURL=user-service.js.map
|