bkper-js 2.21.0 → 2.23.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/CHANGELOG.md CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  See what's new and what has changed in bkper-js
4
4
 
5
+ ## 2026
6
+
7
+ **January 2026**
8
+ - Added `App.setUsers`
9
+ - Added `App.getUsers`
10
+ - Added `App.setDevelopers`
11
+ - Added `App.getDevelopers`
12
+ - Added `Config.agentIdProvider`
13
+ - Added `Billing`
14
+ - Added `Billing.getAdminEmail`
15
+ - Added `Billing.getDaysLeftInTrial`
16
+ - Added `Billing.getPlan`
17
+ - Added `Billing.getTotalTransactionsThisMonth`
18
+ - Added `Billing.getTotalTransactionsThisYear`
19
+ - Added `Billing.hasStartedTrial`
20
+ - Added `Billing.isEnabled`
21
+ - Added `Billing.isPlanOverdue`
22
+ - Added `User.getBilling`
23
+ - Added `User.getUsername`
24
+ - Removed `App.setUserEmails` from `App`. Use `App.setUsers` instead
25
+ - Removed `App.setDeveloperEmail` from `App`. Use `App.setDevelopers` instead
26
+ - Removed `User.getDaysLeftInTrial` from `User`. Use `Billing.getDaysLeftInTrial` instead
27
+ - Removed `User.getPlan` from `User`. Use `Billing.getPlan` instead
28
+ - Removed `User.hasBillingEnabled` from `User`. Use `Billing.isEnabled` instead
29
+ - Removed `User.hasStartedTrial` from `User`. Use `Billing.hasStartedTrial` instead
30
+ - Removed `User.isFree` from `User`. Use `Billing.getPlan` instead
31
+
5
32
  ## 2025
6
33
 
7
34
  **December 2025**
package/lib/index.d.ts CHANGED
@@ -1165,6 +1165,81 @@ export declare enum BalanceType {
1165
1165
  CUMULATIVE = "CUMULATIVE"
1166
1166
  }
1167
1167
 
1168
+ /**
1169
+ * This class defines the Billing information for a [[User]].
1170
+ *
1171
+ * The Billing information includes the plan, the admin email, and the billing portal URL.
1172
+ *
1173
+ * @public
1174
+ */
1175
+ export declare class Billing extends Resource<bkper.Billing> {
1176
+ private config?;
1177
+ constructor(json?: bkper.Billing, config?: Config);
1178
+
1179
+ /**
1180
+ * Tells if billing is enabled for the User.
1181
+ *
1182
+ * @returns True if billing is enabled for the User
1183
+ */
1184
+ isEnabled(): boolean | undefined;
1185
+ /**
1186
+ * Gets the current plan of the User.
1187
+ *
1188
+ * @returns The User's plan
1189
+ */
1190
+ getPlan(): string | undefined;
1191
+ /**
1192
+ * Tells if the User's current plan payment is overdue.
1193
+ *
1194
+ * @returns True if the plan payment is overdue
1195
+ */
1196
+ isPlanOverdue(): boolean | undefined;
1197
+ /**
1198
+ * Gets the admin email for this User's billing account.
1199
+ *
1200
+ * @returns The billing admin email
1201
+ */
1202
+ getAdminEmail(): string | undefined;
1203
+ /**
1204
+ * Tells if the User has started the trial period.
1205
+ *
1206
+ * @returns True if the User has started the trial period
1207
+ */
1208
+ hasStartedTrial(): boolean | undefined;
1209
+ /**
1210
+ * Gets the number of days left in User's trial period.
1211
+ *
1212
+ * @returns The number of days left in trial period
1213
+ */
1214
+ getDaysLeftInTrial(): number | undefined;
1215
+ /**
1216
+ * Gets the number of total transactions this month for the User's billing account.
1217
+ *
1218
+ * @returns The number of total transactions this month
1219
+ */
1220
+ getTotalTransactionsThisMonth(): number | undefined;
1221
+ /**
1222
+ * Gets the number of total transactions this year for the User's billing account.
1223
+ *
1224
+ * @returns The number of total transactions this year
1225
+ */
1226
+ getTotalTransactionsThisYear(): number | undefined;
1227
+ /**
1228
+ * Gets the transaction counts associated to the User's billing account.
1229
+ *
1230
+ * @returns The transaction counts associated to the User's billing account
1231
+ */
1232
+ getCounts(): Promise<bkper.Counts>;
1233
+ /**
1234
+ * Gets the URL to redirect the User to the billing portal.
1235
+ *
1236
+ * @param returnUrl - The URL to return to after the User has been redirected to the billing portal
1237
+ *
1238
+ * @returns The URL to redirect the User to the billing portal
1239
+ */
1240
+ getPortalUrl(returnUrl: string): Promise<string | undefined>;
1241
+ }
1242
+
1168
1243
  /**
1169
1244
  * This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
1170
1245
  *
@@ -1266,14 +1341,6 @@ export declare class Bkper {
1266
1341
  * @returns The retrieved User
1267
1342
  */
