bkper-js 1.8.0 → 1.8.2

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/Book.js CHANGED
@@ -8,18 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import * as AccountService from '../service/account-service.js';
11
- import * as GroupService from '../service/group-service.js';
12
11
  import * as BookService from '../service/book-service.js';
13
12
  import * as FileService from '../service/file-service.js';
14
- import * as TransactionService from '../service/transaction-service.js';
13
+ import * as GroupService from '../service/group-service.js';
15
14
  import * as IntegrationService from '../service/integration-service.js';
15
+ import * as TransactionService from '../service/transaction-service.js';
16
16
  import * as Utils from '../utils.js';
17
17
  import { Account } from './Account.js';
18
18
  import { Collection } from './Collection.js';
19
19
  import { File } from './File.js';
20
20
  import { Group } from './Group.js';
21
- import { Transaction } from './Transaction.js';
22
21
  import { Integration } from './Integration.js';
22
+ import { Transaction } from './Transaction.js';
23
23
  import { TransactionList } from './TransactionList.js';
24
24
  /**
25
25
  *
@@ -30,28 +30,28 @@ import { TransactionList } from './TransactionList.js';
30
30
  * @public
31
31
  */
32
32
  export class Book {
33
- constructor(json) {
34
- this.wrapped = json || {};
33
+ constructor(payload) {
34
+ this.payload = payload || {};
35
35
  this.mapGroups();
36
36
  this.mapAccounts();
37
37
  }
38
38
  /**
39
- * @returns The wrapped plain json object
39
+ * @returns An immutable copy of the json payload
40
40
  */
41
41
  json() {
42
- return this.wrapped;
42
+ return Object.assign({}, this.payload);
43
43
  }
44
44
  /**
45
45
  * Same as bookId param
46
46
  */
47
47
  getId() {
48
- return this.wrapped.id || '';
48
+ return this.payload.id || '';
49
49
  }
50
50
  /**
51
51
  * @returns The name of this Book
52
52
  */
53
53
  getName() {
54
- return this.wrapped.name;
54
+ return this.payload.name;
55
55
  }
56
56
  /**
57
57
  *
@@ -60,14 +60,14 @@ export class Book {
60
60
  * @returns This Book, for chainning.
61
61
  */
62
62
  setName(name) {
63
- this.wrapped.name = name;
63
+ this.payload.name = name;
64
64
  return this;
65
65
  }
66
66
  /**
67
67
  * @returns The number of fraction digits supported by this Book. Same as getDecimalPlaces
68
68
  */
69
69
  getFractionDigits() {
70
- return this.wrapped.fractionDigits;
70
+ return this.payload.fractionDigits;
71
71
  }
72
72
  /**
73
73
  * @returns The number of decimal places supported by this Book. Same as getFractionDigits
@@ -82,14 +82,14 @@ export class Book {
82
82
  * @returns This Book, for chainning.
83
83
  */
84
84
  setFractionDigits(fractionDigits) {
85
- this.wrapped.fractionDigits = fractionDigits;
85
+ this.payload.fractionDigits = fractionDigits;
86
86
  return this;
87
87
  }
88
88
  /**
89
89
  * @returns The period slice for balances visualization
90
90
  */
91
91
  getPeriod() {
92
- return this.wrapped.period;
92
+ return this.payload.period;
93
93
  }
94
94
  /**
95
95
  * Sets the period slice for balances visualization
@@ -97,14 +97,14 @@ export class Book {
97
97
  * @returns This Book, for chainning.
98
98
  */
99
99
  setPeriod(period) {
100
- this.wrapped.period = period;
100
+ this.payload.period = period;
101
101
  return this;
102
102
  }
103
103
  /**
104
104
  * @returns The start month when YEAR period set
105
105
  */
106
106
  getPeriodStartMonth() {
107
- return this.wrapped.periodStartMonth;
107
+ return this.payload.periodStartMonth;
108
108
  }
109
109
  /**
110
110
  * Sets the start month when YEAR period set
@@ -112,14 +112,14 @@ export class Book {
112
112
  * @returns This Book, for chainning.
113
113
  */
114
114
  setPeriodStartMonth(month) {
115
- this.wrapped.periodStartMonth = month;
115
+ this.payload.periodStartMonth = month;
116
116
  return this;
117
117
  }
118
118
  /**
119
119
  * @returns The transactions pagination page size
120
120
  */
121
121
  getPageSize() {
122
- return this.wrapped.pageSize;
122
+ return this.payload.pageSize;
123
123
  }
124
124
  /**
125
125
  * Sets the transactions pagination page size
@@ -127,27 +127,27 @@ export class Book {
127
127
  * @returns This Book, for chainning.
128
128
  */
129
129
  setPageSize(pageSize) {
130
- this.wrapped.pageSize = pageSize;
130
+ this.payload.pageSize = pageSize;
131
131
  return this;
132
132
  }
133
133
  /**
134
134
  * @returns The name of the owner of the Book
135
135
  */
136
136
  getOwnerName() {
137
- return this.wrapped.ownerName;
137
+ return this.payload.ownerName;
138
138
  }
139
139
  /**
140
140
  * @returns The permission for the current user
141
141
  */
142
142
  getPermission() {
143
- return this.wrapped.permission;
143
+ return this.payload.permission;
144
144
  }
145
145
  /**
146
146
  * @returns The collection of this book
147
147
  */
148
148
  getCollection() {
149
- if (this.wrapped.collection != null && this.collection == null) {
150
- this.collection = new Collection(this.wrapped.collection);
149
+ if (this.payload.collection != null && this.collection == null) {
150
+ this.collection = new Collection(this.payload.collection);
151
151
  }
152
152
  return this.collection;
153
153
  }
@@ -155,7 +155,7 @@ export class Book {
155
155
  * @returns The date pattern of the Book. Current: dd/MM/yyyy | MM/dd/yyyy | yyyy/MM/dd
156
156
  */
157
157
  getDatePattern() {
158
- return this.wrapped.datePattern;
158
+ return this.payload.datePattern;
159
159
  }
160
160
  /**
161
161
  *
@@ -164,14 +164,14 @@ export class Book {
164
164
  * @returns This Book, for chainning.
165
165
  */
166
166
  setDatePattern(datePattern) {
167
- this.wrapped.datePattern = datePattern;
167
+ this.payload.datePattern = datePattern;
168
168
  return this;
169
169
  }
170
170
  /**
171
171
  * @returns The lock date of the Book in ISO format yyyy-MM-dd
172
172
  */
173
173
  getLockDate() {
174
- return this.wrapped.lockDate;
174
+ return this.payload.lockDate;
175
175
  }
176
176
  /**
177
177
  *
@@ -183,14 +183,14 @@ export class Book {
183
183
  if (lockDate == null) {
184
184
  lockDate = "1900-00-00";
185
185
  }
186
- this.wrapped.lockDate = lockDate;
186
+ this.payload.lockDate = lockDate;
187
187
  return this;
188
188
  }
189
189
  /**
190
190
  * @returns The closing date of the Book in ISO format yyyy-MM-dd
191
191
  */
192
192
  getClosingDate() {
193
- return this.wrapped.closingDate;
193
+ return this.payload.closingDate;
194
194
  }
195
195
  /**
196
196
  *
@@ -202,14 +202,14 @@ export class Book {
202
202
  if (closingDate == null) {
203
203
  closingDate = "1900-00-00";
204
204
  }
205
- this.wrapped.closingDate = closingDate;
205
+ this.payload.closingDate = closingDate;
206
206
  return this;
207
207
  }
208
208
  /**
209
209
  * @returns The decimal separator of the Book
210
210
  */
211
211
  getDecimalSeparator() {
212
- return this.wrapped.decimalSeparator;
212
+ return this.payload.decimalSeparator;
213
213
  }
214
214
  /**
215
215
  *
@@ -218,14 +218,14 @@ export class Book {
218
218
  * @returns This Book, for chainning.
219
219
  */
220
220
  setDecimalSeparator(decimalSeparator) {
221
- this.wrapped.decimalSeparator = decimalSeparator;
221
+ this.payload.decimalSeparator = decimalSeparator;
222
222
  return this;
223
223
  }
224
224
  /**
225
225
  * @returns The time zone of the Book
226
226
  */
227
227
  getTimeZone() {
228
- return this.wrapped.timeZone;
228
+ return this.payload.timeZone;
229
229
  }
230
230
  /**
231
231
  *
@@ -234,50 +234,50 @@ export class Book {
234
234
  * @returns This Book, for chainning.
235
235
  */
236
236
  setTimeZone(timeZone) {
237
- this.wrapped.timeZone = timeZone;
237
+ this.payload.timeZone = timeZone;
238
238
  return this;
239
239
  }
240
240
  /**
241
241
  * @returns The time zone offset of the book, in minutes
242
242
  */
243
243
  getTimeZoneOffset() {
244
- return this.wrapped.timeZoneOffset;
244
+ return this.payload.timeZoneOffset;
245
245
  }
246
246
  /**
247
247
  * @returns The last update date of the book, in in milliseconds
248
248
  */
249
249
  getLastUpdateMs() {
250
- return this.wrapped.lastUpdateMs ? +this.wrapped.lastUpdateMs : undefined;
250
+ return this.payload.lastUpdateMs ? +this.payload.lastUpdateMs : undefined;
251
251
  }
252
252
  /**
253
253
  * @returns The total number of posted transactions
254
254
  */
255
255
  getTotalTransactions() {
256
- return this.wrapped.totalTransactions ? +(this.wrapped.totalTransactions) : 0;
256
+ return this.payload.totalTransactions ? +(this.payload.totalTransactions) : 0;
257
257
  }
258
258
  /**
259
259
  * @returns The total number of posted transactions on current month
260
260
  */
261
261
  getTotalTransactionsCurrentMonth() {
262
- return this.wrapped.totalTransactionsCurrentMonth ? +(this.wrapped.totalTransactionsCurrentMonth) : 0;
262
+ return this.payload.totalTransactionsCurrentMonth ? +(this.payload.totalTransactionsCurrentMonth) : 0;
263
263
  }
264
264
  /**
265
265
  * @returns The total number of posted transactions on current year
266
266
  */
267
267
  getTotalTransactionsCurrentYear() {
268
- return this.wrapped.totalTransactionsCurrentYear ? +(this.wrapped.totalTransactionsCurrentYear) : 0;
268
+ return this.payload.totalTransactionsCurrentYear ? +(this.payload.totalTransactionsCurrentYear) : 0;
269
269
  }
270
270
  /**
271
271
  * @returns The visibility of the book
272
272
  */
273
273
  getVisibility() {
274
- return this.wrapped.visibility;
274
+ return this.payload.visibility;
275
275
  }
276
276
  /**
277
277
  * Gets the custom properties stored in this Book
278
278
  */
279
279
  getProperties() {
280
- return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
280
+ return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
281
281
  }
282
282
  /**
283
283
  * Gets the property value for given keys. First property found will be retrieved
@@ -287,7 +287,7 @@ export class Book {
287
287
  getProperty(...keys) {
288
288
  for (let index = 0; index < keys.length; index++) {
289
289
  const key = keys[index];
290
- let value = this.wrapped.properties != null ? this.wrapped.properties[key] : null;
290
+ let value = this.payload.properties != null ? this.payload.properties[key] : null;
291
291
  if (value != null && value.trim() != '') {
292
292
  return value;
293
293
  }
@@ -302,7 +302,7 @@ export class Book {
302
302
  * @returns This Book, for chainning.
303
303
  */
304
304
  setProperties(properties) {
305
- this.wrapped.properties = Object.assign({}, properties);
305
+ this.payload.properties = Object.assign({}, properties);
306
306
  return this;
307
307
  }
308
308
  /**
@@ -317,13 +317,13 @@ export class Book {
317
317
  if (key == null || key.trim() == '') {
318
318
  return this;
319
319
  }
320
- if (this.wrapped.properties == null) {
321
- this.wrapped.properties = {};
320
+ if (this.payload.properties == null) {
321
+ this.payload.properties = {};
322
322
  }
323
323
  if (!value) {
324
324
  value = '';
325
325
  }
326
- this.wrapped.properties[key] = value;
326
+ this.payload.properties[key] = value;
327
327
  return this;
328
328
  }
329
329
  /**
@@ -702,7 +702,7 @@ export class Book {
702
702
  */
703
703
  create() {
704
704
  return __awaiter(this, void 0, void 0, function* () {
705
- this.wrapped = yield BookService.createBook(this.wrapped);
705
+ this.payload = yield BookService.createBook(this.payload);
706
706
  return this;
707
707
  });
708
708
  }
@@ -711,7 +711,7 @@ export class Book {
711
711
  */
712
712
  update() {
713
713
  return __awaiter(this, void 0, void 0, function* () {
714
- this.wrapped = yield BookService.updateBook(this.getId(), this.wrapped);
714
+ this.payload = yield BookService.updateBook(this.getId(), this.payload);
715
715
  return this;
716
716
  });
717
717
  }
@@ -5,41 +5,40 @@ import { Book } from "./Book.js";
5
5
  * @public
6
6
  */
7
7
  export class Collection {
8
- /** @internal */
9
- constructor(json) {
10
- this.wrapped = json || {};
8
+ constructor(payload) {
9
+ this.payload = payload || {};
10
+ }
11
+ /**
12
+ * @returns The wrapped plain json object
13
+ */
14
+ json() {
15
+ return Object.assign({}, this.payload);
11
16
  }
12
17
  /**
13
18
  * @returns The id of this Collection
14
19
  */
15
20
  getId() {
16
- return this.wrapped.id;
21
+ return this.payload.id;
17
22
  }
18
23
  /**
19
24
  * @returns The name of this Collection
20
25
  */
21
26
  getName() {
22
- return this.wrapped.name;
27
+ return this.payload.name;
23
28
  }
24
29
  /**
25
30
  * @returns All Books of this collection.
26
31
  */
27
32
  getBooks() {
28
33
  let books = [];
29
- if (this.wrapped.books == null) {
34
+ if (this.payload.books == null) {
30
35
  return books;
31
36
  }
32
- for (const bookPayload of this.wrapped.books) {
37
+ for (const bookPayload of this.payload.books) {
33
38
  let book = new Book(bookPayload);
34
39
  books.push(book);
35
40
  }
36
41
  return books;
37
42
  }
38
- /**
39
- * @returns The wrapped plain json object
40
- */
41
- json() {
42
- return this.wrapped;
43
- }
44
43
  }
45
44
  //# sourceMappingURL=Collection.js.map
@@ -15,16 +15,14 @@ import { Integration } from './Integration.js';
15
15
  * @public
16
16
  */
17
17
  export class Connection {
18
- constructor(json) {
19
- this.wrapped = json || {};
18
+ constructor(payload) {
19
+ this.payload = payload || {};
20
20
  }
21
21
  /**
22
- * Gets the wrapped plain json object of the Connection.
23
- *
24
- * @returns The Connection wrapped plain json object
22
+ * @returns An immutable copy of the json payload
25
23
  */
26
24
  json() {
27
- return this.wrapped;
25
+ return Object.assign({}, this.payload);
28
26
  }
29
27
  /**
30
28
  * Gets the id of the Connection.
@@ -32,7 +30,7 @@ export class Connection {
32
30
  * @returns The Connection's id
33
31
  */
34
32
  getId() {
35
- return this.wrapped.id;
33
+ return this.payload.id;
36
34
  }
37
35
  /**
38
36
  * Gets the agentId of the Connection.
@@ -40,7 +38,7 @@ export class Connection {
40
38
  * @returns The Connection's agentId
41
39
  */
42
40
  getAgentId() {
43
- return this.wrapped.agentId;
41
+ return this.payload.agentId;
44
42
  }
45
43
  /**
46
44
  * Sets the Connection agentId.
@@ -50,7 +48,7 @@ export class Connection {
50
48
  * @returns The Connection, for chainning
51
49
  */
52
50
  setAgentId(agentId) {
53
- this.wrapped.agentId = agentId;
51
+ this.payload.agentId = agentId;
54
52
  return this;
55
53
  }
56
54
  /**
@@ -59,7 +57,7 @@ export class Connection {
59
57
  * @returns The Connection name
60
58
  */
61
59
  getName() {
62
- return this.wrapped.name;
60
+ return this.payload.name;
63
61
  }
64
62
  /**
65
63
  * Gets the email of the owner of the Connection.
@@ -67,7 +65,7 @@ export class Connection {
67
65
  * @returns The Connection owner's email
68
66
  */
69
67
  getEmail() {
70
- return this.wrapped.email;
68
+ return this.payload.email;
71
69
  }
72
70
  /**
73
71
  * Sets the name of the Connection.
@@ -77,7 +75,7 @@ export class Connection {
77
75
  * @returns The Connection, for chainning
78
76
  */
79
77
  setName(name) {
80
- this.wrapped.name = name;
78
+ this.payload.name = name;
81
79
  return this;
82
80
  }
83
81
  /**
@@ -88,7 +86,7 @@ export class Connection {
88
86
  * @returns The Connection, for chainning
89
87
  */
90
88
  setUUID(uuid) {
91
- this.wrapped.uuid = uuid;
89
+ this.payload.uuid = uuid;
92
90
  return this;
93
91
  }
94
92
  /**
@@ -97,7 +95,7 @@ export class Connection {
97
95
  * @returns The Connection's universal unique identifier name
98
96
  */
99
97
  getUUID() {
100
- return this.wrapped.uuid;
98
+ return this.payload.uuid;
101
99
  }
102
100
  /**
103
101
  * Gets the type of the Connection.
@@ -105,7 +103,7 @@ export class Connection {
105
103
  * @returns The Connection type
106
104
  */
107
105
  getType() {
108
- return this.wrapped.type;
106
+ return this.payload.type;
109
107
  }
110
108
  /**
111
109
  * Sets the Connection type.
@@ -115,7 +113,7 @@ export class Connection {
115
113
  * @returns The Connection, for chainning
116
114
  */
117
115
  setType(type) {
118
- this.wrapped.type = type;
116
+ this.payload.type = type;
119
117
  return this;
120
118
  }
121
119
  /**
@@ -124,7 +122,7 @@ export class Connection {
124
122
  * @returns Object with key/value pair properties
125
123
  */
126
124
  getProperties() {
127
- return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
125
+ return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
128
126
  }
129
127
  /**
130
128
  * Sets the custom properties of the Connection.
@@ -134,7 +132,7 @@ export class Connection {
134
132
  * @returns The Connection, for chainning
135
133
  */
136
134
  setProperties(properties) {
137
- this.wrapped.properties = Object.assign({}, properties);
135
+ this.payload.properties = Object.assign({}, properties);
138
136
  return this;
139
137
  }
140
138
  /**
@@ -147,7 +145,7 @@ export class Connection {
147
145
  getProperty(...keys) {
148
146
  for (let index = 0; index < keys.length; index++) {
149
147
  const key = keys[index];
150
- let value = this.wrapped.properties != null ? this.wrapped.properties[key] : null;
148
+ let value = this.payload.properties != null ? this.payload.properties[key] : null;
151
149
  if (value != null && value.trim() != '') {
152
150
  return value;
153
151
  }
@@ -166,13 +164,13 @@ export class Connection {
166
164
  if (key == null || key.trim() == '') {
167
165
  return this;
168
166
  }
169
- if (this.wrapped.properties == null) {
170
- this.wrapped.properties = {};
167
+ if (this.payload.properties == null) {
168
+ this.payload.properties = {};
171
169
  }
172
170
  if (!value) {
173
171
  value = '';
174
172
  }
175
- this.wrapped.properties[key] = value;
173
+ this.payload.properties[key] = value;
176
174
  return this;
177
175
  }
178
176
  /**
@@ -229,7 +227,7 @@ export class Connection {
229
227
  */
230
228
  create() {
231
229
  return __awaiter(this, void 0, void 0, function* () {
232
- this.wrapped = yield ConnectionService.createConnection(this.wrapped);
230
+ this.payload = yield ConnectionService.createConnection(this.payload);
233
231
  return this;
234
232
  });
235
233
  }
package/lib/model/File.js CHANGED
@@ -17,28 +17,27 @@ import * as FileService from '../service/file-service.js';
17
17
  * @public
18
18
  */
19
19
  export class File {
20
- constructor(book, json) {
20
+ constructor(book, payload) {
21
21
  this.book = book;
22
- this.wrapped = json || {};
22
+ this.payload = payload || {};
23
23
  }
24
24
  /**
25
- *
26
- * @returns The wrapped plain json object
25
+ * @returns An immutable copy of the json payload
27
26
  */
28
27
  json() {
29
- return this.wrapped;
28
+ return Object.assign({}, this.payload);
30
29
  }
31
30
  /**
32
31
  * Gets the File id
33
32
  */
34
33
  getId() {
35
- return this.wrapped.id;
34
+ return this.payload.id;
36
35
  }
37
36
  /**
38
37
  * Gets the File name
39
38
  */
40
39
  getName() {
41
- return this.wrapped.name;
40
+ return this.payload.name;
42
41
  }
43
42
  /**
44
43
  *
@@ -47,14 +46,14 @@ export class File {
47
46
  * @returns This File, for chainning.
48
47
  */
49
48
  setName(name) {
50
- this.wrapped.name = name;
49
+ this.payload.name = name;
51
50
  return this;
52
51
  }
53
52
  /**
54
53
  * Gets the File content type
55
54
  */
56
55
  getContentType() {
57
- return this.wrapped.contentType;
56
+ return this.payload.contentType;
58
57
  }
59
58
  /**
60
59
  *
@@ -63,7 +62,7 @@ export class File {
63
62
  * @returns This File, for chainning.
64
63
  */
65
64
  setContentType(contentType) {
66
- this.wrapped.contentType = contentType;
65
+ this.payload.contentType = contentType;
67
66
  return this;
68
67
  }
69
68
  /**
@@ -72,10 +71,10 @@ export class File {
72
71
  getContent() {
73
72
  return __awaiter(this, void 0, void 0, function* () {
74
73
  const id = this.getId();
75
- if (this.getId() != null && (this.wrapped == null || this.wrapped.content == null) && this.book && id) {
76
- this.wrapped = yield FileService.getFile(this.book.getId(), id);
74
+ if (this.getId() != null && (this.payload == null || this.payload.content == null) && this.book && id) {
75
+ this.payload = yield FileService.getFile(this.book.getId(), id);
77
76
  }
78
- return this.wrapped.content;
77
+ return this.payload.content;
79
78
  });
80
79
  }
81
80
  /**
@@ -85,20 +84,20 @@ export class File {
85
84
  * @returns This File, for chainning.
86
85
  */
87
86
  setContent(content) {
88
- this.wrapped.content = content;
87
+ this.payload.content = content;
89
88
  return this;
90
89
  }
91
90
  /**
92
91
  * Gets the file serving url for accessing via browser
93
92
  */
94
93
  getUrl() {
95
- return this.wrapped.url;
94
+ return this.payload.url;
96
95
  }
97
96
  /**
98
97
  * Gets the file size in bytes
99
98
  */
100
99
  getSize() {
101
- return this.wrapped.size;
100
+ return this.payload.size;
102
101
  }
103
102
  /**
104
103
  * Perform create new File.
@@ -106,7 +105,7 @@ export class File {
106
105
  create() {
107
106
  return __awaiter(this, void 0, void 0, function* () {
108
107
  if (this.book) {
109
- this.wrapped = yield FileService.createFile(this.book.getId(), this.wrapped);
108
+ this.payload = yield FileService.createFile(this.book.getId(), this.payload);
110
109
  }
111
110
  return this;
112
111
  });