bkper-js 1.8.1 → 1.9.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 +45 -118
- package/lib/model/Account.js +46 -42
- package/lib/model/Amount.js +53 -53
- package/lib/model/App.js +18 -18
- package/lib/model/Book.js +46 -122
- package/lib/model/Collection.js +12 -13
- package/lib/model/Connection.js +21 -23
- package/lib/model/File.js +19 -17
- package/lib/model/Group.js +28 -27
- package/lib/model/Integration.js +13 -15
- package/lib/model/Template.js +15 -17
- package/lib/model/Transaction.js +69 -70
- package/lib/model/TransactionList.js +7 -7
- package/lib/model/User.js +14 -15
- package/package.json +1 -1
package/lib/model/Transaction.js
CHANGED
|
@@ -21,18 +21,17 @@ import { Amount } from './Amount.js';
|
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
export class Transaction {
|
|
24
|
-
constructor(book,
|
|
24
|
+
constructor(book, payload) {
|
|
25
25
|
this.book = book;
|
|
26
|
-
this.
|
|
26
|
+
this.payload = payload || {
|
|
27
27
|
createdAt: `${Date.now()}`
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @returns The wrapped plain json object
|
|
31
|
+
* @returns An immutable copy of the json payload
|
|
33
32
|
*/
|
|
34
33
|
json() {
|
|
35
|
-
return this.
|
|
34
|
+
return Object.assign({}, this.payload);
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
37
|
* @returns The book of the Transaction.
|
|
@@ -44,13 +43,13 @@ export class Transaction {
|
|
|
44
43
|
* @returns The id of the Transaction.
|
|
45
44
|
*/
|
|
46
45
|
getId() {
|
|
47
|
-
return this.
|
|
46
|
+
return this.payload.id;
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
49
|
* @returns The id of the agent that created this transaction
|
|
51
50
|
*/
|
|
52
51
|
getAgentId() {
|
|
53
|
-
return this.
|
|
52
|
+
return this.payload.agentId;
|
|
54
53
|
}
|
|
55
54
|
/**
|
|
56
55
|
* Remote ids are used to avoid duplication.
|
|
@@ -58,7 +57,7 @@ export class Transaction {
|
|
|
58
57
|
* @returns The remote ids of the Transaction.
|
|
59
58
|
*/
|
|
60
59
|
getRemoteIds() {
|
|
61
|
-
return this.
|
|
60
|
+
return this.payload.remoteIds || [];
|
|
62
61
|
}
|
|
63
62
|
/**
|
|
64
63
|
* Add a remote id to the Transaction.
|
|
@@ -68,11 +67,11 @@ export class Transaction {
|
|
|
68
67
|
* @returns This Transaction, for chainning.
|
|
69
68
|
*/
|
|
70
69
|
addRemoteId(remoteId) {
|
|
71
|
-
if (this.
|
|
72
|
-
this.
|
|
70
|
+
if (this.payload.remoteIds == null) {
|
|
71
|
+
this.payload.remoteIds = [];
|
|
73
72
|
}
|
|
74
73
|
if (remoteId) {
|
|
75
|
-
this.
|
|
74
|
+
this.payload.remoteIds.push(remoteId);
|
|
76
75
|
}
|
|
77
76
|
return this;
|
|
78
77
|
}
|
|
@@ -80,13 +79,13 @@ export class Transaction {
|
|
|
80
79
|
* @returns True if transaction was already posted to the accounts. False if is still a Draft.
|
|
81
80
|
*/
|
|
82
81
|
isPosted() {
|
|
83
|
-
return this.
|
|
82
|
+
return this.payload.posted;
|
|
84
83
|
}
|
|
85
84
|
/**
|
|
86
85
|
* @returns True if transaction is checked.
|
|
87
86
|
*/
|
|
88
87
|
isChecked() {
|
|
89
|
-
return this.
|
|
88
|
+
return this.payload.checked;
|
|
90
89
|
}
|
|
91
90
|
/**
|
|
92
91
|
* Set the check state of the Transaction.
|
|
@@ -96,26 +95,26 @@ export class Transaction {
|
|
|
96
95
|
* @returns This Transaction, for chainning.
|
|
97
96
|
*/
|
|
98
97
|
setChecked(checked) {
|
|
99
|
-
this.
|
|
98
|
+
this.payload.checked = checked;
|
|
100
99
|
return this;
|
|
101
100
|
}
|
|
102
101
|
/**
|
|
103
102
|
* @returns True if transaction is in trash.
|
|
104
103
|
*/
|
|
105
104
|
isTrashed() {
|
|
106
|
-
return this.
|
|
105
|
+
return this.payload.trashed;
|
|
107
106
|
}
|
|
108
107
|
/**
|
|
109
108
|
* @returns All #hashtags used on the transaction.
|
|
110
109
|
*/
|
|
111
110
|
getTags() {
|
|
112
|
-
return this.
|
|
111
|
+
return this.payload.tags || [];
|
|
113
112
|
}
|
|
114
113
|
/**
|
|
115
114
|
* @returns All urls of the transaction.
|
|
116
115
|
*/
|
|
117
116
|
getUrls() {
|
|
118
|
-
return this.
|
|
117
|
+
return this.payload.urls || [];
|
|
119
118
|
}
|
|
120
119
|
/**
|
|
121
120
|
* Sets the Transaction urls. Url starts with https://
|
|
@@ -125,7 +124,7 @@ export class Transaction {
|
|
|
125
124
|
* @returns This Transaction, for chainning.
|
|
126
125
|
*/
|
|
127
126
|
setUrls(urls) {
|
|
128
|
-
this.
|
|
127
|
+
this.payload.urls = undefined;
|
|
129
128
|
if (urls) {
|
|
130
129
|
urls.forEach(url => {
|
|
131
130
|
this.addUrl(url);
|
|
@@ -141,11 +140,11 @@ export class Transaction {
|
|
|
141
140
|
* @returns This Transaction, for chainning.
|
|
142
141
|
*/
|
|
143
142
|
addUrl(url) {
|
|
144
|
-
if (this.
|
|
145
|
-
this.
|
|
143
|
+
if (this.payload.urls == null) {
|
|
144
|
+
this.payload.urls = [];
|
|
146
145
|
}
|
|
147
146
|
if (url) {
|
|
148
|
-
this.
|
|
147
|
+
this.payload.urls.push(url);
|
|
149
148
|
}
|
|
150
149
|
return this;
|
|
151
150
|
}
|
|
@@ -153,8 +152,8 @@ export class Transaction {
|
|
|
153
152
|
* @returns The files attached to the transaction.
|
|
154
153
|
*/
|
|
155
154
|
getFiles() {
|
|
156
|
-
if (this.
|
|
157
|
-
const files = this.
|
|
155
|
+
if (this.payload.files && this.payload.files.length > 0) {
|
|
156
|
+
const files = this.payload.files.map(file => new File(this.book, file));
|
|
158
157
|
return files;
|
|
159
158
|
}
|
|
160
159
|
else {
|
|
@@ -173,14 +172,14 @@ export class Transaction {
|
|
|
173
172
|
*/
|
|
174
173
|
addFile(file) {
|
|
175
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
if (this.
|
|
177
|
-
this.
|
|
175
|
+
if (this.payload.files == null) {
|
|
176
|
+
this.payload.files = [];
|
|
178
177
|
}
|
|
179
178
|
//Make sure file is already created
|
|
180
179
|
if (file.getId() == null) {
|
|
181
180
|
file = yield file.create();
|
|
182
181
|
}
|
|
183
|
-
this.
|
|
182
|
+
this.payload.files.push(file.json());
|
|
184
183
|
return this;
|
|
185
184
|
});
|
|
186
185
|
}
|
|
@@ -200,7 +199,7 @@ export class Transaction {
|
|
|
200
199
|
* Gets the custom properties stored in this Transaction.
|
|
201
200
|
*/
|
|
202
201
|
getProperties() {
|
|
203
|
-
return this.
|
|
202
|
+
return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
|
|
204
203
|
}
|
|
205
204
|
/**
|
|
206
205
|
* Sets the custom properties of the Transaction
|
|
@@ -210,7 +209,7 @@ export class Transaction {
|
|
|
210
209
|
* @returns This Transaction, for chainning.
|
|
211
210
|
*/
|
|
212
211
|
setProperties(properties) {
|
|
213
|
-
this.
|
|
212
|
+
this.payload.properties = Object.assign({}, properties);
|
|
214
213
|
return this;
|
|
215
214
|
}
|
|
216
215
|
/**
|
|
@@ -221,7 +220,7 @@ export class Transaction {
|
|
|
221
220
|
getProperty(...keys) {
|
|
222
221
|
for (let index = 0; index < keys.length; index++) {
|
|
223
222
|
const key = keys[index];
|
|
224
|
-
let value = this.
|
|
223
|
+
let value = this.payload.properties != null ? this.payload.properties[key] : null;
|
|
225
224
|
if (value != null && value.trim() != '') {
|
|
226
225
|
return value;
|
|
227
226
|
}
|
|
@@ -256,13 +255,13 @@ export class Transaction {
|
|
|
256
255
|
if (key == null || key.trim() == '') {
|
|
257
256
|
return this;
|
|
258
257
|
}
|
|
259
|
-
if (this.
|
|
260
|
-
this.
|
|
258
|
+
if (this.payload.properties == null) {
|
|
259
|
+
this.payload.properties = {};
|
|
261
260
|
}
|
|
262
261
|
if (!value) {
|
|
263
262
|
value = '';
|
|
264
263
|
}
|
|
265
|
-
this.
|
|
264
|
+
this.payload.properties[key] = value;
|
|
266
265
|
return this;
|
|
267
266
|
}
|
|
268
267
|
/**
|
|
@@ -282,10 +281,10 @@ export class Transaction {
|
|
|
282
281
|
*/
|
|
283
282
|
getCreditAccount() {
|
|
284
283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
-
if (!this.
|
|
284
|
+
if (!this.payload.creditAccount) {
|
|
286
285
|
return undefined;
|
|
287
286
|
}
|
|
288
|
-
return yield this.book.getAccount(this.
|
|
287
|
+
return yield this.book.getAccount(this.payload.creditAccount.id);
|
|
289
288
|
});
|
|
290
289
|
}
|
|
291
290
|
/**
|
|
@@ -313,12 +312,12 @@ export class Transaction {
|
|
|
313
312
|
setCreditAccount(account) {
|
|
314
313
|
if (account instanceof Account) {
|
|
315
314
|
if (account != null && account.getId() != null) {
|
|
316
|
-
this.
|
|
315
|
+
this.payload.creditAccount = account.json();
|
|
317
316
|
}
|
|
318
317
|
}
|
|
319
318
|
else {
|
|
320
319
|
if (account != null && account.id != null) {
|
|
321
|
-
this.
|
|
320
|
+
this.payload.creditAccount = account;
|
|
322
321
|
}
|
|
323
322
|
}
|
|
324
323
|
return this;
|
|
@@ -341,10 +340,10 @@ export class Transaction {
|
|
|
341
340
|
*/
|
|
342
341
|
getDebitAccount() {
|
|
343
342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
344
|
-
if (!this.
|
|
343
|
+
if (!this.payload.debitAccount) {
|
|
345
344
|
return undefined;
|
|
346
345
|
}
|
|
347
|
-
return yield this.book.getAccount(this.
|
|
346
|
+
return yield this.book.getAccount(this.payload.debitAccount.id);
|
|
348
347
|
});
|
|
349
348
|
}
|
|
350
349
|
/**
|
|
@@ -372,12 +371,12 @@ export class Transaction {
|
|
|
372
371
|
setDebitAccount(account) {
|
|
373
372
|
if (account instanceof Account) {
|
|
374
373
|
if (account != null && account.getId() != null) {
|
|
375
|
-
this.
|
|
374
|
+
this.payload.debitAccount = account.json();
|
|
376
375
|
}
|
|
377
376
|
}
|
|
378
377
|
else {
|
|
379
378
|
if (account != null && account.id != null) {
|
|
380
|
-
this.
|
|
379
|
+
this.payload.debitAccount = account;
|
|
381
380
|
}
|
|
382
381
|
}
|
|
383
382
|
return this;
|
|
@@ -398,7 +397,7 @@ export class Transaction {
|
|
|
398
397
|
* @returns The amount of the transaction.
|
|
399
398
|
*/
|
|
400
399
|
getAmount() {
|
|
401
|
-
return this.
|
|
400
|
+
return this.payload.amount != null && this.payload.amount.trim() != '' ? new Amount(this.payload.amount) : undefined;
|
|
402
401
|
}
|
|
403
402
|
/**
|
|
404
403
|
*
|
|
@@ -409,15 +408,15 @@ export class Transaction {
|
|
|
409
408
|
setAmount(amount) {
|
|
410
409
|
if (typeof amount == "string") {
|
|
411
410
|
amount = Utils.parseValue(amount, this.book.getDecimalSeparator()) + '';
|
|
412
|
-
this.
|
|
411
|
+
this.payload.amount = amount.toString();
|
|
413
412
|
return this;
|
|
414
413
|
}
|
|
415
414
|
amount = new Amount(amount);
|
|
416
415
|
if (amount.eq(0)) {
|
|
417
|
-
this.
|
|
416
|
+
this.payload.amount = undefined;
|
|
418
417
|
return this;
|
|
419
418
|
}
|
|
420
|
-
this.
|
|
419
|
+
this.payload.amount = amount.abs().toString();
|
|
421
420
|
return this;
|
|
422
421
|
}
|
|
423
422
|
/**
|
|
@@ -520,10 +519,10 @@ export class Transaction {
|
|
|
520
519
|
* @returns The description of this transaction.
|
|
521
520
|
*/
|
|
522
521
|
getDescription() {
|
|
523
|
-
if (this.
|
|
522
|
+
if (this.payload.description == null) {
|
|
524
523
|
return "";
|
|
525
524
|
}
|
|
526
|
-
return this.
|
|
525
|
+
return this.payload.description;
|
|
527
526
|
}
|
|
528
527
|
/**
|
|
529
528
|
*
|
|
@@ -532,7 +531,7 @@ export class Transaction {
|
|
|
532
531
|
* @returns This Transaction, for chainning.
|
|
533
532
|
*/
|
|
534
533
|
setDescription(description) {
|
|
535
|
-
this.
|
|
534
|
+
this.payload.description = description;
|
|
536
535
|
return this;
|
|
537
536
|
}
|
|
538
537
|
//DATE
|
|
@@ -540,7 +539,7 @@ export class Transaction {
|
|
|
540
539
|
* @returns The Transaction date, in ISO format yyyy-MM-dd.
|
|
541
540
|
*/
|
|
542
541
|
getDate() {
|
|
543
|
-
return this.
|
|
542
|
+
return this.payload.date;
|
|
544
543
|
}
|
|
545
544
|
/**
|
|
546
545
|
*
|
|
@@ -552,14 +551,14 @@ export class Transaction {
|
|
|
552
551
|
if (typeof date == "string") {
|
|
553
552
|
if (date.indexOf('/') > 0) {
|
|
554
553
|
let dateObject = Utils.parseDate(date, this.book.getDatePattern(), this.book.getTimeZone());
|
|
555
|
-
this.
|
|
554
|
+
this.payload.date = Utils.formatDateISO(dateObject, this.book.getTimeZone());
|
|
556
555
|
}
|
|
557
556
|
else if (date.indexOf('-')) {
|
|
558
|
-
this.
|
|
557
|
+
this.payload.date = date;
|
|
559
558
|
}
|
|
560
559
|
}
|
|
561
560
|
else if (Object.prototype.toString.call(date) === '[object Date]') {
|
|
562
|
-
this.
|
|
561
|
+
this.payload.date = Utils.formatDateISO(date, this.book.getTimeZone());
|
|
563
562
|
}
|
|
564
563
|
return this;
|
|
565
564
|
}
|
|
@@ -573,19 +572,19 @@ export class Transaction {
|
|
|
573
572
|
* @returns The Transaction date number, in format YYYYMMDD.
|
|
574
573
|
*/
|
|
575
574
|
getDateValue() {
|
|
576
|
-
return this.
|
|
575
|
+
return this.payload.dateValue;
|
|
577
576
|
}
|
|
578
577
|
/**
|
|
579
578
|
* @returns The Transaction date, formatted on the date pattern of the [[Book]].
|
|
580
579
|
*/
|
|
581
580
|
getDateFormatted() {
|
|
582
|
-
return this.
|
|
581
|
+
return this.payload.dateFormatted;
|
|
583
582
|
}
|
|
584
583
|
/**
|
|
585
584
|
* @returns The date the transaction was created.
|
|
586
585
|
*/
|
|
587
586
|
getCreatedAt() {
|
|
588
|
-
return new Date(new Number(this.
|
|
587
|
+
return new Date(new Number(this.payload.createdAt).valueOf());
|
|
589
588
|
}
|
|
590
589
|
/**
|
|
591
590
|
* @returns The date the transaction was created, formatted according to the date pattern of [[Book]].
|
|
@@ -596,11 +595,11 @@ export class Transaction {
|
|
|
596
595
|
//EVOLVED BALANCES
|
|
597
596
|
/** @internal */
|
|
598
597
|
getCaEvolvedBalance_() {
|
|
599
|
-
return this.
|
|
598
|
+
return this.payload.creditAccount != null && this.payload.creditAccount.balance != null ? new Amount(this.payload.creditAccount.balance) : undefined;
|
|
600
599
|
}
|
|
601
600
|
/** @internal */
|
|
602
601
|
getDaEvolvedBalance_() {
|
|
603
|
-
return this.
|
|
602
|
+
return this.payload.debitAccount != null && this.payload.debitAccount.balance != null ? new Amount(this.payload.debitAccount.balance) : undefined;
|
|
604
603
|
}
|
|
605
604
|
/**
|
|
606
605
|
* Gets the balance that the [[Account]] has at that day, when listing transactions of that Account.
|
|
@@ -636,8 +635,8 @@ export class Transaction {
|
|
|
636
635
|
*/
|
|
637
636
|
create() {
|
|
638
637
|
return __awaiter(this, void 0, void 0, function* () {
|
|
639
|
-
let operation = yield TransactionService.createTransaction(this.book.getId(), this.
|
|
640
|
-
this.
|
|
638
|
+
let operation = yield TransactionService.createTransaction(this.book.getId(), this.payload);
|
|
639
|
+
this.payload = operation.transaction || {};
|
|
641
640
|
return this;
|
|
642
641
|
});
|
|
643
642
|
}
|
|
@@ -646,8 +645,8 @@ export class Transaction {
|
|
|
646
645
|
*/
|
|
647
646
|
update() {
|
|
648
647
|
return __awaiter(this, void 0, void 0, function* () {
|
|
649
|
-
let operation = yield TransactionService.updateTransaction(this.book.getId(), this.
|
|
650
|
-
this.
|
|
648
|
+
let operation = yield TransactionService.updateTransaction(this.book.getId(), this.payload);
|
|
649
|
+
this.payload = operation.transaction || {};
|
|
651
650
|
return this;
|
|
652
651
|
});
|
|
653
652
|
}
|
|
@@ -657,8 +656,8 @@ export class Transaction {
|
|
|
657
656
|
check() {
|
|
658
657
|
return __awaiter(this, void 0, void 0, function* () {
|
|
659
658
|
var _a;
|
|
660
|
-
let operation = yield TransactionService.checkTransaction(this.book.getId(), this.
|
|
661
|
-
this.
|
|
659
|
+
let operation = yield TransactionService.checkTransaction(this.book.getId(), this.payload);
|
|
660
|
+
this.payload.checked = (_a = operation.transaction) === null || _a === void 0 ? void 0 : _a.checked;
|
|
662
661
|
return this;
|
|
663
662
|
});
|
|
664
663
|
}
|
|
@@ -668,8 +667,8 @@ export class Transaction {
|
|
|
668
667
|
uncheck() {
|
|
669
668
|
return __awaiter(this, void 0, void 0, function* () {
|
|
670
669
|
var _a;
|
|
671
|
-
let operation = yield TransactionService.uncheckTransaction(this.book.getId(), this.
|
|
672
|
-
this.
|
|
670
|
+
let operation = yield TransactionService.uncheckTransaction(this.book.getId(), this.payload);
|
|
671
|
+
this.payload.checked = (_a = operation.transaction) === null || _a === void 0 ? void 0 : _a.checked;
|
|
673
672
|
return this;
|
|
674
673
|
});
|
|
675
674
|
}
|
|
@@ -678,8 +677,8 @@ export class Transaction {
|
|
|
678
677
|
*/
|
|
679
678
|
post() {
|
|
680
679
|
return __awaiter(this, void 0, void 0, function* () {
|
|
681
|
-
let operation = yield TransactionService.postTransaction(this.book.getId(), this.
|
|
682
|
-
this.
|
|
680
|
+
let operation = yield TransactionService.postTransaction(this.book.getId(), this.payload);
|
|
681
|
+
this.payload = operation.transaction || {};
|
|
683
682
|
return this;
|
|
684
683
|
});
|
|
685
684
|
}
|
|
@@ -689,8 +688,8 @@ export class Transaction {
|
|
|
689
688
|
remove() {
|
|
690
689
|
return __awaiter(this, void 0, void 0, function* () {
|
|
691
690
|
var _a;
|
|
692
|
-
let operation = yield TransactionService.trashTransaction(this.book.getId(), this.
|
|
693
|
-
this.
|
|
691
|
+
let operation = yield TransactionService.trashTransaction(this.book.getId(), this.payload);
|
|
692
|
+
this.payload.trashed = (_a = operation.transaction) === null || _a === void 0 ? void 0 : _a.trashed;
|
|
694
693
|
return this;
|
|
695
694
|
});
|
|
696
695
|
}
|
|
@@ -700,8 +699,8 @@ export class Transaction {
|
|
|
700
699
|
restore() {
|
|
701
700
|
return __awaiter(this, void 0, void 0, function* () {
|
|
702
701
|
var _a;
|
|
703
|
-
let operation = yield TransactionService.restoreTransaction(this.book.getId(), this.
|
|
704
|
-
this.
|
|
702
|
+
let operation = yield TransactionService.restoreTransaction(this.book.getId(), this.payload);
|
|
703
|
+
this.payload.trashed = (_a = operation.transaction) === null || _a === void 0 ? void 0 : _a.trashed;
|
|
705
704
|
return this;
|
|
706
705
|
});
|
|
707
706
|
}
|
|
@@ -12,25 +12,25 @@ import { Transaction } from "./Transaction.js";
|
|
|
12
12
|
* A list associated with a transaction query.
|
|
13
13
|
*/
|
|
14
14
|
export class TransactionList {
|
|
15
|
-
constructor(book,
|
|
15
|
+
constructor(book, payload) {
|
|
16
16
|
this.book = book;
|
|
17
|
-
this.
|
|
17
|
+
this.payload = payload;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* @returns The cursor associated with the query for pagination.
|
|
21
21
|
*/
|
|
22
22
|
getCursor() {
|
|
23
|
-
return this.
|
|
23
|
+
return this.payload.cursor;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Retrieves the account associated with the query, when filtering by account.
|
|
27
27
|
*/
|
|
28
28
|
getAccount() {
|
|
29
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
if (!this.
|
|
30
|
+
if (!this.payload.account) {
|
|
31
31
|
return undefined;
|
|
32
32
|
}
|
|
33
|
-
return yield this.book.getAccount(this.
|
|
33
|
+
return yield this.book.getAccount(this.payload.account);
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -48,7 +48,7 @@ export class TransactionList {
|
|
|
48
48
|
*/
|
|
49
49
|
size() {
|
|
50
50
|
var _a;
|
|
51
|
-
return ((_a = this.
|
|
51
|
+
return ((_a = this.payload.items) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Get the transactions in the list.
|
|
@@ -58,7 +58,7 @@ export class TransactionList {
|
|
|
58
58
|
getItems() {
|
|
59
59
|
var _a;
|
|
60
60
|
let transactions = [];
|
|
61
|
-
for (let transaction of (_a = this.
|
|
61
|
+
for (let transaction of (_a = this.payload.items) !== null && _a !== void 0 ? _a : []) {
|
|
62
62
|
transactions.push(new Transaction(this.book, transaction));
|
|
63
63
|
}
|
|
64
64
|
return transactions;
|
package/lib/model/User.js
CHANGED
|
@@ -15,16 +15,15 @@ import * as ConnectionService from '../service/connection-service.js';
|
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
export class User {
|
|
18
|
-
constructor(
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
this.wrapped = json || {};
|
|
18
|
+
constructor(payload) {
|
|
19
|
+
this.payload = {};
|
|
20
|
+
this.payload = payload || {};
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
|
-
* @returns
|
|
23
|
+
* @returns An immutable copy of the json payload
|
|
25
24
|
*/
|
|
26
25
|
json() {
|
|
27
|
-
return this.
|
|
26
|
+
return Object.assign({}, this.payload);
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* Gets the id of the User.
|
|
@@ -32,7 +31,7 @@ export class User {
|
|
|
32
31
|
* @returns The User's id
|
|
33
32
|
*/
|
|
34
33
|
getId() {
|
|
35
|
-
return this.
|
|
34
|
+
return this.payload.id;
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
37
|
* Gets the name of the User.
|
|
@@ -40,7 +39,7 @@ export class User {
|
|
|
40
39
|
* @returns The User's name
|
|
41
40
|
*/
|
|
42
41
|
getName() {
|
|
43
|
-
return this.
|
|
42
|
+
return this.payload.name;
|
|
44
43
|
}
|
|
45
44
|
/**
|
|
46
45
|
* Gets the full name of the User.
|
|
@@ -48,7 +47,7 @@ export class User {
|
|
|
48
47
|
* @returns The User's full name
|
|
49
48
|
*/
|
|
50
49
|
getFullName() {
|
|
51
|
-
return this.
|
|
50
|
+
return this.payload.fullName;
|
|
52
51
|
}
|
|
53
52
|
/**
|
|
54
53
|
* Gets the email of the User.
|
|
@@ -56,7 +55,7 @@ export class User {
|
|
|
56
55
|
* @returns The User's email
|
|
57
56
|
*/
|
|
58
57
|
getEmail() {
|
|
59
|
-
return this.
|
|
58
|
+
return this.payload.email;
|
|
60
59
|
}
|
|
61
60
|
/**
|
|
62
61
|
* Gets the hosted domain of the User.
|
|
@@ -64,7 +63,7 @@ export class User {
|
|
|
64
63
|
* @returns The User's hosted domain
|
|
65
64
|
*/
|
|
66
65
|
getHostedDomain() {
|
|
67
|
-
return this.
|
|
66
|
+
return this.payload.hostedDomain;
|
|
68
67
|
}
|
|
69
68
|
/**
|
|
70
69
|
* Tells if the User is in the free plan.
|
|
@@ -72,7 +71,7 @@ export class User {
|
|
|
72
71
|
* @returns True if the User is in the free plan
|
|
73
72
|
*/
|
|
74
73
|
isFree() {
|
|
75
|
-
return this.
|
|
74
|
+
return this.payload.free;
|
|
76
75
|
}
|
|
77
76
|
/**
|
|
78
77
|
* Tells if the User has started the trial.
|
|
@@ -80,7 +79,7 @@ export class User {
|
|
|
80
79
|
* @returns True if the User has started the trial
|
|
81
80
|
*/
|
|
82
81
|
hasStartedTrial() {
|
|
83
|
-
return this.
|
|
82
|
+
return this.payload.startedTrial;
|
|
84
83
|
}
|
|
85
84
|
/**
|
|
86
85
|
* Gets the days left in User's trial.
|
|
@@ -88,7 +87,7 @@ export class User {
|
|
|
88
87
|
* @returns The User's days left in trial
|
|
89
88
|
*/
|
|
90
89
|
getDaysLeftInTrial() {
|
|
91
|
-
return this.
|
|
90
|
+
return this.payload.daysLeftInTrial;
|
|
92
91
|
}
|
|
93
92
|
/**
|
|
94
93
|
* Tells if the User has already used [[Connections]].
|
|
@@ -96,7 +95,7 @@ export class User {
|
|
|
96
95
|
* @returns True if the User has already used Connections
|
|
97
96
|
*/
|
|
98
97
|
hasUsedConnections() {
|
|
99
|
-
return this.
|
|
98
|
+
return this.payload.bankConnections;
|
|
100
99
|
}
|
|
101
100
|
/**
|
|
102
101
|
* Gets the [[Connections]] of the User.
|