bkper-js 1.2.5 → 1.3.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
  /**
@@ -1832,4 +1858,20 @@ export declare class User {
1832
1858
  getConnection(id: string): Promise<Connection>;
1833
1859
  }
1834
1860
 
1861
+ /**
1862
+ * Enum representing the visibility of a Book
1863
+ *
1864
+ * @public
1865
+ */
1866
+ declare enum Visibility {
1867
+ /**
1868
+ * The book can be accessed by anyone with the link
1869
+ */
1870
+ PUBLIC = "PUBLIC",
1871
+ /**
1872
+ * The book can be accessed by the owner and collaborators
1873
+ */
1874
+ PRIVATE = "PRIVATE"
1875
+ }
1876
+
1835
1877
  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
  *
@@ -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.3.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",