1268
1343
  getUser(): Promise<User>;
1269
- /**
1270
- * Gets the URL to redirect the User to the billing portal.
1271
- *
1272
- * @param returnUrl - The URL to return to after the User has been redirected to the billing portal
1273
- *
1274
- * @returns The URL to redirect the User to the billing portal
1275
- */
1276
- getBillingPortalUrl(returnUrl: string): Promise<string | undefined>;
1277
1344
  }
1278
1345
 
1279
1346
  /**
@@ -3688,65 +3755,17 @@ export declare class User extends Resource<bkper.User> {
3688
3755
  */
3689
3756
  getUsername(): string | undefined;
3690
3757
  /**
3691
- * Tells if the User is in the free plan.
3692
- *
3693
- * @returns True if the User is in the free plan
3694
- */
3695
- isFree(): boolean | undefined;
3696
- /**
3697
- * Gets the plan of the User.
3698
- *
3699
- * @returns The User's plan
3700
- */
3701
- getPlan(): string | undefined;
3702
- /**
3703
- * Tells if the User's subscription payment is overdue.
3758
+ * Gets the billing information for this User.
3704
3759
  *
3705
- * @returns True if the subscription payment is overdue
3760
+ * @returns The User's billing information
3706
3761
  */
3707
- isPlanOverdue(): boolean | undefined;
3708
- /**
3709
- * Tells if billing is enabled for the User.
3710
- *
3711
- * @returns True if billing is enabled for the User
3712
- */
3713
- hasBillingEnabled(): boolean | undefined;
3714
- /**
3715
- * Gets the billing admin email for this User's billing account.
3716
- *
3717
- * @returns The billing admin email
3718
- */
3719
- getBillingAdminEmail(): string | undefined;
3720
- /**
3721
- * Tells if the User has started the trial.
3722
- *
3723
- * @returns True if the User has started the trial
3724
- */
3725
- hasStartedTrial(): boolean | undefined;
3726
- /**
3727
- * Gets the days left in User's trial.
3728
- *
3729
- * @returns The User's days left in trial
3730
- */
3731
- getDaysLeftInTrial(): number | undefined;
3762
+ getBilling(): Promise<Billing>;
3732
3763
  /**
3733
3764
  * Tells if the User has already used [[Connections]].
3734
3765
  *
3735
3766
  * @returns True if the User has already used Connections
3736
3767
  */
3737
3768
  hasUsedConnections(): boolean | undefined;
