bkper-js 1.9.3 → 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 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
  *
@@ -1261,6 +1269,36 @@ export declare class Integration {
1261
1269
  * @returns The Integration's name
1262
1270
  */
1263
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;
1264
1302
  /**
1265
1303
  * Gets the custom properties stored in the Integration.
1266
1304
  *
@@ -1304,6 +1342,12 @@ export declare class Integration {
1304
1342
  * @returns The Integration, for chainning
1305
1343
  */
1306
1344
  deleteProperty(key: string): Integration;
1345
+ /**
1346
+ * Performs remove Integration.
1347
+ *
1348
+ * @returns The removed Integration object
1349
+ */
1350
+ remove(): Promise<Integration>;
1307
1351
  }
1308
1352
 
1309
1353
  /**
@@ -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
  *
@@ -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
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "1.9.3",
3
+ "version": "1.10.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",