bkper-js 1.47.2 → 2.0.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/model/App.js CHANGED
@@ -20,32 +20,37 @@ export class App {
20
20
  this.payload = payload || {};
21
21
  }
22
22
  /**
23
+ * Gets the wrapped plain JSON object.
24
+ *
23
25
  * @returns The wrapped plain json object
24
26
  */
25
27
  json() {
26
28
  return Object.assign({}, this.payload);
27
29
  }
28
30
  /**
29
- *
30
31
  * Sets the webhook url for development.
31
32
  *
32
- * @returns This App, for chainning.
33
+ * @param webhookUrlDev - The webhook URL for development
34
+ *
35
+ * @returns This App, for chaining
33
36
  */
34
37
  setWebhookUrlDev(webhookUrlDev) {
35
38
  this.payload.webhookUrlDev = webhookUrlDev;
36
39
  return this;
37
40
  }
38
41
  /**
39
- *
40
42
  * Sets the conversation url for development.
41
43
  *
42
- * @returns This App, for chainning.
44
+ * @param conversationUrlDev - The conversation URL for development
45
+ *
46
+ * @returns This App, for chaining
43
47
  */
44
48
  setConversationUrlDev(conversationUrlDev) {
45
49
  this.payload.conversationUrlDev = conversationUrlDev;
46
50
  return this;
47
51
  }
48
52
  /**
53
+ * Gets the App universal identifier.
49
54
  *
50
55
  * @returns The App universal identifier
51
56
  */
@@ -53,56 +58,74 @@ export class App {
53
58
  return this.payload.id;
54
59
  }
55
60
  /**
56
- * @return The name of this App
61
+ * Gets the name of this App.
62
+ *
63
+ * @returns The name of this App
57
64
  */
58
65
  getName() {
59
66
  return this.payload.name;
60
67
  }
61
68
  /**
62
- * @return True if this App has events bound to it
69
+ * Checks if this App has events bound to it.
70
+ *
71
+ * @returns True if this App has events bound to it
63
72
  */
64
73
  hasEvents() {
65
74
  const events = this.getEvents() || [];
66
75
  return events.length > 0;
67
76
  }
68
77
  /**
69
- * @return The events bound to this App
78
+ * Gets the events bound to this App.
79
+ *
80
+ * @returns The events bound to this App
70
81
  */
71
82
  getEvents() {
72
83
  return this.payload.events;
73
84
  }
74
85
  /**
75
- * @return True if this App is published
86
+ * Checks if this App is published.
87
+ *
88
+ * @returns True if this App is published
76
89
  */
77
90
  isPublished() {
78
91
  return this.payload.published || false;
79
92
  }
80
93
  /**
81
- * @return True if this App is conversational
94
+ * Checks if this App is conversational.
95
+ *
96
+ * @returns True if this App is conversational
82
97
  */
83
98
  isConversational() {
84
99
  return this.payload.conversational || false;
85
100
  }
86
101
  /**
87
- * @return The logo url of this App
102
+ * Gets the logo url of this App.
103
+ *
104
+ * @returns The logo url of this App
88
105
  */
89
106
  getLogoUrl() {
90
107
  return this.payload.logoUrl;
91
108
  }
92
109
  /**
93
- * @return The logo url of this App in dark mode
110
+ * Gets the logo url of this App in dark mode.
111
+ *
112
+ * @returns The logo url of this App in dark mode
94
113
  */
95
114
  getLogoUrlDark() {
96
115
  return this.payload.logoUrlDark;
97
116
  }
98
117
  /**
99
- * @return The description of this App
118
+ * Gets the description of this App.
119
+ *
120
+ * @returns The description of this App
100
121
  */
101
122
  getDescription() {
102
123
  return this.payload.description;
103
124
  }
104
125
  /**
105
- * Sets the whitelabeled user emails
126
+ * Sets the whitelabeled user emails.
127
+ *
128
+ * @param emails - The user emails to whitelist
106
129
  *
107
130
  * @returns This App for chaining
108
131
  */
@@ -111,55 +134,73 @@ export class App {
111
134
  return this;
112
135
  }
113
136
  /**
114
- * @return The name of the owner of this App
137
+ * Gets the name of the owner of this App.
138
+ *
139
+ * @returns The name of the owner of this App
115
140
  */
116
141
  getOwnerName() {
117
142
  return this.payload.ownerName;
118
143
  }
119
144
  /**
120
- * @return The menu url of this App
145
+ * Gets the menu url of this App.
146
+ *
147
+ * @returns The menu url of this App
121
148
  */
122
149
  getMenuUrl() {
123
150
  return this.payload.menuUrl;
124
151
  }
125
152
  /**
126
- * @return The menu development url of this App
153
+ * Gets the menu development url of this App.
154
+ *
155
+ * @returns The menu development url of this App
127
156
  */
128
157
  getMenuUrlDev() {
129
158
  return this.payload.menuUrlDev;
130
159
  }
131
160
  /**
132
- * @return The menu text of this App
161
+ * Gets the menu text of this App.
162
+ *
163
+ * @returns The menu text of this App
133
164
  */
