vtb-appit 0.0.62 → 0.0.64

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.
@@ -43,6 +43,11 @@ class AppitBaseTransformer {
43
43
  return false;
44
44
  }
45
45
 
46
+ documents()
47
+ {
48
+ return false;
49
+ }
50
+
46
51
  flightImages()
47
52
  {
48
53
  return false;
package/appit.js CHANGED
@@ -34,6 +34,7 @@ class Appit {
34
34
  places: {},
35
35
  accommodations: {},
36
36
  schemes: {},
37
+ documents: {},
37
38
  labels: {},
38
39
  destinations: {},
39
40
  flights: {},
@@ -75,6 +76,7 @@ class Appit {
75
76
  await this.flights();
76
77
  await this.flightImages();
77
78
  await this.contacts();
79
+ await this.documents();
78
80
  await this.homescreen();
79
81
  await this.settings();
80
82
  await this.notifications();
@@ -334,6 +336,23 @@ class Appit {
334
336
 
335
337
  this.history.travels = travelInfoHistory;
336
338
  }
339
+
340
+ async documents()
341
+ {
342
+ const documents = this.transformer.documents();
343
+ if(documents) {
344
+ for(let i = 0; i < documents.length; i++) {
345
+ documents[i].excursion_id = this.history.excursionId;
346
+ let id = this.findId('documents', documents[i].object_id);
347
+ if(!id) {
348
+ let model = await this.createDocument(documents[i]);
349
+ this.history.documents[documents[i].object_id] = model.data.id;
350
+ } else {
351
+ await this.updateDocument(id, documents[i]);
352
+ }
353
+ }
354
+ }
355
+ }
337
356
 
338
357
  async accommodations()
339
358
  {
@@ -856,6 +875,20 @@ class Appit {
856
875
  }
857
876
  }
858
877
 
878
+ async createDocument(data)
879
+ {
880
+ return await this.request('POST', `documents`, data);
881
+ }
882
+
883
+ async updateDocument(id, data)
884
+ {
885
+ try {
886
+ return await this.request('PUT', `documents/${id}`, data);
887
+ } catch {
888
+ console.log(`updateDocument failed: ${id}`);
889
+ }
890
+ }
891
+
859
892
  async deletePlace(id)
860
893
  {
861
894
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vtb-appit",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {