bkper-js 1.2.5 → 1.4.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
@@ -395,6 +395,12 @@ export declare class Bkper {
395
395
  * @returns The retrieved Book, for chaining
396
396
  */
397
397
  static getBook(id: string): Promise<Book>;
398
+ /**
399
+ * Gets all [[Books]] the user has access to.
400
+ *
401
+ * @returns The retrieved list of Books
402
+ */
403
+ static getBooks(): Promise<Book[]>;
398
404
  /**
399
405
  * Gets the current logged [[User]].
400
406
  *
@@ -578,6 +584,22 @@ export declare class Book {
578
584
  * @returns The last update date of the book, in in milliseconds
579
585
  */
580
586
  getLastUpdateMs(): number | undefined;
587
+ /**
588
+ * @returns The total number of posted transactions
589
+ */
590
+ getTotalTransactions(): number;
591
+ /**
592
+ * @returns The total number of posted transactions on current month
593
+ */
594
+ getTotalTransactionsCurrentMonth(): number;
595
+ /**
596
+ * @returns The total number of posted transactions on current year
597
+ */
598
+ getTotalTransactionsCurrentYear(): number;
599
+ /**
600
+ * @returns The visibility of the book
601
+ */
602
+ getVisibility(): Visibility;
581
603
  /**
582
604
  * Gets the custom properties stored in this Book
583
605
  */
@@ -832,6 +854,10 @@ export declare class Collection {
832
854
  * @returns All Books of this collection.
833
855
  */
834
856
  getBooks(): Book[];
857
+ /**
858
+ * @returns The wrapped plain json object
859
+ */
860
+ json(): bkper.Collection;
835
861
  }
836
862
 
837
863
  /**
@@ -1798,6 +1824,10 @@ export declare class TransactionIterator {
1798
1824
  export declare class User {
1799
1825
 
1800
1826
  constructor(json?: bkper.User);
1827
+ /**
1828
+ * @returns The wrapped plain json object
1829
+ */
1830
+ json(): bkper.User;
1801
1831
  /**
1802
1832
  * Gets the id of the User.
1803
1833
  *
@@ -1816,6 +1846,42 @@ export declare class User {
1816
1846
  * @returns The User's full name
1817
1847
  */
1818
1848
  getFullName(): string | undefined;
1849
+ /**
1850
+ * Gets the email of the User.
1851
+ *
1852
+ * @returns The User's email
1853
+ */
1854
+ getEmail(): string | undefined;
1855
+ /**
1856
+ * Gets the hosted domain of the User.
1857
+ *
1858
+ * @returns The User's hosted domain
1859
+ */
1860
+ getHostedDomain(): string | undefined;
1861
+ /**
1862
+ * Tells if the User is in the free plan.
1863
+ *
1864
+ * @returns True if the User is in the free plan
1865
+ */
1866
+ isFree(): boolean | undefined;
1867
+ /**
1868
+ * Tells if the User has started the trial.
1869
+ *
1870
+ * @returns True if the User has started the trial
1871
+ */
1872
+ hasStartedTrial(): boolean | undefined;
1873
+ /**
1874
+ * Gets the days left in User's trial.
1875
+ *
1876
+ * @returns The User's days left in trial
1877
+ */
1878
+ getDaysLeftInTrial(): number | undefined;
1879
+ /**
1880
+ * Tells if the User has already used [[Connections]].
1881
+ *
1882
+ * @returns True if the User has already used Connections
1883
+ */
1884
+ hasUsedConnections(): boolean | undefined;
1819
1885
  /**
1820
1886
  * Gets the [[Connections]] of the User.
1821
1887
  *
@@ -1832,4 +1898,20 @@ export declare class User {
1832
1898
  getConnection(id: string): Promise<Connection>;
1833
1899
  }
1834
1900
 
1901
+ /**
1902
+ * Enum representing the visibility of a Book
1903
+ *
1904
+ * @public
1905
+ */
1906
+ declare enum Visibility {
1907
+ /**
1908
+ * The book can be accessed by anyone with the link
1909
+ */
1910
+ PUBLIC = "PUBLIC",
1911
+ /**
1912
+ * The book can be accessed by the owner and collaborators
1913
+ */
1914
+ PRIVATE = "PRIVATE"
1915
+ }
1916
+
1835
1917
  export { }
@@ -45,6 +45,17 @@ export class Bkper {
45
45
  return new Book(book);
46
46
  });
47
47
  }
