vtb-appit 0.0.17 → 0.0.20

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.
@@ -19,6 +19,11 @@ class AppitBaseTransformer {
19
19
  return false;
20
20
  }
21
21
 
22
+ destinations()
23
+ {
24
+ return false;
25
+ }
26
+
22
27
  excursion()
23
28
  {
24
29
  return false;
@@ -70,6 +75,21 @@ class AppitBaseTransformer {
70
75
  .toLowerCase();
71
76
  }
72
77
 
78
+ extraField(name)
79
+ {
80
+ let value = '';
81
+
82
+ this.travelplan.extraFieldValues.forEach(extraFieldValue => {
83
+ extraFieldValue.fields.forEach(object => {
84
+ if(object.name === name) {
85
+ value = object.value;
86
+ }
87
+ });
88
+ });
89
+
90
+ return value;
91
+ }
92
+
73
93
  elementExtraField(element, name)
74
94
  {
75
95
  if(!element || !element.TSOrderline || !element.TSOrderline.extraFieldValues || !element.TSOrderline.extraFieldValues.length) return false;
package/appit.js CHANGED
@@ -32,7 +32,8 @@ class Appit {
32
32
  places: {},
33
33
  accommodations: {},
34
34
  schemes: {},
35
- labels: {}
35
+ labels: {},
36
+ destination: {}
36
37
  };
37
38
 
38
39
  try {
@@ -55,6 +56,7 @@ class Appit {
55
56
  await this.travelInfo();
56
57
  await this.accommodations();
57
58
  await this.schemes();
59
+ await this.destinations();
58
60
 
59
61
  this.history.updatedAt = new Date().getTime();
60
62
 
@@ -188,6 +190,25 @@ class Appit {
188
190
  }
189
191
  }
190
192
 
193
+ async destinations()
194
+ {
195
+ const destinations = this.transformer.destinations();
196
+ if(destinations && destinations.length) {
197
+ for(let i = 0; i < destinations.length; i++) {
198
+ let destination = this.clean(JSON.parse(JSON.stringify(destinations[i])));
199
+ let labels = this.getLabels(destinations[i]);
200
+
201
+ let id = this.findId('destinations', destinations[i].object_id);
202
+ if(!id) {
203
+ let model = await this.createDestination({...destination, labels: labels, excursion_id: this.history.excursionId});
204
+ this.history.destination[destinations[i].object_id] = model.data.id;
205
+ } else {
206
+ await this.updateDestination(id, {...destination, labels: labels, excursion_id: this.history.excursionId});
207
+ }
208
+ }
209
+ }
210
+ }
211
+
191
212
  async schemes()
192
213
  {
193
214
  const schemes = this.transformer.schemes();
@@ -415,6 +436,16 @@ class Appit {
415
436
  return true;
416
437
  }
417
438
 
439
+ async createDestination(data)
440
+ {
441
+ return await this.request('POST', `destinations`, data);
442
+ }
443
+
444
+ async updateDestination(id, data)
445
+ {
446
+ return await this.request('PUT', `destinations/${id}`, data);
447
+ }
448
+
418
449
  async createOrganization(data)
419
450
  {
420
451
  return await this.request('POST', `organizations`, data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vtb-appit",
3
- "version": "0.0.17",
3
+ "version": "0.0.20",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {