bkper-js 2.29.2 → 2.29.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.
package/README.md CHANGED
@@ -18,11 +18,15 @@ It provides a set of classes and functions to interact with the Bkper API, inclu
18
18
  ```
19
19
  npm i -S bkper-js
20
20
  ```
21
+
21
22
  or
23
+
22
24
  ```
23
25
  yarn add bkper-js
24
26
  ```
27
+
25
28
  or
29
+
26
30
  ```
27
31
  bun add bkper-js
28
32
  ```
@@ -39,7 +43,7 @@ import { getOAuthToken } from 'bkper';
39
43
 
40
44
  // Configure with CLI authentication
41
45
  Bkper.setConfig({
42
- oauthTokenProvider: async () => getOAuthToken()
46
+ oauthTokenProvider: async () => getOAuthToken(),
43
47
  });
44
48
 
45
49
  // Create Bkper instance
@@ -54,7 +58,7 @@ const books = await bkper.getBooks();
54
58
  console.log(`You have ${books.length} books`);
55
59
  ```
56
60
 
57
- First, login via CLI: `bkper login`
61
+ First, login via CLI: `bkper auth login`
58
62
 
59
63
  ### Web Applications
60
64
 
@@ -66,8 +70,8 @@ import { BkperAuth } from '@bkper/web-auth';
66
70
 
67
71
  // Initialize authentication
68
72
  const auth = new BkperAuth({
69
- onLoginSuccess: () => initializeApp(),
70
- onLoginRequired: () => showLoginButton()
73
+ onLoginSuccess: () => initializeApp(),
74
+ onLoginRequired: () => showLoginButton(),
71
75
  });
72
76
 
73
77
  // Restore session on app load
@@ -75,7 +79,7 @@ await auth.init();
75
79
 
76
80
  // Configure Bkper with web auth
77
81
  Bkper.setConfig({
78
- oauthTokenProvider: async () => auth.getAccessToken()
82
+ oauthTokenProvider: async () => auth.getAccessToken(),
79
83
  });
80
84
 
81
85
  // Create Bkper instance and use it
@@ -91,8 +95,7 @@ API keys are optional and only needed for dedicated quota limits. If not provide
91
95
 
92
96
  ```typescript
93
97
  Bkper.setConfig({
94
- oauthTokenProvider: async () => getOAuthToken(),
95
- apiKeyProvider: async () => process.env.BKPER_API_KEY // Optional - for dedicated quota
98
+ oauthTokenProvider: async () => getOAuthToken(),
99
+ apiKeyProvider: async () => process.env.BKPER_API_KEY, // Optional - for dedicated quota
96
100
  });
97
101
  ```
98
-
package/lib/index.d.ts CHANGED
@@ -13,6 +13,10 @@
13
13
  *
14
14
  * An Account can be grouped by [[Groups]].
15
15
  *
16
+ * @remarks
17
+ * `Account` has no `getBalance()` method. To retrieve account balances, use
18
+ * {@link Book.getBalancesReport} and read the resulting {@link BalancesContainer}.
19
+ *
16
20
  * @public
17
21
  */
18
22
  export declare class Account extends ResourceProperty<bkper.Account> {
@@ -1340,10 +1344,11 @@ export declare class Billing extends Resource<bkper.Billing> {
1340
1344
  * @param plan - The plan to checkout
1341
1345
  * @param successUrl - The URL to redirect to after the User has successfully checked out
1342
1346
  * @param cancelUrl - The URL to redirect to in case the checkout is cancelled
1347
+ * @param cycle - The billing cycle to checkout - "monthly" (default) or "yearly"
1343
1348
  *
1344
1349
  * @returns The URL to redirect the User to the billing checkout
1345
1350
  */
1346
- getCheckoutUrl(plan: string, successUrl?: string, cancelUrl?: string): Promise<string | undefined>;
1351
+ getCheckoutUrl(plan: string, successUrl?: string, cancelUrl?: string, cycle?: string): Promise<string | undefined>;
1347
1352
  }
1348
1353
 
1349
1354
  /**
@@ -18,6 +18,10 @@ import { ResourceProperty } from './ResourceProperty.js';
18
18
  *
19
19
  * An Account can be grouped by [[Groups]].
20
20
  *
21
+ * @remarks
22
+ * `Account` has no `getBalance()` method. To retrieve account balances, use
23
+ * {@link Book.getBalancesReport} and read the resulting {@link BalancesContainer}.
24
+ *
21
25
  * @public
22
26
  */
23
27
  export class Account extends ResourceProperty {
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { Resource } from "./Resource.js";
11
- import { Bkper } from "./Bkper.js";
12
- import * as UserService from "../service/user-service.js";
10
+ import { Resource } from './Resource.js';
11
+ import { Bkper } from './Bkper.js';
12
+ import * as UserService from '../service/user-service.js';
13
13
  /**
14
14
  * This class defines the Billing information for a [[User]].
15
15
  *
@@ -136,12 +136,13 @@ export class Billing extends Resource {
136
136
  * @param plan - The plan to checkout
137
137
  * @param successUrl - The URL to redirect to after the User has successfully checked out
138
138
  * @param cancelUrl - The URL to redirect to in case the checkout is cancelled
139
+ * @param cycle - The billing cycle to checkout - "monthly" (default) or "yearly"
139
140
  *
140
141
  * @returns The URL to redirect the User to the billing checkout
141
142
  */
142
- getCheckoutUrl(plan, successUrl, cancelUrl) {
143
+ getCheckoutUrl(plan, successUrl, cancelUrl, cycle) {
143
144
  return __awaiter(this, void 0, void 0, function* () {
144
- const urlPayload = yield UserService.getBillingCheckoutUrl(plan, successUrl, cancelUrl, this.getConfig());
145
+ const urlPayload = yield UserService.getBillingCheckoutUrl(plan, successUrl, cancelUrl, cycle, this.getConfig());
145
146
  return urlPayload === null || urlPayload === void 0 ? void 0 : urlPayload.url;
146
147
  });
147
148
  }
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { HttpApiV5Request } from "./http-api-request.js";
10
+ import { HttpApiV5Request } from './http-api-request.js';
11
11
  export function getUser(config) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
13
  const res = yield new HttpApiV5Request(`user`, config).setMethod('GET').fetch();
@@ -28,13 +28,18 @@ export function getBillingCounts(config) {
28
28
  }
29
29
  export function getBillingPortalUrl(returnUrl, config) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
- const res = yield new HttpApiV5Request(`user/billing/portal`, config).addParam('returnUrl', returnUrl).fetch();
31
+ const res = yield new HttpApiV5Request(`user/billing/portal`, config)
32
+ .addParam('returnUrl', returnUrl)
33
+ .fetch();
32
34
  return res.data;
33
35
  });
34
36
  }
35
- export function getBillingCheckoutUrl(plan, successUrl, cancelUrl, config) {
37
+ export function getBillingCheckoutUrl(plan, successUrl, cancelUrl, cycle, config) {
36
38
  return __awaiter(this, void 0, void 0, function* () {
37
39
  const request = new HttpApiV5Request(`user/billing/checkout`, config).addParam('plan', plan);
40
+ if (cycle) {
41
+ request.addParam('cycle', cycle);
42
+ }
38
43
  if (successUrl) {
39
44
  request.addParam('successUrl', successUrl);
40
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.29.2",
3
+ "version": "2.29.4",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",