134
165
  getMenuText() {
135
166
  return this.payload.menuText;
136
167
  }
137
168
  /**
138
- * @return The menu popup width of this App
169
+ * Gets the menu popup width of this App.
170
+ *
171
+ * @returns The menu popup width of this App
139
172
  */
140
173
  getMenuPopupWidth() {
141
174
  return this.payload.menuPopupWidth;
142
175
  }
143
176
  /**
144
- * @return The menu popup height of this App
177
+ * Gets the menu popup height of this App.
178
+ *
179
+ * @returns The menu popup height of this App
145
180
  */
146
181
  getMenuPopupHeight() {
147
182
  return this.payload.menuPopupHeight;
148
183
  }
149
184
  /**
150
- * @return The logo url of the owner of this App
185
+ * Gets the logo url of the owner of this App.
186
+ *
187
+ * @returns The logo url of the owner of this App
151
188
  */
152
189
  getOwnerLogoUrl() {
153
190
  return this.payload.ownerLogoUrl;
154
191
  }
155
192
  /**
156
- * @return The file patterns the App handles - E.g *.pdf *.csv
193
+ * Gets the file patterns the App handles.
194
+ *
195
+ * @returns The file patterns the App handles - E.g *.pdf *.csv
157
196
  */
158
197
  getFilePatterns() {
159
198
  return this.payload.filePatterns;
160
199
  }
161
200
  /**
162
- * Sets the developer email
201
+ * Sets the developer email.
202
+ *
203
+ * @param email - The developer email to set
163
204
  *
164
205
  * @returns This App for chaining
165
206
  */
@@ -168,7 +209,9 @@ export class App {
168
209
  return this;
169
210
  }
170
211
  /**
171
- * Sets the client secret
212
+ * Sets the client secret.
213
+ *
214
+ * @param clientSecret - The client secret to set
172
215
  *
173
216
  * @returns This App for chaining
174
217
  */
@@ -177,7 +220,9 @@ export class App {
177
220
  return this;
178
221
  }
179
222
  /**
180
- * Sets the readme text
223
+ * Sets the readme text.
224
+ *
225
+ * @param readme - The readme text to set
181
226
  *
182
227
  * @returns This App for chaining
183
228
  */
