bkper 2.2.0 → 2.5.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
@@ -21,6 +21,11 @@
21
21
  export declare class Account {
22
22
 
23
23
 
24
+ /**
25
+ *
26
+ * @returns The wrapped plain json object
27
+ */
28
+ json(): bkper.Account;
24
29
  /**
25
30
  * Gets the account internal id.
26
31
  */
@@ -163,13 +168,13 @@ export declare class Account {
163
168
  *
164
169
  * @returns This Account, for chainning.
165
170
  */
166
- setGroups(groups: string[] | Group[]): Account;
171
+ setGroups(groups: Group[] | bkper.Group[]): Account;
167
172
  /**
168
173
  * Add a group to the Account.
169
174
  *
170
175
  * @returns This Account, for chainning.
171
176
  */
172
- addGroup(group: string | Group): Promise<Account>;
177
+ addGroup(group: Group | bkper.Group): Account;
173
178
  /**
174
179
  * Remove a group from the Account.
175
180
  */
@@ -333,26 +338,6 @@ export declare class App {
333
338
 
334
339
 
335
340
 
336
- }
337
-
338
- /**
339
- * Enum that represents balance types.
340
- *
341
- * @public
342
- */
343
- export declare enum BalanceType {
344
- /**
345
- * Total balance
346
- */
347
- TOTAL = "TOTAL",
348
- /**
349
- * Period balance
350
- */
351
- PERIOD = "PERIOD",
352
- /**
353
- * Cumulative balance
354
- */
355
- CUMULATIVE = "CUMULATIVE"
356
341
  }
357
342
 
358
343
  /**
@@ -368,13 +353,6 @@ export declare class Bkper {
368
353
  *
369
354
  */
370
355
  static getBook(id: string): Promise<Book>;
371
- /**
372
- * Creates a new [[Book]] from a plain json Book
373
- *
374
- * @param book - The universal book id - The same bookId param of URL you access at app.bkper.com
375
- *
376
- */
377
- static newBook(book: bkper.Book): Book;
378
356
  /**
379
357
  * Sets the API key to identify the agent.
380
358
  *
@@ -412,7 +390,12 @@ export declare class Book {
412
390
 
413
391
 
414
392
 
415
-
393
+ constructor(json: bkper.Book);
394
+ /**
395
+ *
396
+ * @returns The wrapped plain json object
397
+ */
398
+ json(): bkper.Book;
416
399
  /**
417
400
  * Same as bookId param
418
401
  */
@@ -854,6 +837,11 @@ export declare class Group {
854
837
 
855
838
  accounts: Set<Account>;
856
839
 
840
+ /**
841
+ *
842
+ * @returns The wrapped plain json object
843
+ */
844
+ json(): bkper.Group;
857
845
  /**
858
846
  * @returns The id of this Group
859
847
  */
@@ -1069,9 +1057,12 @@ export declare enum Permission {
1069
1057
  */
1070
1058
  export declare class Transaction {
1071
1059
 
1072
- creditAccount: Account;
1073
- debitAccount: Account;
1074
1060
 
1061
+ /**
1062
+ *
1063
+ * @returns The wrapped plain json object
1064
+ */
1065
+ json(): bkper.Transaction;
1075
1066
  /**
1076
1067
  * @returns The id of the Transaction.
1077
1068
  */
@@ -1208,7 +1199,7 @@ export declare class Transaction {
1208
1199
  *
1209
1200
  * @returns This Transaction, for chainning.
1210
1201
  */
1211
- setCreditAccount(account: Account): Transaction;
1202
+ setCreditAccount(account: Account | bkper.Account): Transaction;
1212
1203
  /**
1213
1204
  *
1214
1205
  * Sets the credit/origin Account of the Transaction. Same as setCreditAccount().
@@ -1217,7 +1208,7 @@ export declare class Transaction {
1217
1208
  *
1218
1209
  * @returns This Transaction, for chainning.
1219
1210
  */
1220
- from(account: Account): Transaction;
1211
+ from(account: Account | bkper.Account): Transaction;
1221
1212
  /**
1222
1213
  * @returns The debit account. The same as destination account.
1223
1214
  *
@@ -1235,7 +1226,7 @@ export declare class Transaction {
1235
1226
  *
1236
1227
  * @returns This Transaction, for chainning.
1237
1228
  */
1238
- setDebitAccount(account: Account): Transaction;
1229
+ setDebitAccount(account: Account | bkper.Account): Transaction;
1239
1230
  /**
1240
1231
  *
1241
1232
  * Sets the debit/origin Account of the Transaction. Same as setDebitAccount().
@@ -1244,7 +1235,7 @@ export declare class Transaction {
1244
1235
  *
1245
1236
  * @returns This Transaction, for chainning.
1246
1237
  */
1247
- to(account: Account): Transaction;
1238
+ to(account: Account | bkper.Account): Transaction;
1248
1239
  /**
1249
1240
  * @returns The amount of the transaction.
1250
1241
  */
package/lib/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * @packageDocumentation
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Permission = exports.DecimalSeparator = exports.BalanceType = exports.AccountType = exports.Periodicity = exports.TransactionIterator = exports.Transaction = exports.Group = exports.File = exports.Collection = exports.Book = exports.Account = exports.Bkper = exports.Amount = exports.App = void 0;
10
+ exports.Permission = exports.DecimalSeparator = exports.AccountType = exports.Periodicity = exports.TransactionIterator = exports.Transaction = exports.Group = exports.File = exports.Collection = exports.Book = exports.Account = exports.Bkper = exports.Amount = exports.App = void 0;
11
11
  var App_1 = require("./model/App");
12
12
  Object.defineProperty(exports, "App", { enumerable: true, get: function () { return App_1.App; } });
13
13
  var Amount_1 = require("./model/Amount");
@@ -31,7 +31,6 @@ Object.defineProperty(exports, "TransactionIterator", { enumerable: true, get: f
31
31
  var Enums_1 = require("./model/Enums");
32
32
  Object.defineProperty(exports, "Periodicity", { enumerable: true, get: function () { return Enums_1.Periodicity; } });
33
33
  Object.defineProperty(exports, "AccountType", { enumerable: true, get: function () { return Enums_1.AccountType; } });
34
- Object.defineProperty(exports, "BalanceType", { enumerable: true, get: function () { return Enums_1.BalanceType; } });
35
34
  Object.defineProperty(exports, "DecimalSeparator", { enumerable: true, get: function () { return Enums_1.DecimalSeparator; } });
36
35
  Object.defineProperty(exports, "Permission", { enumerable: true, get: function () { return Enums_1.Permission; } });
37
36
  //# sourceMappingURL=index.js.map
@@ -46,6 +46,13 @@ const Utils = __importStar(require("../utils"));
46
46
  * @public
47
47
  */
48
48
  class Account {
49
+ /**
50
+ *
51
+ * @returns The wrapped plain json object
52
+ */
53
+ json() {
54
+ return this.wrapped;
55
+ }
49
56
  /**
50
57
  * Gets the account internal id.
51
58
  */
@@ -269,7 +276,7 @@ class Account {
269
276
  setGroups(groups) {
270
277
  this.wrapped.groups = null;
271
278
  if (groups != null) {
272
- groups.forEach((group) => this.addGroup(group));
279
+ groups.forEach(group => this.addGroup(group));
273
280
  }
274
281
  return this;
275
282
  }
@@ -279,22 +286,16 @@ class Account {
279
286
  * @returns This Account, for chainning.
280
287
  */
281
288
  addGroup(group) {
282
- return __awaiter(this, void 0, void 0, function* () {
283
- if (this.wrapped.groups == null) {
284
- this.wrapped.groups = [];
285
- }
286
- let groupObject = null;
287
- if (group instanceof Group_1.Group) {
288
- groupObject = group;
289
- }
290
- else if (typeof group == "string") {
291
- groupObject = yield this.book.getGroup(group);
292
- }
293
- if (groupObject) {
294
- this.wrapped.groups.push(groupObject.wrapped);
295
- }
296
- return this;
297
- });
289
+ if (this.wrapped.groups == null) {
290
+ this.wrapped.groups = [];
291
+ }
292
+ if (group instanceof Group_1.Group) {
293
+ this.wrapped.groups.push(group.wrapped);
294
+ }
295
+ else {
296
+ this.wrapped.groups.push(group);
297
+ }
298
+ return this;
298
299
  }
299
300
  /**
300
301
  * Remove a group from the Account.
@@ -51,15 +51,6 @@ class Bkper {
51
51
  return new Book_1.Book(book);
52
52
  });
53
53
  }
54
- /**
55
- * Creates a new [[Book]] from a plain json Book
56
- *
57
- * @param book - The universal book id - The same bookId param of URL you access at app.bkper.com
58
- *
59
- */
60
- static newBook(book) {
61
- return new Book_1.Book(book);
62
- }
63
54
  /**
64
55
  * Sets the API key to identify the agent.
65
56
  *
package/lib/model/Book.js CHANGED
@@ -51,9 +51,15 @@ const TransactionIterator_1 = require("./TransactionIterator");
51
51
  * @public
52
52
  */
53
53
  class Book {
54
- /** @internal */
55
- constructor(wrapped) {
56
- this.wrapped = wrapped;
54
+ constructor(json) {
55
+ this.wrapped = json;
56
+ }
57
+ /**
58
+ *
59
+ * @returns The wrapped plain json object
60
+ */
61
+ json() {
62
+ return this.wrapped;
57
63
  }
58
64
  /**
59
65
  * Same as bookId param
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Month = exports.Period = exports.BalanceType = exports.AccountType = exports.Permission = exports.DecimalSeparator = exports.Periodicity = void 0;
3
+ exports.Month = exports.Period = exports.AccountType = exports.Permission = exports.DecimalSeparator = exports.Periodicity = void 0;
4
4
  /**
5
5
  * The Periodicity of the query. It may depend on the level of granularity you write the range params.
6
6
  *
@@ -95,26 +95,6 @@ var AccountType;
95
95
  */
96
96
  AccountType["OUTGOING"] = "OUTGOING";
97
97
  })(AccountType = exports.AccountType || (exports.AccountType = {}));
98
- /**
99
- * Enum that represents balance types.
100
- *
101
- * @public
102
- */
103
- var BalanceType;
104
- (function (BalanceType) {
105
- /**
106
- * Total balance
107
- */
108
- BalanceType["TOTAL"] = "TOTAL";
109
- /**
110
- * Period balance
111
- */
112
- BalanceType["PERIOD"] = "PERIOD";
113
- /**
114
- * Cumulative balance
115
- */
116
- BalanceType["CUMULATIVE"] = "CUMULATIVE";
117
- })(BalanceType = exports.BalanceType || (exports.BalanceType = {}));
118
98
  /**
119
99
  * Enum that represents a period slice.
120
100
  *
@@ -43,6 +43,13 @@ const Utils = __importStar(require("../utils"));
43
43
  * @public
44
44
  */
45
45
  class Group {
46
+ /**
47
+ *
48
+ * @returns The wrapped plain json object
49
+ */
50
+ json() {
51
+ return this.wrapped;
52
+ }
46
53
  /**
47
54
  * @returns The id of this Group
48
55
  */
@@ -43,6 +43,13 @@ const Amount_1 = require("./Amount");
43
43
  * @public
44
44
  */
45
45
  class Transaction {
46
+ /**
47
+ *
48
+ * @returns The wrapped plain json object
49
+ */
50
+ json() {
51
+ return this.wrapped;
52
+ }
46
53
  /**
47
54
  * @returns The id of the Transaction.
48
55
  */
@@ -278,13 +285,9 @@ class Transaction {
278
285
  getCreditAccount() {
279
286
  return __awaiter(this, void 0, void 0, function* () {
280
287
  if (!this.wrapped.creditAccount) {
281
- this.creditAccount = null;
282
288
  return null;
283
289
  }
284
- if (this.creditAccount == null) {
285
- this.creditAccount = yield this.book.getAccount(this.wrapped.creditAccount.id);
286
- }
287
- return this.creditAccount;
290
+ return yield this.book.getAccount(this.wrapped.creditAccount.id);
288
291
  });
289
292
  }
290
293
  /**
@@ -309,9 +312,15 @@ class Transaction {
309
312
  * @returns This Transaction, for chainning.
310
313
  */
311
314
  setCreditAccount(account) {
312
- if (account != null && account.getId() != null) {
313
- this.wrapped.creditAccount = account.wrapped;
314
- this.creditAccount = account;
315
+ if (account instanceof Account_1.Account) {
316
+ if (account != null && account.getId() != null) {
317
+ this.wrapped.creditAccount = account.wrapped;
318
+ }
319
+ }
320
+ else {
321
+ if (account != null && account.id != null) {
322
+ this.wrapped.creditAccount = account;
323
+ }
315
324
  }
316
325
  return this;
317
326
  }
@@ -334,13 +343,9 @@ class Transaction {
334
343
  getDebitAccount() {
335
344
  return __awaiter(this, void 0, void 0, function* () {
336
345
  if (!this.wrapped.debitAccount) {
337
- this.debitAccount = null;
338
346
  return null;
339
347
  }
340
- if (this.debitAccount == null) {
341
- this.debitAccount = yield this.book.getAccount(this.wrapped.debitAccount.id);
342
- }
343
- return this.debitAccount;
348
+ return yield this.book.getAccount(this.wrapped.debitAccount.id);
344
349
  });
345
350
  }
346
351
  /**
@@ -365,9 +370,15 @@ class Transaction {
365
370
  * @returns This Transaction, for chainning.
366
371
  */
367
372
  setDebitAccount(account) {
368
- if (account != null && account.getId() != null) {
369
- this.wrapped.debitAccount = account.wrapped;
370
- this.debitAccount = account;
373
+ if (account instanceof Account_1.Account) {
374
+ if (account != null && account.getId() != null) {
375
+ this.wrapped.debitAccount = account.wrapped;
376
+ }
377
+ }
378
+ else {
379
+ if (account != null && account.id != null) {
380
+ this.wrapped.debitAccount = account;
381
+ }
371
382
  }
372
383
  return this;
373
384
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper",
3
- "version": "2.2.0",
3
+ "version": "2.5.0",
4
4
  "description": "Node.js client for Bkper REST API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",