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.
@@ -20,30 +20,29 @@ import { Account } from './Account.js';
20
20
  * @public
21
21
  */
22
22
  export class Group {
23
- constructor(book, json) {
23
+ constructor(book, payload) {
24
24
  this.book = book;
25
- this.wrapped = json || {};
25
+ this.payload = payload || {};
26
26
  }
27
27
  /**
28
- *
29
- * @returns The wrapped plain json object
28
+ * @returns An immutable copy of the json payload
30
29
  */
31
30
  json() {
32
- return this.wrapped;
31
+ return Object.assign({}, this.payload);
33
32
  }
34
33
  /**
35
34
  * @returns The id of this Group
36
35
  */
37
36
  getId() {
38
- return this.wrapped.id;
37
+ return this.payload.id;
39
38
  }
40
39
  /**
41
40
  * @returns The parent Group
42
41
  */
43
42
  getParent() {
44
43
  return __awaiter(this, void 0, void 0, function* () {
45
- if (this.wrapped.parent) {
46
- return yield this.book.getGroup(this.wrapped.parent.id);
44
+ if (this.payload.parent) {
45
+ return yield this.book.getGroup(this.payload.parent.id);
47
46
  }
48
47
  else {
49
48
  return undefined;
@@ -57,10 +56,10 @@ export class Group {
57
56
  */
58
57
  setParent(group) {
59
58
  if (group) {
60
- this.wrapped.parent = { id: group.getId(), name: group.getName(), normalizedName: group.getNormalizedName() };
59
+ this.payload.parent = { id: group.getId(), name: group.getName(), normalizedName: group.getNormalizedName() };
61
60
  }
62
61
  else {
63
- this.wrapped.parent = undefined;
62
+ this.payload.parent = undefined;
64
63
  }
65
64
  return this;
66
65
  }
@@ -68,7 +67,7 @@ export class Group {
68
67
  * @returns The name of this Group
69
68
  */
70
69
  getName() {
71
- return this.wrapped.name;
70
+ return this.payload.name;
72
71
  }
73
72
  /**
74
73
  * Sets the name of the Group.
@@ -76,15 +75,15 @@ export class Group {
76
75
  * @returns This Group, for chainning.
77
76
  */
78
77
  setName(name) {
79
- this.wrapped.name = name;
78
+ this.payload.name = name;
80
79
  return this;
81
80
  }
82
81
  /**
83
82
  * @returns The name of this group without spaces and special characters
84
83
  */
85
84
  getNormalizedName() {
86
- if (this.wrapped.normalizedName) {
87
- return this.wrapped.normalizedName;
85
+ if (this.payload.normalizedName) {
86
+ return this.payload.normalizedName;
88
87
  }
89
88
  else {
90
89
  return normalizeText(this.getName());
@@ -107,19 +106,19 @@ export class Group {
107
106
  * @returns True if this group has any account in it
108
107
  */
109
108
  hasAccounts() {
110
- return this.wrapped.hasAccounts;
109
+ return this.payload.hasAccounts;
111
110
  }
112
111
  /**
113
112
  * @returns The type for of the accounts of this group. Null if mixed
114
113
  */
115
114
  getType() {
116
- return this.wrapped.type;
115
+ return this.payload.type;
117
116
  }
118
117
  /**
119
118
  * Gets the custom properties stored in this Group
120
119
  */
121
120
  getProperties() {
122
- return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
121
+ return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
123
122
  }
124
123
  /**
125
124
  * Sets the custom properties of the Group
@@ -129,7 +128,7 @@ export class Group {
129
128
  * @returns This Group, for chainning.
130
129
  */
131
130
  setProperties(properties) {
132
- this.wrapped.properties = Object.assign({}, properties);
131
+ this.payload.properties = Object.assign({}, properties);
133
132
  return this;
134
133
  }
135
134
  /**
@@ -140,7 +139,7 @@ export class Group {
140
139
  getProperty(...keys) {
141
140
  for (let index = 0; index < keys.length; index++) {
142
141
  const key = keys[index];
143
- let value = this.wrapped.properties != null ? this.wrapped.properties[key] : null;
142
+ let value = this.payload.properties != null ? this.payload.properties[key] : null;
144
143
  if (value != null && value.trim() != '') {
145
144
  return value;
146
145
  }
@@ -157,13 +156,13 @@ export class Group {
157
156
  if (key == null || key.trim() == '') {
158
157
  return this;
159
158
  }
160
- if (this.wrapped.properties == null) {
161
- this.wrapped.properties = {};
159
+ if (this.payload.properties == null) {
160
+ this.payload.properties = {};
162
161
  }
163
162
  if (!value) {
164
163
  value = '';
165
164
  }
166
- this.wrapped.properties[key] = value;
165
+ this.payload.properties[key] = value;
167
166
  return this;
168
167
  }
169
168
  /**
@@ -181,13 +180,13 @@ export class Group {
181
180
  * Tell if the Group is hidden on main transactions menu
182
181
  */
183
182
  isHidden() {
184
- return this.wrapped.hidden;
183
+ return this.payload.hidden;
185
184
  }
186
185
  /**
187
186
  * Hide/Show group on main menu.
188
187
  */
189
188
  setHidden(hidden) {
190
- this.wrapped.hidden = hidden;
189
+ this.payload.hidden = hidden;
191
190
  return this;
192
191
  }
193
192
  /**
@@ -195,7 +194,7 @@ export class Group {
195
194
  */
196
195
  create() {
197
196
  return __awaiter(this, void 0, void 0, function* () {
198
- this.wrapped = yield GroupService.createGroup(this.book.getId(), this.wrapped);
197
+ this.payload = yield GroupService.createGroup(this.book.getId(), this.payload);
199
198
  this.book.updateGroupCache(this);
200
199
  return this;
201
200
  });
@@ -205,7 +204,7 @@ export class Group {
205
204
  */
206
205
  update() {
207
206
  return __awaiter(this, void 0, void 0, function* () {
208
- this.wrapped = yield GroupService.updateGroup(this.book.getId(), this.wrapped);
207
+ this.payload = yield GroupService.updateGroup(this.book.getId(), this.payload);
209
208
  this.book.updateGroupCache(this);
210
209
  return this;
211
210
  });
@@ -215,7 +214,7 @@ export class Group {
215
214
  */
216
215
  remove() {
217
216
  return __awaiter(this, void 0, void 0, function* () {
218
- this.wrapped = yield GroupService.deleteGroup(this.book.getId(), this.wrapped);
217
+ this.payload = yield GroupService.deleteGroup(this.book.getId(), this.payload);
219
218
  this.book.removeGroupCache(this);
220
219
  return this;
221
220
  });
@@ -4,16 +4,14 @@
4
4
  * @public
5
5
  */
6
6
  export class Integration {
7
- constructor(json) {
8
- this.wrapped = json || {};
7
+ constructor(payload) {
8
+ this.payload = payload || {};
9
9
  }
10
10
  /**
11
- * Gets the wrapped plain json object of the Integration.
12
- *
13
- * @returns The Integration wrapped plain json object
11
+ * @returns An immutable copy of the json payload
14
12
  */
15
13
  json() {
16
- return this.wrapped;
14
+ return Object.assign({}, this.payload);
17
15
  }
18
16
  /**
19
17
  * Gets the [[Book]] id of the Integration.
@@ -21,7 +19,7 @@ export class Integration {
21
19
  * @returns The Integration's Book id
22
20
  */
23
21
  getBookId() {
24
- return this.wrapped.bookId;
22
+ return this.payload.bookId;
25
23
  }
26
24
  /**
27
25
  * Gets the id of the Integration.
@@ -29,7 +27,7 @@ export class Integration {
29
27
  * @returns This Integration's id
30
28
  */
31
29
  getId() {
32
- return this.wrapped.id;
30
+ return this.payload.id;
33
31
  }
34
32
  /**
35
33
  * Gets the name of the Integration.
@@ -37,7 +35,7 @@ export class Integration {
37
35
  * @returns The Integration's name
38
36
  */
39
37
  getName() {
40
- return this.wrapped.name;
38
+ return this.payload.name;
41
39
  }
42
40
  /**
43
41
  * Gets the custom properties stored in the Integration.
@@ -45,7 +43,7 @@ export class Integration {
45
43
  * @returns Object with key/value pair properties
46
44
  */
47
45
  getProperties() {
48
- return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
46
+ return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
49
47
  }
50
48
  /**
51
49
  * Sets the custom properties of the Integration.
@@ -55,7 +53,7 @@ export class Integration {
55
53
  * @returns The Integration, for chainning
56
54
  */
57
55
  setProperties(properties) {
58
- this.wrapped.properties = Object.assign({}, properties);
56
+ this.payload.properties = Object.assign({}, properties);
59
57
  return this;
60
58
  }
61
59
  /**
@@ -68,7 +66,7 @@ export class Integration {
68
66
  getProperty(...keys) {
69
67
  for (let index = 0; index < keys.length; index++) {
70
68
  const key = keys[index];
71
- let value = this.wrapped.properties != null ? this.wrapped.properties[key] : null;
69
+ let value = this.payload.properties != null ? this.payload.properties[key] : null;
72
70
  if (value != null && value.trim() != '') {
73
71
  return value;
74
72
  }
@@ -87,13 +85,13 @@ export class Integration {
87
85
  if (key == null || key.trim() == '') {
88
86
  return this;
89
87
  }
90
- if (this.wrapped.properties == null) {
91
- this.wrapped.properties = {};
88
+ if (this.payload.properties == null) {
89
+ this.payload.properties = {};
92
90
  }
93
91
  if (!value) {
94
92
  value = '';
95
93
  }
96
- this.wrapped.properties[key] = value;
94
+ this.payload.properties[key] = value;
97
95
  return this;
98
96
  }
99
97
  /**
@@ -7,7 +7,13 @@
7
7
  */
8
8
  export class Template {
9
9
  constructor(json) {
10
- this.wrapped = json || {};
10
+ this.payload = json || {};
11
+ }
12
+ /**
13
+ * @returns An immutable copy of the json payload
14
+ */
15
+ json() {
16
+ return Object.assign({}, this.payload);
11
17
  }
12
18
  /**
13
19
  * Gets the name of the Template.
@@ -15,7 +21,7 @@ export class Template {
15
21
  * @returns The Template's name
16
22
  */
17
23
  getName() {
18
- return this.wrapped.name;
24
+ return this.payload.name;
19
25
  }
20
26
  /**
21
27
  * Gets the description of the Template.
@@ -23,7 +29,7 @@ export class Template {
23
29
  * @returns The Template's description
24
30
  */
25
31
  getDescription() {
26
- return this.wrapped.description;
32
+ return this.payload.description;
27
33
  }
28
34
  /**
29
35
  * Gets the url of the image of the Template.
@@ -31,7 +37,7 @@ export class Template {
31
37
  * @returns The url of the Template's image
32
38
  */
33
39
  getImageUrl() {
34
- return this.wrapped.imageUrl;
40
+ return this.payload.imageUrl;
35
41
  }
36
42
  /**
37
43
  * Gets the category of the Template.
@@ -39,7 +45,7 @@ export class Template {
39
45
  * @returns The Template's category. Example: "PERSONAL", "BUSINESS", etc
40
46
  */
41
47
  getCategory() {
42
- return this.wrapped.category;
48
+ return this.payload.category;
43
49
  }
44
50
  /**
45
51
  * Gets the times the Template has been used.
@@ -47,7 +53,7 @@ export class Template {
47
53
  * @returns The number of times the Template has been used
48
54
  */
49
55
  getTimesUsed() {
50
- return this.wrapped.timesUsed || 0;
56
+ return this.payload.timesUsed || 0;
51
57
  }
52
58
  /**
53
59
  * Gets the bookId of the [[Book]] associated with the Template.
@@ -55,7 +61,7 @@ export class Template {
55
61
  * @returns The bookId of the Book associated with the Template
56
62
  */
57
63
  getBookId() {
58
- return this.wrapped.bookId;
64
+ return this.payload.bookId;
59
65
  }
60
66
  /**
61
67
  * Gets the link of the [[Book]] associated with the Template.
@@ -63,7 +69,7 @@ export class Template {
63
69
  * @returns The link of the Book associated with the Template
64
70
  */
65
71
  getBookLink() {
66
- return this.wrapped.bookLink;
72
+ return this.payload.bookLink;
67
73
  }
68
74
  /**
69
75
  * Gets the link of the Google Sheets spreadsheet associated with the Template.
@@ -71,15 +77,7 @@ export class Template {
71
77
  * @returns The link of the Google Sheets spreadsheet associated with the Template
72
78
  */
73
79
  getSheetsLink() {
74
- return this.wrapped.sheetsLink;
75
- }
76
- /**
77
- * Gets the wrapped plain json object of the Template.
78
- *
79
- * @returns The Template wrapped plain json object
80
- */
81
- json() {
82
- return this.wrapped;
80
+ return this.payload.sheetsLink;
83
81
  }
84
82
  }
85
83
  //# sourceMappingURL=Template.js.map