bkper-js 2.7.1 → 2.8.1

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/lib/index.d.ts +172 -99
  3. package/lib/model/Account.js +20 -21
  4. package/lib/model/App.js +72 -21
  5. package/lib/model/Bkper.js +42 -30
  6. package/lib/model/Book.js +109 -99
  7. package/lib/model/BotResponse.js +2 -2
  8. package/lib/model/Collaborator.js +12 -11
  9. package/lib/model/Collection.js +24 -19
  10. package/lib/model/Connection.js +28 -18
  11. package/lib/model/Conversation.js +20 -13
  12. package/lib/model/File.js +19 -17
  13. package/lib/model/Group.js +29 -21
  14. package/lib/model/Integration.js +17 -13
  15. package/lib/model/Message.js +20 -16
  16. package/lib/model/Query.js +12 -11
  17. package/lib/model/Resource.js +23 -0
  18. package/lib/model/Template.js +10 -7
  19. package/lib/model/Transaction.js +61 -43
  20. package/lib/model/User.js +14 -12
  21. package/lib/service/account-service.js +12 -12
  22. package/lib/service/app-service.js +8 -8
  23. package/lib/service/balances-service.js +2 -2
  24. package/lib/service/book-service.js +14 -14
  25. package/lib/service/collaborator-service.js +6 -6
  26. package/lib/service/collection-service.js +12 -12
  27. package/lib/service/connection-service.js +12 -15
  28. package/lib/service/conversation-service.js +10 -10
  29. package/lib/service/event-service.js +8 -8
  30. package/lib/service/file-service.js +4 -4
  31. package/lib/service/group-service.js +16 -16
  32. package/lib/service/http-api-request.js +54 -45
  33. package/lib/service/integration-service.js +8 -8
  34. package/lib/service/query-service.js +8 -8
  35. package/lib/service/template-service.js +2 -2
  36. package/lib/service/transaction-service.js +32 -32
  37. package/lib/service/user-service.js +4 -4
  38. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ See what's new and what has changed in bkper-js
5
5
  2025
6
6
  ----
7
7
 
8
+ **September 2025**
9
+ * **v2.8.0 - INTERNAL REFACTOR:**
10
+ * Introduced abstract `Resource` class for all model entities
11
+ * Improved config management with `getConfig()` pattern for config resolution
12
+ * Enhanced type safety with explicit Config type usage throughout
13
+ * Standardized `json()` method across resources for consistent JSON serialization
14
+ * Maintained full backward compatibility - no breaking changes to existing APIs
15
+ * Added `App.getOwnerWebsiteUrl`
16
+ * Added `App.getReadme`
17
+ * Added `App.getRepositoryUrl`
18
+ * Added `App.getWebsiteUrl`
19
+ * Added `App.isInstallable`
20
+ * Added `App.isRepositoryPrivate`
21
+ * Added `Collaborator`
22
+ * Added `Collaborator.json`
23
+ * Added `Collaborator.getId`
24
+ * Added `Collaborator.getEmail`
25
+ * Added `Collaborator.getPermission`
26
+ * Added `Collaborator.setEmail`
27
+ * Added `Collaborator.setPermission`
28
+ * Added `Collaborator.create`
29
+ * Added `Collaborator.update`
30
+ * Added `Collaborator.remove`
31
+ * Added `Book.getCollaborators`
32
+ * Replaced axios with native Fetch API for better compatibility with multiple environments
33
+
8
34
  **August 2025**
9
35
 
10
36
  * Added `Transaction.setFiles`
package/lib/index.d.ts CHANGED
@@ -15,16 +15,15 @@
15
15
  *
16
16
  * @public
17
17
  */
