vtb-appit 0.0.40 → 0.0.41

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.
@@ -37,6 +37,11 @@ class AppitBaseTransformer {
37
37
  return false;
38
38
  }
39
39
 
40
+ flights()
41
+ {
42
+ return false;
43
+ }
44
+
40
45
  places()
41
46
  {
42
47
  return false;
package/appit.js CHANGED
@@ -34,7 +34,8 @@ class Appit {
34
34
  accommodations: {},
35
35
  schemes: {},
36
36
  labels: {},
37
- destinations: {}
37
+ destinations: {},
38
+ flights: {}
38
39
  };
39
40
 
40
41
  try {
@@ -66,6 +67,7 @@ class Appit {
66
67
  await this.accommodations();
67
68
  await this.schemes();
68
69
  await this.destinations();
70
+ await this.flights();
69
71
 
70
72
  this.history.updatedAt = new Date().getTime();
71
73
 
@@ -122,6 +124,24 @@ class Appit {
122
124
  }
123
125
  }
124
126
 
127
+ async flights()
128
+ {
129
+ const flights = this.transformer.flights();
130
+ if(flights && flights.length) {
131
+ for(let i = 0; i < flights.length; i++) {
132
+ let flight = this.clean(JSON.parse(JSON.stringify(flights[i])));
133
+
134
+ let id = this.findId('flights', flights[i].object_id);
135
+ if(!id) {
136
+ let model = await this.createFlight({...flight, excursion_id: this.history.excursionId});
137
+ this.history.flights[flights[i].object_id] = model.data.id;
138
+ } else {
139
+ await this.updateFlight(id, {...flight, excursion_id: this.history.excursionId});
140
+ }
141
+ }
142
+ }
143
+ }
144
+
125
145
  async organizations()
126
146
  {
127
147
  const organizations = this.transformer.organizations();
@@ -517,6 +537,20 @@ class Appit {
517
537
  }
518
538
  }
519
539
 
540
+ async createFlight(data)
541
+ {
542
+ return await this.request('POST', `flights`, data);
543
+ }
544
+
545
+ async updateFlight(id, data)
546
+ {
547
+ try {
548
+ return await this.request('PUT', `flights/${id}`, data);
549
+ } catch {
550
+ console.log(`updateFlight failed: ${id}`);
551
+ }
552
+ }
553
+
520
554
  async createLabel(workspace_id, data)
521
555
  {
522
556
  return await this.request('POST', `workspaces/${workspace_id}/labels`, data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vtb-appit",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {