vtb-appit 0.0.55 → 0.0.57

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.
@@ -139,7 +139,7 @@ class AppitBaseTransformer {
139
139
  }
140
140
  }
141
141
  }
142
- console.log(result);
142
+
143
143
  return result;
144
144
  }
145
145
 
package/appit.js CHANGED
@@ -28,6 +28,7 @@ class Appit {
28
28
  this.history = {
29
29
  excursionId: null,
30
30
  members: {},
31
+ contacts: {},
31
32
  organizations: {},
32
33
  travels: {},
33
34
  places: {},
@@ -72,6 +73,7 @@ class Appit {
72
73
  await this.destinations();
73
74
  await this.flights();
74
75
  await this.flightImages();
76
+ await this.contacts();
75
77
  await this.homescreen();
76
78
  await this.settings();
77
79
 
@@ -290,7 +292,7 @@ class Appit {
290
292
 
291
293
  async destinations()
292
294
  {
293
- const destinations = this.transformer.destinations();
295
+ const destinations = await this.transformer.destinations();
294
296
  if(destinations && destinations.length) {
295
297
  for(let i = 0; i < destinations.length; i++) {
296
298
  let destination = this.clean(JSON.parse(JSON.stringify(destinations[i])));
@@ -329,6 +331,24 @@ class Appit {
329
331
  }
330
332
  }
331
333
 
334
+ async contacts()
335
+ {
336
+ const contacts = this.transformer.contacts();
337
+ if(contacts && contacts.length) {
338
+ for(let i = 0; i < contacts.length; i++) {
339
+ let contact = this.clean(JSON.parse(JSON.stringify(contacts[i])));
340
+
341
+ let id = this.findId('contacts', contacts[i].object_id);
342
+ if(!id) {
343
+ let model = await this.createContact({...contact, excursion_id: this.history.excursionId});
344
+ this.history.contacts[contacts[i].object_id] = model.data.id;
345
+ } else {
346
+ await this.updateContact(id, {...contact, excursion_id: this.history.excursionId});
347
+ }
348
+ }
349
+ }
350
+ }
351
+
332
352
  getLabels(object)
333
353
  {
334
354
  if(object.label && this.history.labels && this.history.labels.hasOwnProperty(object.label)) {
@@ -612,6 +632,20 @@ class Appit {
612
632
  }
613
633
  }
614
634
 
635
+ async createContact(data)
636
+ {
637
+ return await this.request('POST', `contacts`, data);
638
+ }
639
+
640
+ async updateContact(id, data)
641
+ {
642
+ try {
643
+ return await this.request('PUT', `contacts/${id}`, data);
644
+ } catch {
645
+ console.log(`updateContact failed: ${id}`);
646
+ }
647
+ }
648
+
615
649
  async createAccommodation(data)
616
650
  {
617
651
  return await this.request('POST', `accommodations`, data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vtb-appit",
3
- "version": "0.0.55",
3
+ "version": "0.0.57",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {