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/index.d.ts
CHANGED
|
@@ -17,12 +17,11 @@
|
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
19
|
export declare class Account {
|
|
20
|
+
payload: bkper.Account;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
constructor(book: Book, json?: bkper.Account);
|
|
22
|
+
constructor(book: Book, payload?: bkper.Account);
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @returns The wrapped plain json object
|
|
24
|
+
* @returns An immutable copy of the json payload
|
|
26
25
|
*/
|
|
27
26
|
json(): bkper.Account;
|
|
28
27
|
/**
|
|
@@ -314,8 +313,12 @@ export declare class Amount {
|
|
|
314
313
|
* @public
|
|
315
314
|
*/
|
|
316
315
|
export declare class App {
|
|
317
|
-
|
|
318
|
-
constructor(
|
|
316
|
+
payload: bkper.App;
|
|
317
|
+
constructor(payload?: bkper.App);
|
|
318
|
+
/**
|
|
319
|
+
* @returns The wrapped plain json object
|
|
320
|
+
*/
|
|
321
|
+
json(): bkper.App;
|
|
319
322
|
/**
|
|
320
323
|
*
|
|
321
324
|
* Sets the webhook url for development.
|
|
@@ -366,10 +369,6 @@ export declare class App {
|
|
|
366
369
|
* Perform update App, applying pending changes.
|
|
367
370
|
*/
|
|
368
371
|
update(): Promise<App>;
|
|
369
|
-
/**
|
|
370
|
-
* @returns The wrapped plain json object
|
|
371
|
-
*/
|
|
372
|
-
json(): bkper.App;
|
|
373
372
|
}
|
|
374
373
|
|
|
375
374
|
/**
|
|
@@ -470,13 +469,13 @@ export declare class Bkper {
|
|
|
470
469
|
* @public
|
|
471
470
|
*/
|
|
472
471
|
export declare class Book {
|
|
472
|
+
payload: bkper.Book;
|
|
473
473
|
|
|
474
474
|
|
|
475
475
|
|
|
476
|
-
|
|
477
|
-
constructor(json?: bkper.Book);
|
|
476
|
+
constructor(payload?: bkper.Book);
|
|
478
477
|
/**
|
|
479
|
-
* @returns
|
|
478
|
+
* @returns An immutable copy of the json payload
|
|
480
479
|
*/
|
|
481
480
|
json(): bkper.Book;
|
|
482
481
|
/**
|
|
@@ -730,56 +729,6 @@ export declare class Book {
|
|
|
730
729
|
* @returns The updated Integration object
|
|
731
730
|
*/
|
|
732
731
|
updateIntegration(integration: bkper.Integration): Promise<Integration>;
|
|
733
|
-
/**
|
|
734
|
-
* Instantiate a new [[Transaction]]
|
|
735
|
-
*
|
|
736
|
-
* Example:
|
|
737
|
-
*
|
|
738
|
-
* ```js
|
|
739
|
-
* var book = Bkper.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
|
|
740
|
-
*
|
|
741
|
-
* book.newTransaction()
|
|
742
|
-
* .setDate('2013-01-25')
|
|
743
|
-
* .setDescription("Filling tank of my truck")
|
|
744
|
-
* .from('Credit Card')
|
|
745
|
-
* .to('Gas')
|
|
746
|
-
* .setAmount(126.50)
|
|
747
|
-
* .create();
|
|
748
|
-
*
|
|
749
|
-
* ```
|
|
750
|
-
*
|
|
751
|
-
*/
|
|
752
|
-
newTransaction(): Transaction;
|
|
753
|
-
/**
|
|
754
|
-
* Instantiate a new [[Account]]
|
|
755
|
-
*
|
|
756
|
-
* Example:
|
|
757
|
-
* ```js
|
|
758
|
-
* var book = Bkper.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
|
|
759
|
-
*
|
|
760
|
-
* book.newAccount()
|
|
761
|
-
* .setName('Some New Account')
|
|
762
|
-
* .setType('INCOMING')
|
|
763
|
-
* .addGroup('Revenue').addGroup('Salary')
|
|
764
|
-
* .setProperties({prop_a: 'A', prop_b: 'B'})
|
|
765
|
-
* .create();
|
|
766
|
-
* ```
|
|
767
|
-
*/
|
|
768
|
-
newAccount(): Account;
|
|
769
|
-
/**
|
|
770
|
-
* Instantiate a new [[Group]]
|
|
771
|
-
*
|
|
772
|
-
* Example:
|
|
773
|
-
* ```js
|
|
774
|
-
* var book = Bkper.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
|
|
775
|
-
*
|
|
776
|
-
* book.newGroup()
|
|
777
|
-
* .setName('Some New Group')
|
|
778
|
-
* .setProperty('key', 'value')
|
|
779
|
-
* .create();
|
|
780
|
-
* ```
|
|
781
|
-
*/
|
|
782
|
-
newGroup(): Group;
|
|
783
732
|
/**
|
|
784
733
|
* Gets an [[Account]] object
|
|
785
734
|
*
|
|
@@ -821,19 +770,6 @@ export declare class Book {
|
|
|
821
770
|
* Retrieve a transaction by id
|
|
822
771
|
*/
|
|
823
772
|
getTransaction(id: string): Promise<Transaction | undefined>;
|
|
824
|
-
/**
|
|
825
|
-
* Instantiate a new [[BkperFile]]
|
|
826
|
-
*
|
|
827
|
-
* Example:
|
|
828
|
-
* ```js
|
|
829
|
-
* var book = Bkper.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
|
|
830
|
-
*
|
|
831
|
-
* book.newFile()
|
|
832
|
-
* .setBlob(UrlFetchApp.fetch('https://bkper.com/images/index/integrations4.png').getBlob())
|
|
833
|
-
* .create();
|
|
834
|
-
* ```
|
|
835
|
-
*/
|
|
836
|
-
newFile(): File;
|
|
837
773
|
/**
|
|
838
774
|
* Retrieve a file by id
|
|
839
775
|
*/
|
|
@@ -856,8 +792,12 @@ export declare class Book {
|
|
|
856
792
|
* @public
|
|
857
793
|
*/
|
|
858
794
|
export declare class Collection {
|
|
859
|
-
|
|
860
|
-
|
|
795
|
+
payload: bkper.Collection;
|
|
796
|
+
constructor(payload?: bkper.Collection);
|
|
797
|
+
/**
|
|
798
|
+
* @returns The wrapped plain json object
|
|
799
|
+
*/
|
|
800
|
+
json(): bkper.Collection;
|
|
861
801
|
/**
|
|
862
802
|
* @returns The id of this Collection
|
|
863
803
|
*/
|
|
@@ -870,10 +810,6 @@ export declare class Collection {
|
|
|
870
810
|
* @returns All Books of this collection.
|
|
871
811
|
*/
|
|
872
812
|
getBooks(): Book[];
|
|
873
|
-
/**
|
|
874
|
-
* @returns The wrapped plain json object
|
|
875
|
-
*/
|
|
876
|
-
json(): bkper.Collection;
|
|
877
813
|
}
|
|
878
814
|
|
|
879
815
|
/**
|
|
@@ -927,12 +863,10 @@ export declare interface Config {
|
|
|
927
863
|
* @public
|
|
928
864
|
*/
|
|
929
865
|
export declare class Connection {
|
|
930
|
-
|
|
931
|
-
constructor(
|
|
866
|
+
payload: bkper.Connection;
|
|
867
|
+
constructor(payload?: bkper.Connection);
|
|
932
868
|
/**
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
* @returns The Connection wrapped plain json object
|
|
869
|
+
* @returns An immutable copy of the json payload
|
|
936
870
|
*/
|
|
937
871
|
json(): bkper.Connection;
|
|
938
872
|
/**
|
|
@@ -1095,14 +1029,13 @@ export declare enum DecimalSeparator {
|
|
|
1095
1029
|
* @public
|
|
1096
1030
|
*/
|
|
1097
1031
|
export declare class File {
|
|
1032
|
+
payload: bkper.File;
|
|
1098
1033
|
|
|
1099
|
-
|
|
1100
|
-
constructor(book: Book, json?: bkper.File);
|
|
1034
|
+
constructor(book: Book, payload?: bkper.File);
|
|
1101
1035
|
/**
|
|
1102
|
-
*
|
|
1103
|
-
* @returns The wrapped plain json object
|
|
1036
|
+
* @returns An immutable copy of the json payload
|
|
1104
1037
|
*/
|
|
1105
|
-
json(): bkper.
|
|
1038
|
+
json(): bkper.File;
|
|
1106
1039
|
/**
|
|
1107
1040
|
* Gets the File id
|
|
1108
1041
|
*/
|
|
@@ -1164,13 +1097,12 @@ export declare class File {
|
|
|
1164
1097
|
* @public
|
|
1165
1098
|
*/
|
|
1166
1099
|
export declare class Group {
|
|
1100
|
+
payload: bkper.Group;
|
|
1167
1101
|
|
|
1168
1102
|
|
|
1169
|
-
|
|
1170
|
-
constructor(book: Book, json?: bkper.Group);
|
|
1103
|
+
constructor(book: Book, payload?: bkper.Group);
|
|
1171
1104
|
/**
|
|
1172
|
-
*
|
|
1173
|
-
* @returns The wrapped plain json object
|
|
1105
|
+
* @returns An immutable copy of the json payload
|
|
1174
1106
|
*/
|
|
1175
1107
|
json(): bkper.Group;
|
|
1176
1108
|
/**
|
|
@@ -1278,12 +1210,10 @@ export declare class Group {
|
|
|
1278
1210
|
* @public
|
|
1279
1211
|
*/
|
|
1280
1212
|
export declare class Integration {
|
|
1281
|
-
|
|
1282
|
-
constructor(
|
|
1213
|
+
payload: bkper.Integration;
|
|
1214
|
+
constructor(payload?: bkper.Integration);
|
|
1283
1215
|
/**
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1286
|
-
* @returns The Integration wrapped plain json object
|
|
1216
|
+
* @returns An immutable copy of the json payload
|
|
1287
1217
|
*/
|
|
1288
1218
|
json(): bkper.Integration;
|
|
1289
1219
|
/**
|
|
@@ -1451,8 +1381,12 @@ export declare enum Permission {
|
|
|
1451
1381
|
* @public
|
|
1452
1382
|
*/
|
|
1453
1383
|
export declare class Template {
|
|
1454
|
-
|
|
1384
|
+
payload: bkper.Template;
|
|
1455
1385
|
constructor(json?: bkper.Template);
|
|
1386
|
+
/**
|
|
1387
|
+
* @returns An immutable copy of the json payload
|
|
1388
|
+
*/
|
|
1389
|
+
json(): bkper.Template;
|
|
1456
1390
|
/**
|
|
1457
1391
|
* Gets the name of the Template.
|
|
1458
1392
|
*
|
|
@@ -1501,12 +1435,6 @@ export declare class Template {
|
|
|
1501
1435
|
* @returns The link of the Google Sheets spreadsheet associated with the Template
|
|
1502
1436
|
*/
|
|
1503
1437
|
getSheetsLink(): string | undefined;
|
|
1504
|
-
/**
|
|
1505
|
-
* Gets the wrapped plain json object of the Template.
|
|
1506
|
-
*
|
|
1507
|
-
* @returns The Template wrapped plain json object
|
|
1508
|
-
*/
|
|
1509
|
-
json(): bkper.Template;
|
|
1510
1438
|
}
|
|
1511
1439
|
|
|
1512
1440
|
/**
|
|
@@ -1518,12 +1446,11 @@ export declare class Template {
|
|
|
1518
1446
|
* @public
|
|
1519
1447
|
*/
|
|
1520
1448
|
export declare class Transaction {
|
|
1449
|
+
payload: bkper.Transaction;
|
|
1521
1450
|
|
|
1522
|
-
|
|
1523
|
-
constructor(book: Book, json?: bkper.Transaction);
|
|
1451
|
+
constructor(book: Book, payload?: bkper.Transaction);
|
|
1524
1452
|
/**
|
|
1525
|
-
*
|
|
1526
|
-
* @returns The wrapped plain json object
|
|
1453
|
+
* @returns An immutable copy of the json payload
|
|
1527
1454
|
*/
|
|
1528
1455
|
json(): bkper.Transaction;
|
|
1529
1456
|
/**
|
|
@@ -1850,9 +1777,9 @@ export declare class Transaction {
|
|
|
1850
1777
|
* A list associated with a transaction query.
|
|
1851
1778
|
*/
|
|
1852
1779
|
export declare class TransactionPage {
|
|
1853
|
-
private
|
|
1854
|
-
|
|
1855
|
-
constructor(book: Book,
|
|
1780
|
+
private payload;
|
|
1781
|
+
|
|
1782
|
+
constructor(book: Book, payload: bkper.TransactionList);
|
|
1856
1783
|
/**
|
|
1857
1784
|
* @returns The cursor associated with the query for pagination.
|
|
1858
1785
|
*/
|
|
@@ -1886,10 +1813,10 @@ export declare class TransactionPage {
|
|
|
1886
1813
|
* @public
|
|
1887
1814
|
*/
|
|
1888
1815
|
export declare class User {
|
|
1889
|
-
|
|
1890
|
-
constructor(
|
|
1816
|
+
payload: bkper.User;
|
|
1817
|
+
constructor(payload?: bkper.User);
|
|
1891
1818
|
/**
|
|
1892
|
-
* @returns
|
|
1819
|
+
* @returns An immutable copy of the json payload
|
|
1893
1820
|
*/
|
|
1894
1821
|
json(): bkper.User;
|
|
1895
1822
|
/**
|
package/lib/model/Account.js
CHANGED
|
@@ -23,28 +23,29 @@ import { Amount } from './Amount.js';
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
export class Account {
|
|
26
|
-
constructor(book,
|
|
26
|
+
constructor(book, payload) {
|
|
27
27
|
this.book = book;
|
|
28
|
-
this.
|
|
28
|
+
this.payload = payload || {
|
|
29
|
+
createdAt: `${Date.now()}`
|
|
30
|
+
};
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @returns The wrapped plain json object
|
|
33
|
+
* @returns An immutable copy of the json payload
|
|
33
34
|
*/
|
|
34
35
|
json() {
|
|
35
|
-
return this.
|
|
36
|
+
return Object.assign({}, this.payload);
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* Gets the account internal id.
|
|
39
40
|
*/
|
|
40
41
|
getId() {
|
|
41
|
-
return this.
|
|
42
|
+
return this.payload.id;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* Gets the account name.
|
|
45
46
|
*/
|
|
46
47
|
getName() {
|
|
47
|
-
return this.
|
|
48
|
+
return this.payload.name;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
*
|
|
@@ -53,15 +54,15 @@ export class Account {
|
|
|
53
54
|
* @returns This Account, for chainning.
|
|
54
55
|
*/
|
|
55
56
|
setName(name) {
|
|
56
|
-
this.
|
|
57
|
+
this.payload.name = name;
|
|
57
58
|
return this;
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* @returns The name of this account without spaces or special characters.
|
|
61
62
|
*/
|
|
62
63
|
getNormalizedName() {
|
|
63
|
-
if (this.
|
|
64
|
-
return this.
|
|
64
|
+
if (this.payload.normalizedName) {
|
|
65
|
+
return this.payload.normalizedName;
|
|
65
66
|
}
|
|
66
67
|
else {
|
|
67
68
|
return normalizeText(this.getName());
|
|
@@ -71,7 +72,7 @@ export class Account {
|
|
|
71
72
|
* @returns The type for of this account.
|
|
72
73
|
*/
|
|
73
74
|
getType() {
|
|
74
|
-
return this.
|
|
75
|
+
return this.payload.type;
|
|
75
76
|
}
|
|
76
77
|
/**
|
|
77
78
|
*
|
|
@@ -80,14 +81,14 @@ export class Account {
|
|
|
80
81
|
* @returns This Account, for chainning
|
|
81
82
|
*/
|
|
82
83
|
setType(type) {
|
|
83
|
-
this.
|
|
84
|
+
this.payload.type = type;
|
|
84
85
|
return this;
|
|
85
86
|
}
|
|
86
87
|
/**
|
|
87
88
|
* Gets the custom properties stored in this Account.
|
|
88
89
|
*/
|
|
89
90
|
getProperties() {
|
|
90
|
-
return this.
|
|
91
|
+
return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
93
94
|
* Sets the custom properties of the Account
|
|
@@ -97,7 +98,7 @@ export class Account {
|
|
|
97
98
|
* @returns This Account, for chainning.
|
|
98
99
|
*/
|
|
99
100
|
setProperties(properties) {
|
|
100
|
-
this.
|
|
101
|
+
this.payload.properties = Object.assign({}, properties);
|
|
101
102
|
return this;
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
@@ -108,7 +109,7 @@ export class Account {
|
|
|
108
109
|
getProperty(...keys) {
|
|
109
110
|
for (let index = 0; index < keys.length; index++) {
|
|
110
111
|
const key = keys[index];
|
|
111
|
-
let value = this.
|
|
112
|
+
let value = this.payload.properties != null ? this.payload.properties[key] : null;
|
|
112
113
|
if (value != null && value.trim() != '') {
|
|
113
114
|
return value;
|
|
114
115
|
}
|
|
@@ -127,13 +128,13 @@ export class Account {
|
|
|
127
128
|
if (key == null || key.trim() == '') {
|
|
128
129
|
return this;
|
|
129
130
|
}
|
|
130
|
-
if (this.
|
|
131
|
-
this.
|
|
131
|
+
if (this.payload.properties == null) {
|
|
132
|
+
this.payload.properties = {};
|
|
132
133
|
}
|
|
133
134
|
if (!value) {
|
|
134
135
|
value = '';
|
|
135
136
|
}
|
|
136
|
-
this.
|
|
137
|
+
this.payload.properties[key] = value;
|
|
137
138
|
return this;
|
|
138
139
|
}
|
|
139
140
|
/**
|
|
@@ -154,8 +155,8 @@ export class Account {
|
|
|
154
155
|
*/
|
|
155
156
|
getBalance() {
|
|
156
157
|
var balance = new Amount('0');
|
|
157
|
-
if (this.
|
|
158
|
-
balance = round(this.
|
|
158
|
+
if (this.payload.balance != null) {
|
|
159
|
+
balance = round(this.payload.balance, this.book.getFractionDigits());
|
|
159
160
|
}
|
|
160
161
|
return balance;
|
|
161
162
|
}
|
|
@@ -166,8 +167,8 @@ export class Account {
|
|
|
166
167
|
*/
|
|
167
168
|
getBalanceRaw() {
|
|
168
169
|
var balance = new Amount('0');
|
|
169
|
-
if (this.
|
|
170
|
-
balance = round(this.
|
|
170
|
+
if (this.payload.balance != null) {
|
|
171
|
+
balance = round(this.payload.balance, this.book.getFractionDigits());
|
|
171
172
|
}
|
|
172
173
|
return balance;
|
|
173
174
|
}
|
|
@@ -175,7 +176,7 @@ export class Account {
|
|
|
175
176
|
* Tell if this account is archived.
|
|
176
177
|
*/
|
|
177
178
|
isArchived() {
|
|
178
|
-
return this.
|
|
179
|
+
return this.payload.archived;
|
|
179
180
|
}
|
|
180
181
|
/**
|
|
181
182
|
* Set account archived/unarchived.
|
|
@@ -183,7 +184,7 @@ export class Account {
|
|
|
183
184
|
* @returns This Account, for chainning.
|
|
184
185
|
*/
|
|
185
186
|
setArchived(archived) {
|
|
186
|
-
this.
|
|
187
|
+
this.payload.archived = archived;
|
|
187
188
|
return this;
|
|
188
189
|
}
|
|
189
190
|
/**
|
|
@@ -192,7 +193,7 @@ export class Account {
|
|
|
192
193
|
* Accounts with transaction posted, even with zero balance, can only be archived.
|
|
193
194
|
*/
|
|
194
195
|
hasTransactionPosted() {
|
|
195
|
-
return this.
|
|
196
|
+
return this.payload.hasTransactionPosted;
|
|
196
197
|
}
|
|
197
198
|
/**
|
|
198
199
|
*
|
|
@@ -207,7 +208,7 @@ export class Account {
|
|
|
207
208
|
* @returns True if its a permanent Account
|
|
208
209
|
*/
|
|
209
210
|
isPermanent() {
|
|
210
|
-
return this.
|
|
211
|
+
return this.payload.permanent;
|
|
211
212
|
}
|
|
212
213
|
/**
|
|
213
214
|
* Tell if the account has a Credit nature or Debit otherwise
|
|
@@ -230,7 +231,7 @@ export class Account {
|
|
|
230
231
|
* As a rule of thumb, and for simple understanding, almost all accounts are Debit nature (NOT credit), except the ones that "offers" amount for the books, like revenue accounts.
|
|
231
232
|
*/
|
|
232
233
|
isCredit() {
|
|
233
|
-
return this.
|
|
234
|
+
return this.payload.credit;
|
|
234
235
|
}
|
|
235
236
|
/**
|
|
236
237
|
* Get the [[Groups]] of this account.
|
|
@@ -252,7 +253,7 @@ export class Account {
|
|
|
252
253
|
* @returns This Account, for chainning.
|
|
253
254
|
*/
|
|
254
255
|
setGroups(groups) {
|
|
255
|
-
this.
|
|
256
|
+
this.payload.groups = undefined;
|
|
256
257
|
if (groups != null) {
|
|
257
258
|
groups.forEach(group => this.addGroup(group));
|
|
258
259
|
}
|
|
@@ -264,14 +265,14 @@ export class Account {
|
|
|
264
265
|
* @returns This Account, for chainning.
|
|
265
266
|
*/
|
|
266
267
|
addGroup(group) {
|
|
267
|
-
if (!this.
|
|
268
|
-
this.
|
|
268
|
+
if (!this.payload.groups) {
|
|
269
|
+
this.payload.groups = [];
|
|
269
270
|
}
|
|
270
271
|
if (group instanceof Group) {
|
|
271
|
-
this.
|
|
272
|
+
this.payload.groups.push(group.json());
|
|
272
273
|
}
|
|
273
274
|
else {
|
|
274
|
-
this.
|
|
275
|
+
this.payload.groups.push(group);
|
|
275
276
|
}
|
|
276
277
|
return this;
|
|
277
278
|
}
|
|
@@ -280,7 +281,7 @@ export class Account {
|
|
|
280
281
|
*/
|
|
281
282
|
removeGroup(group) {
|
|
282
283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
-
if (this.
|
|
284
|
+
if (this.payload.groups != null) {
|
|
284
285
|
let groupObject = undefined;
|
|
285
286
|
if (group instanceof Group) {
|
|
286
287
|
groupObject = group;
|
|
@@ -289,10 +290,10 @@ export class Account {
|
|
|
289
290
|
groupObject = yield this.book.getGroup(group);
|
|
290
291
|
}
|
|
291
292
|
if (groupObject) {
|
|
292
|
-
for (let i = 0; i < this.
|
|
293
|
-
const groupId = this.
|
|
293
|
+
for (let i = 0; i < this.payload.groups.length; i++) {
|
|
294
|
+
const groupId = this.payload.groups[i];
|
|
294
295
|
if (groupId == groupObject.getId()) {
|
|
295
|
-
this.
|
|
296
|
+
this.payload.groups.splice(i, 1);
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
}
|
|
@@ -324,11 +325,11 @@ export class Account {
|
|
|
324
325
|
}
|
|
325
326
|
/** @internal */
|
|
326
327
|
isInGroupObject_(group) {
|
|
327
|
-
if (this.
|
|
328
|
+
if (this.payload.groups == null) {
|
|
328
329
|
return false;
|
|
329
330
|
}
|
|
330
|
-
for (var i = 0; i < this.
|
|
331
|
-
if (this.
|
|
331
|
+
for (var i = 0; i < this.payload.groups.length; i++) {
|
|
332
|
+
if (this.payload.groups[i] == group.getId()) {
|
|
332
333
|
return true;
|
|
333
334
|
}
|
|
334
335
|
}
|
|
@@ -339,7 +340,8 @@ export class Account {
|
|
|
339
340
|
*/
|
|
340
341
|
create() {
|
|
341
342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
342
|
-
this.
|
|
343
|
+
this.payload = yield AccountService.createAccount(this.book.getId(), this.payload);
|
|
344
|
+
this.book.updateAccountCache(this);
|
|
343
345
|
return this;
|
|
344
346
|
});
|
|
345
347
|
}
|
|
@@ -348,7 +350,8 @@ export class Account {
|
|
|
348
350
|
*/
|
|
349
351
|
update() {
|
|
350
352
|
return __awaiter(this, void 0, void 0, function* () {
|
|
351
|
-
this.
|
|
353
|
+
this.payload = yield AccountService.updateAccount(this.book.getId(), this.payload);
|
|
354
|
+
this.book.updateAccountCache(this);
|
|
352
355
|
return this;
|
|
353
356
|
});
|
|
354
357
|
}
|
|
@@ -357,7 +360,8 @@ export class Account {
|
|
|
357
360
|
*/
|
|
358
361
|
remove() {
|
|
359
362
|
return __awaiter(this, void 0, void 0, function* () {
|
|
360
|
-
this.
|
|
363
|
+
this.payload = yield AccountService.deleteAccount(this.book.getId(), this.payload);
|
|
364
|
+
this.book.removeAccountCache(this);
|
|
361
365
|
return this;
|
|
362
366
|
});
|
|
363
367
|
}
|