3738
- /**
3739
- * Gets the User's total transactions this month.
3740
- *
3741
- * @returns The total transactions this month
3742
- */
3743
- getTotalTransactionsThisMonth(): number | undefined;
3744
- /**
3745
- * Gets the User's total transactions this year.
3746
- *
3747
- * @returns The total transactions this year
3748
- */
3749
- getTotalTransactionsThisYear(): number | undefined;
3750
3769
  /**
3751
3770
  * Gets the [[Connections]] of the User.
3752
3771
  *
package/lib/index.js CHANGED
@@ -13,6 +13,7 @@ export { Backlog } from "./model/Backlog.js";
13
13
  export { Balance } from "./model/Balance.js";
14
14
  export { BalancesDataTableBuilder } from "./model/BalancesDataTableBuilder.js";
15
15
  export { BalancesReport } from "./model/BalancesReport.js";
16
+ export { Billing } from "./model/Billing.js";
16
17
  export { Bkper } from "./model/Bkper.js";
17
18
  export { Book } from "./model/Book.js";
18
19
  export { Collaborator } from "./model/Collaborator.js";
@@ -0,0 +1,118 @@
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 { Resource } from "./Resource.js";
11
+ import { Bkper } from "./Bkper.js";
12
+ import * as UserService from "../service/user-service.js";
13
+ /**
14
+ * This class defines the Billing information for a [[User]].
15
+ *
16
+ * The Billing information includes the plan, the admin email, and the billing portal URL.
17
+ *
18
+ * @public
19
+ */
20
+ export class Billing extends Resource {
21
+ constructor(json, config) {
22
+ super(json);
23
+ this.config = config;
24
+ }
25
+ /** @internal */
26
+ getConfig() {
27
+ return this.config || Bkper.globalConfig;
28
+ }
29
+ /**
30
+ * Tells if billing is enabled for the User.
31
+ *
32
+ * @returns True if billing is enabled for the User
33
+ */
34
+ isEnabled() {
35
+ return this.payload.enabled;
36
+ }
37
+ /**
38
+ * Gets the current plan of the User.
39
+ *
40
+ * @returns The User's plan
41
+ */
42
+ getPlan() {
43
+ return this.payload.plan;
44
+ }
45
+ /**
46
+ * Tells if the User's current plan payment is overdue.
47
+ *
48
+ * @returns True if the plan payment is overdue
49
+ */
50
+ isPlanOverdue() {
51
+ return this.payload.planOverdue;
52
+ }
53
+ /**
54
+ * Gets the admin email for this User's billing account.
55
+ *
56
+ * @returns The billing admin email
57
+ */
58
+ getAdminEmail() {
59
+ return this.payload.adminEmail;
60
+ }
61
+ /**
62
+ * Tells if the User has started the trial period.
63
+ *
64
+ * @returns True if the User has started the trial period
65
+ */
66
+ hasStartedTrial() {
67
+ return this.payload.startedTrial;
68
+ }
69
+ /**
70
+ * Gets the number of days left in User's trial period.
71
+ *
72
+ * @returns The number of days left in trial period
73
+ */
74
+ getDaysLeftInTrial() {
75
+ return this.payload.daysLeftInTrial;
76
+ }
77
+ /**
78
+ * Gets the number of total transactions this month for the User's billing account.
79
+ *
80
+ * @returns The number of total transactions this month
81
+ */
82
+ getTotalTransactionsThisMonth() {
83
+ return this.payload.totalTransactionsThisMonth;
84
+ }
85
+ /**
86
+ * Gets the number of total transactions this year for the User's billing account.
87
+ *
88
+ * @returns The number of total transactions this year
89
+ */
90
+ getTotalTransactionsThisYear() {
91
+ return this.payload.totalTransactionsThisYear;
92
+ }
93
+ /**
94
+ * Gets the transaction counts associated to the User's billing account.
95
+ *
96
+ * @returns The transaction counts associated to the User's billing account
97
+ */
98
+ getCounts() {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ const countsPayload = yield UserService.getBillingCounts(this.getConfig());
101
+ return countsPayload;
102
+ });
103
+ }
104
+ /**
105
+ * Gets the URL to redirect the User to the billing portal.
106
+ *
107
+ * @param returnUrl - The URL to return to after the User has been redirected to the billing portal
108
+ *
109
+ * @returns The URL to redirect the User to the billing portal
110
+ */
111
+ getPortalUrl(returnUrl) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const urlPayload = yield UserService.getBillingPortalUrl(returnUrl, this.getConfig());
114
+ return urlPayload.url;
115
+ });
116
+ }
117
+ }
118
+ //# sourceMappingURL=Billing.js.map
@@ -152,19 +152,6 @@ export class Bkper {
152
152
  return new User(user, this.config);
153
153
  });
154
154
  }
155
- /**
156
- * Gets the URL to redirect the User to the billing portal.
157
- *
158
- * @param returnUrl - The URL to return to after the User has been redirected to the billing portal
159
- *
160
- * @returns The URL to redirect the User to the billing portal
161
- */
162
- getBillingPortalUrl(returnUrl) {
163
- return __awaiter(this, void 0, void 0, function* () {
164
- let url = yield UserService.getBillingPortalUrl(returnUrl, this.config);
165
- return url.url;
166
- });
167
- }
168
155
  }
169
156
  /** @internal */
170
157
  Bkper.globalConfig = {};