@@ -189,6 +234,8 @@ export class App {
189
234
  * Performs the app creation, applying pending changes.
190
235
  *
191
236
  * The App id MUST be unique. If another app is already existing, an error will be thrown.
237
+ *
238
+ * @returns This App after creation
192
239
  */
193
240
  create() {
194
241
  return __awaiter(this, void 0, void 0, function* () {
@@ -197,7 +244,9 @@ export class App {
197
244
  });
198
245
  }
199
246
  /**
200
- * Partially update an App, applying pending changes.
247
+ * Partially updates an App, applying pending changes.
248
+ *
249
+ * @returns This App after the partial update
201
250
  */
202
251
  patch() {
203
252
  return __awaiter(this, void 0, void 0, function* () {
@@ -206,7 +255,9 @@ export class App {
206
255
  });
207
256
  }
208
257
  /**
209
- * Perform update App, applying pending changes.
258
+ * Performs a full update of the App, applying pending changes.
259
+ *
260
+ * @returns This App after the update
210
261
  */
211
262
  update() {
212
263
  return __awaiter(this, void 0, void 0, function* () {
@@ -12,19 +12,25 @@ export class BalancesReport {
12
12
  this.payload = payload;
13
13
  }
14
14
  /**
15
- * @returns The [[Book]] that generated the report.
15
+ * Gets the [[Book]] that generated the report.
16
+ *
17
+ * @returns The [[Book]] that generated the report
16
18
  */
17
19
  getBook() {
18
20
  return this.book;
19
21
  }
20
22
  /**
21
- * @returns The [[Periodicity]] of the query used to generate the report.
23
+ * Gets the [[Periodicity]] of the query used to generate the report.
24
+ *
25
+ * @returns The [[Periodicity]] of the query used to generate the report
22
26
  */
23
27
  getPeriodicity() {
24
28
  return this.payload.periodicity;
25
29
  }
26
30
  /**
27
- * @returns All [[BalancesContainers]] of the report.
31
+ * Gets all [[BalancesContainers]] of the report.
32
+ *
33
+ * @returns All [[BalancesContainers]] of the report
28
34
  */
29
35
  getBalancesContainers() {
30
36
  let containers = [];
@@ -41,9 +47,9 @@ export class BalancesReport {
41
47
  /**
42
48
  * Gets a specific [[BalancesContainer]].
43
49
  *
44
- * @param name The [[Account]] or [[Group]] name.
50
+ * @param name - The [[Account]] or [[Group]] name
45
51
  *
46
- * @returns The retrieved [[BalancesContainer]].
52
+ * @returns The retrieved [[BalancesContainer]]
47
53
  */
48
54
  getBalancesContainer(name) {
49
55
  var _a;
@@ -29,7 +29,7 @@ import { Agent } from "./Agent.js";
29
29
  * Example:
30
30
  *
31
31
  * ```javascript
32
- * Bkper.setConfig({
32
+ * Bkper.get().setConfig({
33
33
  * apiKeyProvider: () => process.env.BKPER_API_KEY,
34
34
  * oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
35
35
  * })
@@ -40,15 +40,23 @@ import { Agent } from "./Agent.js";
40
40
  * @public
41
41
  */
42
42
  export class Bkper {
43
+ /**
44
+ * Creates a new Bkper instance with the specified API configuration.
45
+ *
46
+ * @param config - The Config object
47
+ */
48
+ constructor(config) {
49
+ HttpApiRequest.config = config;
50
+ }
43
51
  /**
44
52
  * Gets the [[Book]] with the specified bookId from url param.
45
53
  *
46
54
  * @param id - The universal book id - The same bookId param of URL you access at app.bkper.com
47
55
  * @param includeAccounts - Optional parameter to include accounts in the retrieved Book
48
56
  *
49
- * @returns The retrieved Book, for chaining
57
+ * @returns The retrieved Book
50
58
  */
51
- static getBook(id, includeAccounts) {
59
+ getBook(id, includeAccounts) {
52
60
  return __awaiter(this, void 0, void 0, function* () {
53
61
  let book = yield BookService.loadBook(id, includeAccounts);
54
62
  return new Book(book);
@@ -60,7 +68,7 @@ export class Bkper {
60
68
  * @param query - Optional search term to filter books
61
69
  * @returns The retrieved list of Books
62
70
  */
63
- static getBooks(query) {
71
+ getBooks(query) {
64
72
  return __awaiter(this, void 0, void 0, function* () {
65
73
  let books = yield BookService.loadBooks(query);
66
74
  return books.map(book => new Book(book));
@@ -71,7 +79,7 @@ export class Bkper {
71
79
  *
72
80
  * @returns The retrieved list of Collections
73
81
  */
74
- static getCollections() {
82
+ getCollections() {
75
83
  return __awaiter(this, void 0, void 0, function* () {
76
84
  let collections = yield CollectionService.loadCollections();
77
85
  return collections.map(collection => new Collection(collection));
@@ -82,7 +90,7 @@ export class Bkper {
82
90
  *
83
91
  * @returns The retrieved list of Apps
84
92
  */
85
- static getApps() {
93
+ getApps() {
86
94
  return __awaiter(this, void 0, void 0, function* () {
87
95
  let apps = yield AppService.getApps();
88
96
  return apps.map(app => new App(app));
@@ -93,7 +101,7 @@ export class Bkper {
93
101
  *
94
102
  * @returns The retrieved list of Conversations
95
103
  */
96
- static getConversations() {
104
+ getConversations() {
97
105
  return __awaiter(this, void 0, void 0, function* () {
98
106
  const conversationPayloads = yield ConversationService.getConversations();
99
107
  let conversations = [];
@@ -110,7 +118,7 @@ export class Bkper {
110
118
  *
111
119
  * @returns The retrieved list of Templates
112
120
  */
113
- static getTemplates() {
121
+ getTemplates() {
114
122
  return __awaiter(this, void 0, void 0, function* () {
115
123
  let templates = yield TemplateService.getTemplates();
116
124
  return templates.map(template => new Template(template));
@@ -119,9 +127,9 @@ export class Bkper {
119
127
  /**
120
128
  * Gets the current logged [[User]].
121
129
  *
122
- * @returns The retrieved User, for chaining
130
+ * @returns The retrieved User
123
131
  */
124
- static getUser() {
132
+ getUser() {
125
133
  return __awaiter(this, void 0, void 0, function* () {
126
134
  let user = yield UserService.getUser();
127
135
  return new User(user);
@@ -134,42 +142,11 @@ export class Bkper {
134
142
  *
135
143
  * @returns The URL to redirect the User to the billing portal
136
144
  */
137
- static getBillingPortalUrl(returnUrl) {
145
+ getBillingPortalUrl(returnUrl) {
138
146
  return __awaiter(this, void 0, void 0, function* () {
139
147
  let url = yield UserService.getBillingPortalUrl(returnUrl);
140
148
  return url.url;
141
149
  });
142
150
  }
143
- /**
144
- * Sets the API [[Config]] object.
145
- *
146
- * @param config - The Config object
147
- */
148
- static setConfig(config) {
149
- HttpApiRequest.config = config;
150
- }
151
- /**
152
- * Sets the API key to identify the agent.
153
- *
154
- * @param key - The API key
155
- *
156
- * @returns The defined [[App]] object
157
- *
158
- * @deprecated Use `setConfig()` instead
159
- */
160
- static setApiKey(key) {
161
- HttpApiRequest.config.apiKeyProvider = () => __awaiter(this, void 0, void 0, function* () { return key; });
162
- return new App({});
163
- }
164
- /**
165
- * Sets the provider of the valid OAuth2 access token
166
- *
167
- * @deprecated Use `setConfig()` instead
168
- */
169
- static setOAuthTokenProvider(oauthTokenProvider) {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- HttpApiRequest.config.oauthTokenProvider = oauthTokenProvider;
172
- });
173
- }
174
151
  }
175
152
  //# sourceMappingURL=Bkper.js.map