18
- export declare class Account {
19
- payload: bkper.Account;
18
+ export declare class Account extends Resource<bkper.Account> {
20
19
 
21
20
  constructor(book: Book, payload?: bkper.Account);
22
21
  /**
23
- * Gets an immutable copy of the JSON payload.
22
+ * Gets the configuration object for this Account.
24
23
  *
25
- * @returns An immutable copy of the json payload
24
+ * @returns The Config object from the parent Book
26
25
  */
27
- json(): bkper.Account;
26
+ getConfig(): Config;
28
27
  /**
29
28
  * Gets the Account internal id.
30
29
  *
@@ -442,15 +441,15 @@ export declare class Amount {
442
441
  *
443
442
  * @public
444
443
  */
445
- export declare class App {
446
- payload: bkper.App;
447
- constructor(payload?: bkper.App);
444
+ export declare class App extends Resource<bkper.App> {
445
+ private config?;
446
+ constructor(payload?: bkper.App, config?: Config);
448
447
  /**
449
- * Gets the wrapped plain JSON object.
448
+ * Gets the configuration object for this App.
450
449
  *
451
- * @returns The wrapped plain json object
450
+ * @returns The Config object for this App or the global config
452
451
  */
453
- json(): bkper.App;
452
+ getConfig(): Config;
454
453
  /**
455
454
  * Sets the webhook url for development.
456
455
  *
@@ -497,6 +496,12 @@ export declare class App {
497
496
  * @returns True if this App is published
498
497
  */
499
498
  isPublished(): boolean;
499
+ /**
500
+ * Tells if this App is installable.
501
+ *
502
+ * @returns True if this App is installable
503
+ */
504
+ isInstallable(): boolean;
500
505
  /**
501
506
  * Checks if this App is conversational.
502
507
  *
@@ -529,12 +534,6 @@ export declare class App {
529
534
  * @returns This App for chaining
530
535
  */
531
536
  setUserEmails(emails?: string): App;
532
- /**
533
- * Gets the name of the owner of this App.
534
- *
535
- * @returns The name of the owner of this App
536
- */
537
- getOwnerName(): string | undefined;
538
537
  /**
539
538
  * Gets the menu url of this App.
540
539
  *
@@ -565,12 +564,24 @@ export declare class App {
565
564
  * @returns The menu popup height of this App
566
565
  */
567
566
  getMenuPopupHeight(): string | undefined;
567
+ /**
568
+ * Gets the name of the owner of this App.
569
+ *
570
+ * @returns The name of the owner of this App
571
+ */
572
+ getOwnerName(): string | undefined;
568
573
  /**
569
574
  * Gets the logo url of the owner of this App.
570
575
  *
571
576
  * @returns The logo url of the owner of this App
572
577
  */
573
578
  getOwnerLogoUrl(): string | undefined;
579
+ /**
580
+ * Gets the website url of the owner of this App.
581
+ *
582
+ * @returns The website url of the owner of this App
583
+ */
584
+ getOwnerWebsiteUrl(): string | undefined;
574
585
  /**
575
586
  * Gets the file patterns the App handles.
576
587
  *
@@ -594,11 +605,35 @@ export declare class App {
594
605
  */
595
606
  setClientSecret(clientSecret?: string): App;
596
607
  /**
597
- * Sets the readme text.
608
+ * Gets the website url of this App.
609
+ *
610
+ * @returns The website url of this App
611
+ */
612
+ getWebsiteUrl(): string | undefined;
613
+ /**
614
+ * Tells if the repository is private.
615
+ *
616
+ * @returns True if the repository is private
617
+ */
618
+ isRepositoryPrivate(): boolean | undefined;
619
+ /**
620
+ * Gets the repository url of this App.
621
+ *
622
+ * @returns The repository url of this App
623
+ */
624
+ getRepositoryUrl(): string | undefined;
625
+ /**
626
+ * Gets the readme.md file as text.
627
+ *
628
+ * @returns The readme text
629
+ */
630
+ getReadme(): string | undefined;
631
+ /**
632
+ * Sets the readme.md file as text.
598
633
  *
599
634
  * @param readme - The readme text to set
600
635
  *
601
- * @returns This App for chaining
636
+ * @returns This App, for chaining
602
637
  */
603
638
  setReadme(readme?: string): App;
604
639
  /**
@@ -1162,10 +1197,9 @@ export declare enum BalanceType {
1162
1197
  /**
1163
1198
  * This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
1164
1199
  *
1165
- * You start by setting the API [[Config]] object using the static setConfig method.
1166
- *
1167
- * Example:
1200
+ * You can configure the library in two ways:
1168
1201
  *
1202
+ * 1. Using static configuration (traditional approach):
1169
1203
  * ```javascript
1170
1204
  * Bkper.setConfig({
1171
1205
  * apiKeyProvider: () => process.env.BKPER_API_KEY,
@@ -1176,22 +1210,36 @@ export declare enum BalanceType {
1176
1210
  * const book = await bkper.getBook('bookId');
1177
1211
  * ```
1178
1212
  *
1179
- * Once the config is set, you can create instances and start using the library.
1213
+ * 2. Using per-instance configuration (recommended for Cloudflare Workers):
1214
+ * ```javascript
1215
+ * const bkper = new Bkper({
1216
+ * apiKeyProvider: () => process.env.BKPER_API_KEY,
1217
+ * oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
1218
+ * });
1219
+ *
1220
+ * const book = await bkper.getBook('bookId');
1221
+ * ```
1180
1222
  *
1181
1223
  * @public
1182
1224
  */
1183
1225
  export declare class Bkper {
1226
+
1227
+ private config;
1184
1228
  /**
1185
1229
  * Sets the global API configuration for all Bkper operations.
1186
1230
  *
1231
+ * WARNING: This configuration will be shared and should NOT be used on shared environments.
1232
+ *
1187
1233
  * @param config - The Config object containing API key and OAuth token providers
1188
1234
  */
1189
1235
  static setConfig(config: Config): void;
1190
1236
  /**
1191
- * Creates a new Bkper instance using the global configuration set via setConfig().
1192
- * Make sure to call Bkper.setConfig() before creating instances.
1237
+ * Creates a new Bkper instance with the provided configuration.
1238
+ *
1239
+ * @param config - The Config object containing API key and OAuth token providers.
1240
+ * If not provided, uses the global configuration set via setConfig().
1193
1241
  */
1194
- constructor();
1242
+ constructor(config?: Config);
1195
1243
  /**
1196
1244
  * Gets the [[Book]] with the specified bookId from url param.
1197
1245
  *
@@ -1262,8 +1310,8 @@ export declare class Bkper {
1262
1310
  *
1263
1311
  * @public
1264
1312
  */
1265
- export declare class Book {
1266
- payload: bkper.Book;
1313
+ export declare class Book extends Resource<bkper.Book> {
1314
+ private config?;
1267
1315
 
1268
1316
 
1269
1317
 
@@ -1272,13 +1320,13 @@ export declare class Book {
1272
1320
 
1273
1321
 
1274
1322
 
1275
- constructor(payload?: bkper.Book);
1323
+ constructor(payload?: bkper.Book, config?: Config);
1276
1324
  /**
1277
- * Gets an immutable copy of the JSON payload for this Book.
1325
+ * Gets the configuration object for this Book.
1278
1326
  *
1279
- * @returns An immutable copy of the JSON payload
1327
+ * @returns The Config object for this Book or the global config
1280
1328
  */
1281
- json(): bkper.Book;
1329
+ getConfig(): Config;
1282
1330
  /**
1283
1331
  * Gets the unique identifier of this Book.
1284
1332
  *
@@ -1909,16 +1957,15 @@ export declare enum BotResponseType {
1909
1957
  *
1910
1958
  * @public
1911
1959
  */
1912
- export declare class Collaborator {
1913
- payload: bkper.Collaborator;
1960
+ export declare class Collaborator extends Resource<bkper.Collaborator> {
1914
1961
 
1915
1962
  constructor(book: Book, payload?: bkper.Collaborator);
1916
1963
  /**
1917
- * Gets an immutable copy of the JSON payload.
1964
+ * Gets the configuration object for this Collaborator.
1918
1965
  *
1919
- * @returns An immutable copy of the json payload
1966
+ * @returns The Config object from the parent Book
1920
1967
  */
1921
- json(): bkper.Collaborator;
1968
+ getConfig(): Config;
1922
1969
  /**
1923
1970
  * Gets the Collaborator internal id.
1924
1971
  *
@@ -1978,15 +2025,15 @@ export declare class Collaborator {
1978
2025
  *
1979
2026
  * @public
1980
2027
  */
1981
- export declare class Collection {
1982
- payload: bkper.Collection;
1983
- constructor(payload?: bkper.Collection);
2028
+ export declare class Collection extends Resource<bkper.Collection> {
2029
+ private config?;
2030
+ constructor(payload?: bkper.Collection, config?: Config);
1984
2031
  /**
1985
- * Gets an immutable copy of the JSON payload for this Collection.
2032
+ * Gets the configuration object for this Collection.
1986
2033
  *
1987
- * @returns The wrapped plain json object
2034
+ * @returns The Config object for this Collection or the global config
1988
2035
  */
1989
- json(): bkper.Collection;
2036
+ getConfig(): Config;
1990
2037
  /**
1991
2038
  * Gets the unique identifier of this Collection.
1992
2039
  *
@@ -2119,15 +2166,15 @@ export declare interface Config {
2119
2166
  *
2120
2167
  * @public
2121
2168
  */
2122
- export declare class Connection {
2123
- payload: bkper.Connection;
2124
- constructor(payload?: bkper.Connection);
2169
+ export declare class Connection extends Resource<bkper.Connection> {
2170
+ private config?;
2171
+ constructor(payload?: bkper.Connection, config?: Config);
2125
2172
  /**
2126
- * Gets an immutable copy of the JSON payload for this Connection.
2173
+ * Gets the configuration object for this Connection.
2127
2174
  *
2128
- * @returns An immutable copy of the json payload
2175
+ * @returns The Config object for this Connection or the global config
2129
2176
  */
2130
- json(): bkper.Connection;
2177
+ getConfig(): Config;
2131
2178
  /**
2132
2179
  * Gets the id of the Connection.
2133
2180
  *
@@ -2288,17 +2335,17 @@ export declare class Connection {
2288
2335
  *
2289
2336
  * @public
2290
2337
  */
2291
- export declare class Conversation {
2292
- payload: bkper.Conversation;
2338
+ export declare class Conversation extends Resource<bkper.Conversation> {
2293
2339
 
2294
2340
 
2295
- constructor(agent: Agent, payload?: bkper.Conversation);
2341
+ private config?;
2342
+ constructor(agent: Agent, payload?: bkper.Conversation, config?: Config);
2296
2343
  /**
2297
- * Gets an immutable copy of the JSON payload for this Conversation.
2344
+ * Gets the configuration object for this Conversation.
2298
2345
  *
2299
- * @returns The wrapped plain json object
2346
+ * @returns The Config object for this Conversation or the global config
2300
2347
  */
2301
- json(): bkper.Conversation;
2348
+ getConfig(): Config;
2302
2349
  /**
2303
2350
  * Gets the Agent associated to this Conversation.
2304
2351
  *
@@ -2508,16 +2555,15 @@ export declare enum EventType {
2508
2555
  *
2509
2556
  * @public
2510
2557
  */
2511
- export declare class File {
2512
- payload: bkper.File;
2558
+ export declare class File extends Resource<bkper.File> {
2513
2559
 
2514
2560
  constructor(book: Book, payload?: bkper.File);
2515
2561
  /**
2516
- * Gets an immutable copy of the JSON payload for this File.
2562
+ * Gets the configuration object for this File.
2517
2563
  *
2518
- * @returns An immutable copy of the json payload
2564
+ * @returns The Config object from the parent Book
2519
2565
  */
2520
- json(): bkper.File;
2566
+ getConfig(): Config;
2521
2567
  /**
2522
2568
  * Gets the File id.
2523
2569
  *
@@ -2638,8 +2684,7 @@ export declare class File {
2638
2684
  *
2639
2685
  * @public
2640
2686
  */
2641
- export declare class Group {
2642
- payload: bkper.Group;
2687
+ export declare class Group extends Resource<bkper.Group> {
2643
2688
 
2644
2689
 
2645
2690
 
@@ -2648,11 +2693,11 @@ export declare class Group {
2648
2693
 
2649
2694
  constructor(book: Book, payload?: bkper.Group);
2650
2695
  /**
2651
- * Gets an immutable copy of the json payload.
2696
+ * Gets the configuration object for this Group.
2652
2697
  *
2653
- * @returns An immutable copy of the json payload
2698
+ * @returns The Config object from the parent Book
2654
2699
  */
2655
- json(): bkper.Group;
2700
+ getConfig(): Config;
2656
2701
  /**
2657
2702
  * Gets the id of this Group.
2658
2703
  *
@@ -2890,15 +2935,15 @@ export declare class Group {
2890
2935
  *
2891
2936
  * @public
2892
2937
  */
2893
- export declare class Integration {
2894
- payload: bkper.Integration;
2895
- constructor(payload?: bkper.Integration);
2938
+ export declare class Integration extends Resource<bkper.Integration> {
2939
+ private config?;
2940
+ constructor(payload?: bkper.Integration, config?: Config);
2896
2941
  /**
2897
- * Gets an immutable copy of the JSON payload for this Integration.
2942
+ * Gets the configuration object for this Integration.
2898
2943
  *
2899
- * @returns An immutable copy of the json payload
2944
+ * @returns The Config object for this Integration or the global config
2900
2945
  */
2901
- json(): bkper.Integration;
2946
+ getConfig(): Config;
2902
2947
  /**
2903
2948
  * Gets the [[Book]] id of the Integration.
2904
2949
  *
@@ -3005,17 +3050,16 @@ export declare class Integration {
3005
3050
  *
3006
3051
  * @public
3007
3052
  */
3008
- export declare class Message {
3009
- payload: bkper.Message;
3053
+ export declare class Message extends Resource<bkper.Message> {
3010
3054
 
3011
3055
 
3012
- constructor(conversation: Conversation, payload?: bkper.Message);
3056
+ constructor(conversation: Conversation, payload?: bkper.Message, config?: Config);
3013
3057
  /**
3014
- * Gets the wrapped plain json object.
3058
+ * Gets the configuration object for this Message.
3015
3059
  *
3016
- * @returns The wrapped plain json object
3060
+ * @returns The Config object from the parent Conversation
3017
3061
  */
3018
- json(): bkper.Message;
3062
+ getConfig(): Config;
3019
3063
  /**
3020
3064
  * Gets the Message universal identifier.
3021
3065
  *
@@ -3218,16 +3262,15 @@ export declare enum Permission {
3218
3262
  *
3219
3263
  * @public
3220
3264
  */
3221
- export declare class Query {
3222
- payload: bkper.Query;
3265
+ export declare class Query extends Resource<bkper.Query> {
3223
3266
 
3224
3267
  constructor(book: Book, payload?: bkper.Query);
3225
3268
  /**
3226
- * Gets the wrapped plain json object.
3269
+ * Gets the configuration object for this Query.
3227
3270
  *
3228
- * @returns The wrapped plain json object
3271
+ * @returns The Config object from the parent Book
3229
3272
  */
3230
- json(): bkper.Query;
3273
+ getConfig(): Config;
3231
3274
  /**
3232
3275
  * Gets the Query universal identifier.
3233
3276
  *
@@ -3283,6 +3326,37 @@ export declare class Query {
3283
3326
 
3284
3327
  }
3285
3328
 
3329
+ /**
3330
+ * Abstract base class for all Bkper resources.
3331
+ * Provides common functionality for config management and JSON serialization.
3332
+ *
3333
+ * @public
3334
+ */
3335
+ declare abstract class Resource<T = any> {
3336
+ /**
3337
+ * The underlying payload data for this resource
3338
+ */
3339
+ payload: T;
3340
+ /**
3341
+ * Constructs a new Resource
3342
+ * @param payload - The data payload for this resource
3343
+ */
3344
+ constructor(payload?: T);
3345
+ /**
3346
+ * Gets an immutable copy of the JSON payload for this resource.
3347
+ * @returns An immutable copy of the json payload
3348
+ */
3349
+ json(): T;
3350
+ /**
3351
+ * Gets the effective configuration for this resource.
3352
+ * Each resource must implement this to either:
3353
+ * - Return its own config (for root containers like Book, Collection)
3354
+ * - Delegate to its container (for contained resources like Account, Transaction)
3355
+ * @returns The resolved configuration
3356
+ */
3357
+ abstract getConfig(): Config;
3358
+ }
3359
+
3286
3360
  /**
3287
3361
  * This class defines a Template.
3288
3362
  *
@@ -3290,15 +3364,15 @@ export declare class Query {
3290
3364
  *
3291
3365
  * @public
3292
3366
  */
3293
- export declare class Template {
3294
- payload: bkper.Template;
3295
- constructor(json?: bkper.Template);
3367
+ export declare class Template extends Resource<bkper.Template> {
3368
+ private config?;
3369
+ constructor(json?: bkper.Template, config?: Config);
3296
3370
  /**
3297
- * Gets an immutable copy of the JSON payload for this Template.
3371
+ * Gets the configuration object for this Template.
3298
3372
  *
3299
- * @returns An immutable copy of the json payload
3373
+ * @returns The Config object for this Template or the global config
3300
3374
  */
3301
- json(): bkper.Template;
3375
+ getConfig(): Config;
3302
3376
  /**
3303
3377
  * Gets the name of the Template.
3304
3378
  *
@@ -3357,16 +3431,15 @@ export declare class Template {
3357
3431
  *
3358
3432
  * @public
3359
3433
  */
3360
- export declare class Transaction {
3361
- payload: bkper.Transaction;
3434
+ export declare class Transaction extends Resource<bkper.Transaction> {
3362
3435
 
3363
3436
  constructor(book: Book, payload?: bkper.Transaction);
3364
3437
  /**
3365
- * Gets the JSON representation of the transaction.
3438
+ * Gets the configuration object for this Transaction.
3366
3439
  *
3367
- * @returns An immutable copy of the json payload
3440
+ * @returns The Config object from the parent Book
3368
3441
  */
3369
- json(): bkper.Transaction;
3442
+ getConfig(): Config;
3370
3443
  /**
3371
3444
  * Gets the book associated with this transaction.
3372
3445
  *
@@ -3861,15 +3934,15 @@ export declare class TransactionList {
3861
3934
  *
3862
3935
  * @public
3863
3936
  */
3864
- export declare class User {
3865
- payload: bkper.User;
3866
- constructor(payload?: bkper.User);
3937
+ export declare class User extends Resource<bkper.User> {
3938
+ private config?;
3939
+ constructor(payload?: bkper.User, config?: Config);
3867
3940
  /**
3868
- * Gets an immutable copy of the JSON payload for this User.
3941
+ * Gets the configuration object for this User.
3869
3942
  *
3870
- * @returns An immutable copy of the json payload
3943
+ * @returns The Config object for this User or the global config
3871
3944
  */
3872
- json(): bkper.User;
3945
+ getConfig(): Config;
3873
3946
  /**
3874
3947
  * Gets the id of the User.
3875
3948
  *
@@ -7,10 +7,11 @@ 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 * as AccountService from '../service/account-service.js';
11
- import * as GroupService from '../service/group-service.js';
12
- import { Group } from './Group.js';
13
- import { normalizeText } from '../utils.js';
10
+ import * as AccountService from "../service/account-service.js";
11
+ import * as GroupService from "../service/group-service.js";
12
+ import { Group } from "./Group.js";
13
+ import { normalizeText } from "../utils.js";
14
+ import { Resource } from "./Resource.js";
14
15
  /**
15
16
  * This class defines an [Account](https://en.wikipedia.org/wiki/Account_(bookkeeping)) of a [[Book]].
16
17
  *
@@ -20,20 +21,18 @@ import { normalizeText } from '../utils.js';
20
21
  *
21
22
  * @public
22
23
  */
23
- export class Account {
24
+ export class Account extends Resource {
24
25
  constructor(book, payload) {
26
+ super(payload || { createdAt: `${Date.now()}` });
25
27
  this.book = book;
26
- this.payload = payload || {
27
- createdAt: `${Date.now()}`
28
- };
29
28
  }
30
29
  /**
31
- * Gets an immutable copy of the JSON payload.
30
+ * Gets the configuration object for this Account.
32
31
  *
33
- * @returns An immutable copy of the json payload
32
+ * @returns The Config object from the parent Book
34
33
  */
35
- json() {
36
- return Object.assign({}, this.payload);
34
+ getConfig() {
35
+ return this.book.getConfig();
37
36
  }
38
37
  /**
39
38
  * Gets the Account internal id.
@@ -124,7 +123,7 @@ export class Account {
124
123
  for (let index = 0; index < keys.length; index++) {
125
124
  const key = keys[index];
126
125
  let value = this.payload.properties != null ? this.payload.properties[key] : null;
127
- if (value != null && value.trim() != '') {
126
+ if (value != null && value.trim() != "") {
128
127
  return value;
129
128
  }
130
129
  }
@@ -139,14 +138,14 @@ export class Account {
139
138
  * @returns This Account, for chaining
140
139
  */
141
140
  setProperty(key, value) {
142
- if (key == null || key.trim() == '') {
141
+ if (key == null || key.trim() == "") {
143
142
  return this;
144
143
  }
145
144
  if (this.payload.properties == null) {
146
145
  this.payload.properties = {};
147
146
  }
148
147
  if (!value) {
149
- value = '';
148
+ value = "";
150
149
  }
151
150
  this.payload.properties[key] = value;
152
151
  return this;
@@ -241,8 +240,8 @@ export class Account {
241
240
  if (!id) {
242
241
  return [];
243
242
  }
244
- let groups = yield GroupService.getGroupsByAccountId(this.book.getId(), id);
245
- let groupsObj = groups.map(group => new Group(this.book, group));
243
+ let groups = yield GroupService.getGroupsByAccountId(this.book.getId(), id, this.getConfig());
244
+ let groupsObj = groups.map((group) => new Group(this.book, group));
246
245
  return groupsObj;
247
246
  });
248
247
  }
@@ -256,7 +255,7 @@ export class Account {
256
255
  setGroups(groups) {
257
256
  this.payload.groups = undefined;
258
257
  if (groups != null) {
259
- groups.forEach(group => this.addGroup(group));
258
+ groups.forEach((group) => this.addGroup(group));
260
259
  }
261
260
  return this;
262
261
  }
@@ -351,7 +350,7 @@ export class Account {
351
350
  */
352
351
  create() {
353
352
  return __awaiter(this, void 0, void 0, function* () {
354
- this.payload = yield AccountService.createAccount(this.book.getId(), this.payload);
353
+ this.payload = yield AccountService.createAccount(this.book.getId(), this.payload, this.getConfig());
355
354
  this.updateAccountCache();
356
355
  return this;
357
356
  });
@@ -363,7 +362,7 @@ export class Account {
363
362
  */
364
363
  update() {
365
364
  return __awaiter(this, void 0, void 0, function* () {
366
- this.payload = yield AccountService.updateAccount(this.book.getId(), this.payload);
365
+ this.payload = yield AccountService.updateAccount(this.book.getId(), this.payload, this.getConfig());
367
366
  this.updateAccountCache();
368
367
  return this;
369
368
  });
@@ -375,7 +374,7 @@ export class Account {
375
374
  */
376
375
  remove() {
377
376
  return __awaiter(this, void 0, void 0, function* () {
378
- this.payload = yield AccountService.deleteAccount(this.book.getId(), this.payload);
377
+ this.payload = yield AccountService.deleteAccount(this.book.getId(), this.payload, this.getConfig());
379
378
  this.updateAccountCache(true);
380
379
  return this;
381
380
  });