48
+ /**
49
+ * Gets all [[Books]] the user has access to.
50
+ *
51
+ * @returns The retrieved list of Books
52
+ */
53
+ static getBooks() {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ let books = yield BookService.loadBooks();
56
+ return books.map(book => new Book(book));
57
+ });
58
+ }
48
59
  /**
49
60
  * Gets the current logged [[User]].
50
61
  *
package/lib/model/Book.js CHANGED
@@ -248,6 +248,30 @@ export class Book {
248
248
  getLastUpdateMs() {
249
249
  return this.wrapped.lastUpdateMs ? +this.wrapped.lastUpdateMs : undefined;
250
250
  }
251
+ /**
252
+ * @returns The total number of posted transactions
253
+ */
254
+ getTotalTransactions() {
255
+ return this.wrapped.totalTransactions ? +(this.wrapped.totalTransactions) : 0;
256
+ }
257
+ /**
258
+ * @returns The total number of posted transactions on current month
259
+ */
260
+ getTotalTransactionsCurrentMonth() {
261
+ return this.wrapped.totalTransactionsCurrentMonth ? +(this.wrapped.totalTransactionsCurrentMonth) : 0;
262
+ }
263
+ /**
264
+ * @returns The total number of posted transactions on current year
265
+ */
266
+ getTotalTransactionsCurrentYear() {
267
+ return this.wrapped.totalTransactionsCurrentYear ? +(this.wrapped.totalTransactionsCurrentYear) : 0;
268
+ }
269
+ /**
270
+ * @returns The visibility of the book
271
+ */
272
+ getVisibility() {
273
+ return this.wrapped.visibility;
274
+ }
251
275
  /**
252
276
  * Gets the custom properties stored in this Book
253
277
  */
@@ -35,5 +35,11 @@ export class Collection {
35
35
  }
36
36
  return books;
37
37
  }
38
+ /**
39
+ * @returns The wrapped plain json object
40
+ */
41
+ json() {
42
+ return this.wrapped;
43
+ }
38
44
  }
39
45
  //# sourceMappingURL=Collection.js.map
@@ -68,6 +68,22 @@ export var Permission;
68
68
  */
69
69
  Permission["OWNER"] = "OWNER";
70
70
  })(Permission || (Permission = {}));
71
+ /**
72
+ * Enum representing the visibility of a Book
73
+ *
74
+ * @public
75
+ */
76
+ export var Visibility;
77
+ (function (Visibility) {
78
+ /**
79
+ * The book can be accessed by anyone with the link
80
+ */
81
+ Visibility["PUBLIC"] = "PUBLIC";
82
+ /**
83
+ * The book can be accessed by the owner and collaborators
84
+ */
85
+ Visibility["PRIVATE"] = "PRIVATE";
86
+ })(Visibility || (Visibility = {}));
71
87
  /**
72
88
  * Enum that represents account types.
73
89
  *
package/lib/model/User.js CHANGED
@@ -20,6 +20,12 @@ export class User {
20
20
  this.wrapped = {};
21
21
  this.wrapped = json || {};
22
22
  }
23
+ /**
24
+ * @returns The wrapped plain json object
25
+ */
26
+ json() {
27
+ return this.wrapped;
28
+ }
23
29
  /**
24
30
  * Gets the id of the User.
25
31
  *
@@ -44,6 +50,54 @@ export class User {
44
50
  getFullName() {
45
51
  return this.wrapped.fullName;
46
52
  }
53
+ /**
54
+ * Gets the email of the User.
55
+ *
56
+ * @returns The User's email
57
+ */
58
+ getEmail() {
59
+ return this.wrapped.email;
60
+ }
61
+ /**
62
+ * Gets the hosted domain of the User.
63
+ *
64
+ * @returns The User's hosted domain
65
+ */
66
+ getHostedDomain() {
67
+ return this.wrapped.hostedDomain;
68
+ }
69
+ /**
70
+ * Tells if the User is in the free plan.
71
+ *
72
+ * @returns True if the User is in the free plan
73
+ */
74
+ isFree() {
75
+ return this.wrapped.free;
76
+ }
77
+ /**
78
+ * Tells if the User has started the trial.
79
+ *
80
+ * @returns True if the User has started the trial
81
+ */
82
+ hasStartedTrial() {
83
+ return this.wrapped.startedTrial;
84
+ }
85
+ /**
86
+ * Gets the days left in User's trial.
87
+ *
88
+ * @returns The User's days left in trial
89
+ */
90
+ getDaysLeftInTrial() {
91
+ return this.wrapped.daysLeftInTrial;
92
+ }
93
+ /**
94
+ * Tells if the User has already used [[Connections]].
95
+ *
96
+ * @returns True if the User has already used Connections
97
+ */
98
+ hasUsedConnections() {
99
+ return this.wrapped.bankConnections;
100
+ }
47
101
  /**
48
102
  * Gets the [[Connections]] of the User.
49
103
  *
@@ -8,6 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { HttpBooksApiV5Request } from "./http-api-request.js";
11
+ export function loadBooks() {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ let response = yield new HttpBooksApiV5Request('').fetch();
14
+ if (response.data == null) {
15
+ return [];
16
+ }
17
+ let bookListPlain = response.data;
18
+ let booksJson = bookListPlain.items;
19
+ if (booksJson == null) {
20
+ return [];
21
+ }
22
+ return booksJson;
23
+ });
24
+ }
11
25
  export function loadBook(bookId) {
12
26
  return __awaiter(this, void 0, void 0, function* () {
13
27
  if (bookId == null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "1.2.5",
3
+ "version": "1.4.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -41,7 +41,7 @@
41
41
  "luxon": "^1.25.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@bkper/bkper-api-types": "^5.9.0",
44
+ "@bkper/bkper-api-types": "^5.10.0",
45
45
  "@microsoft/api-extractor": "^7.12.1",
46
46
  "@types/big.js": "^6.0.2",
47
47
  "@types/chai": "^4.2.14",