package/lib/model/User.js CHANGED
@@ -11,6 +11,8 @@ import { Connection } from "./Connection.js";
11
11
  import { Resource } from "./Resource.js";
12
12
  import { Bkper } from "./Bkper.js";
13
13
  import * as ConnectionService from "../service/connection-service.js";
14
+ import * as UserService from "../service/user-service.js";
15
+ import { Billing } from "./Billing.js";
14
16
  /**
15
17
  * This class defines a User on the Bkper platform.
16
18
  *
@@ -86,60 +88,15 @@ export class User extends Resource {
86
88
  return this.payload.username;
87
89
  }
88
90
  /**
89
- * Tells if the User is in the free plan.
91
+ * Gets the billing information for this User.
90
92
  *
91
- * @returns True if the User is in the free plan
93
+ * @returns The User's billing information
92
94
  */
93
- isFree() {
94
- return this.payload.free;
95
- }
96
- /**
97
- * Gets the plan of the User.
98
- *
99
- * @returns The User's plan
100
- */
101
- getPlan() {
102
- return this.payload.plan;
103
- }
104
- /**
105
- * Tells if the User's subscription payment is overdue.
106
- *
107
- * @returns True if the subscription payment is overdue
108
- */
109
- isPlanOverdue() {
110
- return this.payload.planOverdue;
111
- }
112
- /**
113
- * Tells if billing is enabled for the User.
114
- *
115
- * @returns True if billing is enabled for the User
116
- */
117
- hasBillingEnabled() {
118
- return this.payload.billingEnabled;
119
- }
120
- /**
121
- * Gets the billing admin email for this User's billing account.
122
- *
123
- * @returns The billing admin email
124
- */
125
- getBillingAdminEmail() {
126
- return this.payload.billingAdminEmail;
127
- }
128
- /**
129
- * Tells if the User has started the trial.
130
- *
131
- * @returns True if the User has started the trial
132
- */
133
- hasStartedTrial() {
134
- return this.payload.startedTrial;
135
- }
136
- /**
137
- * Gets the days left in User's trial.
138
- *
139
- * @returns The User's days left in trial
140
- */
141
- getDaysLeftInTrial() {
142
- return this.payload.daysLeftInTrial;
95
+ getBilling() {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const payload = yield UserService.getBilling(this.getConfig());
98
+ return new Billing(payload, this.config);
99
+ });
143
100
  }
144
101
  /**
145
102
  * Tells if the User has already used [[Connections]].
@@ -149,22 +106,6 @@ export class User extends Resource {
149
106
  hasUsedConnections() {
150
107
  return this.payload.bankConnections;
151
108
  }
152
- /**
153
- * Gets the User's total transactions this month.
154
- *
155
- * @returns The total transactions this month
156
- */
157
- getTotalTransactionsThisMonth() {
158
- return this.payload.totalTransactionsThisMonth;
159
- }
160
- /**
161
- * Gets the User's total transactions this year.
162
- *
163
- * @returns The total transactions this year
164
- */
165
- getTotalTransactionsThisYear() {
166
- return this.payload.totalTransactionsThisYear;
167
- }
168
109
  /**
169
110
  * Gets the [[Connections]] of the User.
170
111
  *
@@ -14,6 +14,18 @@ export function getUser(config) {
14
14
  return res.data;
15
15
  });
16
16
  }
17
+ export function getBilling(config) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const res = yield new HttpApiV5Request(`user/billing`, config).setMethod('GET').fetch();
20
+ return res.data;
21
+ });
22
+ }
23
+ export function getBillingCounts(config) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const res = yield new HttpApiV5Request(`user/billing/counts`, config).setMethod('GET').fetch();
26
+ return res.data;
27
+ });
28
+ }
17
29
  export function getBillingPortalUrl(returnUrl, config) {
18
30
  return __awaiter(this, void 0, void 0, function* () {
19
31
  const res = yield new HttpApiV5Request(`user/billing/portal`, config).addParam('returnUrl', returnUrl).fetch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.21.0",
3
+ "version": "2.23.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -35,7 +35,7 @@
35
35
  "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
36
36
  },
37
37
  "peerDependencies": {
38
- "@bkper/bkper-api-types": "^5.33.0"
38
+ "@bkper/bkper-api-types": "^5.34.0"
39
39
  },
40
40
  "dependencies": {
41
41
  "big.js": "^6.0.3",