fshub-api 3.0.1 → 4.0.0

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.
Files changed (143) hide show
  1. package/dist/api/FSHubApiRequest.d.ts +2 -2
  2. package/dist/api/FSHubApiRequest.d.ts.map +1 -1
  3. package/dist/api/FSHubApiRequest.js +16 -11
  4. package/dist/api/FSHubApiRequest.js.map +1 -1
  5. package/dist/api/airline/Airline_get.d.ts +2 -2
  6. package/dist/api/airline/Airline_get.d.ts.map +1 -1
  7. package/dist/api/airline/Airline_get.js +1 -1
  8. package/dist/api/airline/Airline_get.js.map +1 -1
  9. package/dist/api/airline/Airline_getAll.d.ts +2 -2
  10. package/dist/api/airline/Airline_getAll.d.ts.map +1 -1
  11. package/dist/api/airline/Airline_getAll.js +1 -1
  12. package/dist/api/airline/Airline_getAll.js.map +1 -1
  13. package/dist/api/airline/Airline_getAllFlightDeparturesAndArrivals.d.ts +2 -2
  14. package/dist/api/airline/Airline_getAllFlightDeparturesAndArrivals.d.ts.map +1 -1
  15. package/dist/api/airline/Airline_getAllFlightDeparturesAndArrivals.js +1 -1
  16. package/dist/api/airline/Airline_getAllFlightDeparturesAndArrivals.js.map +1 -1
  17. package/dist/api/airline/Airline_getAllFlightsArrivals.d.ts +2 -2
  18. package/dist/api/airline/Airline_getAllFlightsArrivals.d.ts.map +1 -1
  19. package/dist/api/airline/Airline_getAllFlightsArrivals.js +1 -1
  20. package/dist/api/airline/Airline_getAllFlightsArrivals.js.map +1 -1
  21. package/dist/api/airline/Airline_getAllFlightsDepartures.d.ts +2 -2
  22. package/dist/api/airline/Airline_getAllFlightsDepartures.d.ts.map +1 -1
  23. package/dist/api/airline/Airline_getAllFlightsDepartures.js +1 -1
  24. package/dist/api/airline/Airline_getAllFlightsDepartures.js.map +1 -1
  25. package/dist/api/airline/Airline_getAllScreenshots.d.ts +2 -2
  26. package/dist/api/airline/Airline_getAllScreenshots.d.ts.map +1 -1
  27. package/dist/api/airline/Airline_getAllScreenshots.js +2 -2
  28. package/dist/api/airline/Airline_getAllScreenshots.js.map +1 -1
  29. package/dist/api/airline/Airline_getFlights.d.ts +2 -2
  30. package/dist/api/airline/Airline_getFlights.d.ts.map +1 -1
  31. package/dist/api/airline/Airline_getFlights.js +1 -1
  32. package/dist/api/airline/Airline_getFlights.js.map +1 -1
  33. package/dist/api/airline/Airline_getPilotStats.d.ts +2 -2
  34. package/dist/api/airline/Airline_getPilotStats.d.ts.map +1 -1
  35. package/dist/api/airline/Airline_getPilotStats.js +1 -1
  36. package/dist/api/airline/Airline_getPilotStats.js.map +1 -1
  37. package/dist/api/airline/Airline_getPilots.d.ts +2 -2
  38. package/dist/api/airline/Airline_getPilots.d.ts.map +1 -1
  39. package/dist/api/airline/Airline_getPilots.js +1 -1
  40. package/dist/api/airline/Airline_getPilots.js.map +1 -1
  41. package/dist/api/airline/Airline_getStats.d.ts +2 -2
  42. package/dist/api/airline/Airline_getStats.d.ts.map +1 -1
  43. package/dist/api/airline/Airline_getStats.js +1 -1
  44. package/dist/api/airline/Airline_getStats.js.map +1 -1
  45. package/dist/api/flight/Flight_getFlightById.d.ts +2 -2
  46. package/dist/api/flight/Flight_getFlightById.d.ts.map +1 -1
  47. package/dist/api/flight/Flight_getFlightById.js +1 -1
  48. package/dist/api/flight/Flight_getFlightById.js.map +1 -1
  49. package/dist/api/flight/Flight_getFlightScreenshotsById.d.ts +2 -2
  50. package/dist/api/flight/Flight_getFlightScreenshotsById.d.ts.map +1 -1
  51. package/dist/api/flight/Flight_getFlightScreenshotsById.js +2 -2
  52. package/dist/api/flight/Flight_getFlightScreenshotsById.js.map +1 -1
  53. package/dist/api/flight/Flight_getFlights.d.ts +3 -0
  54. package/dist/api/flight/Flight_getFlights.d.ts.map +1 -0
  55. package/dist/api/flight/Flight_getFlights.js +57 -0
  56. package/dist/api/flight/Flight_getFlights.js.map +1 -0
  57. package/dist/api/flight/index.d.ts +2 -0
  58. package/dist/api/flight/index.d.ts.map +1 -1
  59. package/dist/api/flight/index.js +2 -0
  60. package/dist/api/flight/index.js.map +1 -1
  61. package/dist/api/index.d.ts +1 -0
  62. package/dist/api/index.d.ts.map +1 -1
  63. package/dist/api/pilot/Pilot_get.d.ts +2 -2
  64. package/dist/api/pilot/Pilot_get.d.ts.map +1 -1
  65. package/dist/api/pilot/Pilot_get.js +1 -1
  66. package/dist/api/pilot/Pilot_get.js.map +1 -1
  67. package/dist/api/pilot/Pilot_getAll.d.ts +2 -2
  68. package/dist/api/pilot/Pilot_getAll.d.ts.map +1 -1
  69. package/dist/api/pilot/Pilot_getAll.js +1 -1
  70. package/dist/api/pilot/Pilot_getAll.js.map +1 -1
  71. package/dist/api/pilot/Pilot_getAllAirlines.d.ts +2 -2
  72. package/dist/api/pilot/Pilot_getAllAirlines.d.ts.map +1 -1
  73. package/dist/api/pilot/Pilot_getAllAirlines.js +1 -1
  74. package/dist/api/pilot/Pilot_getAllAirlines.js.map +1 -1
  75. package/dist/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.d.ts +2 -2
  76. package/dist/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.d.ts.map +1 -1
  77. package/dist/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.js +1 -1
  78. package/dist/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.js.map +1 -1
  79. package/dist/api/pilot/Pilot_getAllFlights.d.ts +2 -2
  80. package/dist/api/pilot/Pilot_getAllFlights.d.ts.map +1 -1
  81. package/dist/api/pilot/Pilot_getAllFlights.js +1 -1
  82. package/dist/api/pilot/Pilot_getAllFlights.js.map +1 -1
  83. package/dist/api/pilot/Pilot_getAllFlightsArrivals.d.ts +2 -2
  84. package/dist/api/pilot/Pilot_getAllFlightsArrivals.d.ts.map +1 -1
  85. package/dist/api/pilot/Pilot_getAllFlightsArrivals.js +1 -1
  86. package/dist/api/pilot/Pilot_getAllFlightsArrivals.js.map +1 -1
  87. package/dist/api/pilot/Pilot_getAllFlightsDepartures.d.ts +2 -2
  88. package/dist/api/pilot/Pilot_getAllFlightsDepartures.d.ts.map +1 -1
  89. package/dist/api/pilot/Pilot_getAllFlightsDepartures.js +1 -1
  90. package/dist/api/pilot/Pilot_getAllFlightsDepartures.js.map +1 -1
  91. package/dist/api/pilot/Pilot_getAllScreenshots.d.ts +2 -2
  92. package/dist/api/pilot/Pilot_getAllScreenshots.d.ts.map +1 -1
  93. package/dist/api/pilot/Pilot_getAllScreenshots.js +2 -2
  94. package/dist/api/pilot/Pilot_getAllScreenshots.js.map +1 -1
  95. package/dist/api/pilot/Pilot_getCurrent.d.ts +2 -2
  96. package/dist/api/pilot/Pilot_getCurrent.d.ts.map +1 -1
  97. package/dist/api/pilot/Pilot_getCurrent.js +1 -1
  98. package/dist/api/pilot/Pilot_getCurrent.js.map +1 -1
  99. package/dist/api/pilot/Pilot_getLatestFlight.d.ts +2 -2
  100. package/dist/api/pilot/Pilot_getLatestFlight.d.ts.map +1 -1
  101. package/dist/api/pilot/Pilot_getLatestFlight.js +1 -1
  102. package/dist/api/pilot/Pilot_getLatestFlight.js.map +1 -1
  103. package/dist/api/pilot/Pilot_getStats.d.ts +2 -2
  104. package/dist/api/pilot/Pilot_getStats.d.ts.map +1 -1
  105. package/dist/api/pilot/Pilot_getStats.js +1 -1
  106. package/dist/api/pilot/Pilot_getStats.js.map +1 -1
  107. package/dist/index.d.ts +25 -24
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/index.js +23 -0
  110. package/dist/index.js.map +1 -1
  111. package/dist/types/index.d.ts +47 -34
  112. package/dist/types/index.d.ts.map +1 -1
  113. package/package.json +2 -2
  114. package/release.ps1 +15 -0
  115. package/src/api/FSHubApiRequest.ts +8 -3
  116. package/src/api/airline/Airline_get.ts +2 -2
  117. package/src/api/airline/Airline_getAll.ts +2 -2
  118. package/src/api/airline/Airline_getAllFlightDeparturesAndArrivals.ts +2 -2
  119. package/src/api/airline/Airline_getAllFlightsArrivals.ts +2 -2
  120. package/src/api/airline/Airline_getAllFlightsDepartures.ts +2 -2
  121. package/src/api/airline/Airline_getAllScreenshots.ts +3 -3
  122. package/src/api/airline/Airline_getFlights.ts +2 -2
  123. package/src/api/airline/Airline_getPilotStats.ts +2 -2
  124. package/src/api/airline/Airline_getPilots.ts +2 -2
  125. package/src/api/airline/Airline_getStats.ts +2 -2
  126. package/src/api/flight/Flight_getFlightById.ts +2 -2
  127. package/src/api/flight/Flight_getFlightScreenshotsById.ts +3 -3
  128. package/src/api/flight/Flight_getFlights.ts +9 -0
  129. package/src/api/flight/index.ts +2 -0
  130. package/src/api/pilot/Pilot_get.ts +2 -2
  131. package/src/api/pilot/Pilot_getAll.ts +2 -2
  132. package/src/api/pilot/Pilot_getAllAirlines.ts +2 -2
  133. package/src/api/pilot/Pilot_getAllFlightDeparturesAndArrivals.ts +2 -2
  134. package/src/api/pilot/Pilot_getAllFlights.ts +2 -2
  135. package/src/api/pilot/Pilot_getAllFlightsArrivals.ts +2 -2
  136. package/src/api/pilot/Pilot_getAllFlightsDepartures.ts +2 -2
  137. package/src/api/pilot/Pilot_getAllScreenshots.ts +3 -3
  138. package/src/api/pilot/Pilot_getCurrent.ts +2 -2
  139. package/src/api/pilot/Pilot_getLatestFlight.ts +2 -2
  140. package/src/api/pilot/Pilot_getStats.ts +2 -2
  141. package/src/index.spec.ts +111 -77
  142. package/src/index.ts +20 -1
  143. package/src/types/index.ts +50 -36
package/src/index.spec.ts CHANGED
@@ -2,7 +2,7 @@ import { describe, before } from 'mocha';
2
2
  import { expect } from 'chai';
3
3
  import FSHubApiClass from './index';
4
4
  import dotenv from 'dotenv';
5
- import { CurrentPilot, Flight, Pilot, FSHubApi, Airline, PilotStats, Screenshot } from './types';
5
+ import { CurrentPilot, Flight, Pilot, FSHubApi, Airline, PilotStats, Screenshot, FSHubResponse, AirlineStats } from './types';
6
6
 
7
7
  dotenv.config();
8
8
  let api: FSHubApi;
@@ -43,174 +43,208 @@ describe('FSHubApi()', function() {
43
43
  expect(api.Airline_getStats).to.be.a('function');
44
44
  expect(api.Flight_getFlightById).to.be.a('function');
45
45
  expect(api.Flight_getFlightScreenshotsById).to.be.a('function');
46
+ expect(api.Flight_getFlights).to.be.a('function');
46
47
  });
47
48
 
48
49
  describe('Pilot', function() {
49
50
  it('Pilot_getCurrent() is called, it should return a valid CurrentPilot object', async function() {
50
- const pilot: CurrentPilot = await api.Pilot_getCurrent();
51
+ const pilot: FSHubResponse<CurrentPilot> = await api.Pilot_getCurrent();
51
52
 
52
- expect(pilot).to.be.an('Object');
53
- expect(pilot.id).to.be.a('number');
54
- expect(pilot.name).to.be.a('string');
55
- expect(pilot.base).to.be.a('string');
56
- expect(pilot.locale).to.be.an('string');
57
- expect(pilot.gps).to.be.an('Object');
53
+ expect(pilot.data).to.be.an('Object');
54
+ expect(pilot.data.id).to.be.a('number');
55
+ expect(pilot.data.name).to.be.a('string');
56
+ expect(pilot.data.base).to.be.a('string');
57
+ expect(pilot.data.locale).to.be.an('string');
58
+ expect(pilot.data.gps).to.be.an('Object');
58
59
  });
59
60
 
60
61
  it('Pilot_getAll() is called, it should return an array of valid Pilot objects', async function() {
61
- const pilots: Pilot[] = await api.Pilot_getAll();
62
+ const pilots: FSHubResponse<Pilot[]> = await api.Pilot_getAll();
62
63
 
63
- expect(pilots).to.be.an('Array');
64
+ expect(pilots.data).to.be.an('Array');
64
65
  });
65
66
 
66
67
  it('Pilot_get(id) is called, it should return a valid Pilot object', async function() {
67
- const pilot: Pilot = await api.Pilot_get(1);
68
+ const pilot: FSHubResponse<Pilot> = await api.Pilot_get(1);
68
69
 
69
- expect(pilot).to.be.an('Object');
70
+ expect(pilot.data).to.be.an('Object');
71
+ expect(pilot.data).to.be.an('Object');
72
+ expect(pilot.data.id).to.be.a('number');
73
+ expect(pilot.data.name).to.be.a('string');
74
+ expect(pilot.data.base).to.be.a('string');
75
+ expect(pilot.data.locale).to.be.an('string');
76
+ expect(pilot.data.gps).to.be.an('Object');
70
77
  });
71
78
 
72
79
  it('Pilot_getLatestFlight(id) is called, it should return a valid Flight object', async function() {
73
- const pilot: Pilot = await api.Pilot_getCurrent();
74
- const flight: Flight = await api.Pilot_getLatestFlight(pilot.id);
80
+ const pilot: FSHubResponse<CurrentPilot> = await api.Pilot_getCurrent();
81
+ const flight: FSHubResponse<Flight> = await api.Pilot_getLatestFlight(pilot.data.id);
75
82
 
76
83
  expect(flight).to.be.an('Object');
77
84
  });
78
85
 
79
86
  it('Pilot_getAllFlights(id) is called, it should return an array of valid Flight objects', async function() {
80
- const pilot: Pilot = await api.Pilot_getCurrent();
81
- const flights: Flight[] = await api.Pilot_getAllFlights(pilot.id);
87
+ const pilot: FSHubResponse<CurrentPilot> = await api.Pilot_getCurrent();
88
+ const flights: FSHubResponse<Flight[]> = await api.Pilot_getAllFlights(pilot.data.id);
82
89
 
83
- expect(flights).to.be.an('Array');
90
+ expect(flights.data).to.be.an('Array');
84
91
  });
85
92
 
86
93
  it('Pilot_getAllAirlines(id) is called, it should return an array of valid Airline objects', async function() {
87
- const pilot: Pilot = await api.Pilot_getCurrent();
88
- const airlines: Airline[] = await api.Pilot_getAllAirlines(pilot.id);
94
+ const pilot: FSHubResponse<CurrentPilot> = await api.Pilot_getCurrent();
95
+ const airlines: FSHubResponse<Airline[]> = await api.Pilot_getAllAirlines(pilot.data.id);
89
96
 
90
- expect(airlines).to.be.an('Array');
97
+ expect(airlines.data).to.be.an('Array');
91
98
  });
92
99
 
93
100
  it('Pilot_getStats(id) is called, it should return a valid PilotStats object', async function() {
94
- const pilot: Pilot = await api.Pilot_getCurrent();
95
- const stats: PilotStats = await api.Pilot_getStats(pilot.id);
101
+ const pilot: FSHubResponse<CurrentPilot> = await api.Pilot_getCurrent();
102
+ const stats: FSHubResponse<PilotStats> = await api.Pilot_getStats(pilot.data.id);
96
103
 
97
- expect(stats).to.be.an('Object');
98
- expect(stats.id).to.be.a('number');
99
- expect(stats.all_time).to.be.an('Object');
100
- expect(stats.month).to.be.an('Object');
104
+ expect(stats.data).to.be.an('Object');
105
+ expect(stats.data.id).to.be.a('number');
106
+ expect(stats.data.all_time).to.be.an('Object');
107
+ expect(stats.data.month).to.be.an('Object');
101
108
  });
102
109
 
103
110
  it('Pilot_getAllFlightsDepartures(id, airportCode) is called, it should return an array of valid Flight objects', async function() {
104
- const pilot: Pilot = await api.Pilot_getCurrent();
105
- const flights: Flight[] = await api.Pilot_getAllFlightsDepartures(pilot.id, 'KPHX');
111
+ const pilot: FSHubResponse<CurrentPilot> = await api.Pilot_getCurrent();
112
+ const flights: FSHubResponse<Flight[]> = await api.Pilot_getAllFlightsDepartures(pilot.data.id, 'KPHX');
106
113
 
107
- expect(flights).to.be.an('Array');
114
+ expect(flights.data).to.be.an('Array');
108
115
  });
109
116
 
110
117
  it('Pilot_getAllFlightsArrivals(id, airportCode) is called, it should return an array of valid Flight objects', async function() {
111
- const pilot: Pilot = await api.Pilot_getCurrent();
112
- const flights: Flight[] = await api.Pilot_getAllFlightsArrivals(pilot.id, 'KPHX');
118
+ const pilot: FSHubResponse<CurrentPilot> = await api.Pilot_getCurrent();
119
+ const flights: FSHubResponse<Flight[]> = await api.Pilot_getAllFlightsArrivals(pilot.data.id, 'KPHX');
113
120
 
114
- expect(flights).to.be.an('Array');
121
+ expect(flights.data).to.be.an('Array');
115
122
  });
116
123
 
117
124
  it('Pilot_getAllFlightDeparturesAndArrivals(id, departureAirportCode, arrivalAirportCode) is called, it should return an array of valid Flight objects', async function() {
118
- const pilot: Pilot = await api.Pilot_getCurrent();
119
- const flights: Flight[] = await api.Pilot_getAllFlightDeparturesAndArrivals(pilot.id, 'KPHX', 'KJAC');
125
+ const pilot: FSHubResponse<CurrentPilot> = await api.Pilot_getCurrent();
126
+ const flights: FSHubResponse<Flight[]> = await api.Pilot_getAllFlightDeparturesAndArrivals(pilot.data.id, 'KPHX', 'KJAC');
120
127
 
121
- expect(flights).to.be.an('Array');
128
+ expect(flights.data).to.be.an('Array');
122
129
  });
123
130
 
124
131
  it('Pilot_getAllScreenshots(id) is called, it should return an array of valid Screenshot objects', async function() {
125
- const pilot: Pilot = await api.Pilot_getCurrent();
126
- const screenshots: Screenshot[] = await api.Pilot_getAllScreenshots(pilot.id);
132
+ const pilot: FSHubResponse<CurrentPilot> = await api.Pilot_getCurrent();
133
+ const screenshots: FSHubResponse<Screenshot[]> = await api.Pilot_getAllScreenshots(pilot.data.id);
127
134
 
128
- expect(screenshots).to.be.an('Array');
135
+ expect(screenshots.data).to.be.an('Array');
129
136
  });
130
137
  });
131
138
 
132
139
  describe('Airline', function() {
133
140
  it('Airline_getAll() is called, it should return an array of valid Airline objects', async function() {
134
- const airlines: Airline[] = await api.Airline_getAll();
141
+ const airlines: FSHubResponse<Airline[]> = await api.Airline_getAll();
135
142
 
136
- expect(airlines).to.be.an('Array');
143
+ expect(airlines.data).to.be.an('Array');
137
144
  });
138
145
 
139
146
  it('Airline_get(id) is called, it should return a valid Airline object', async function() {
140
- const airline: Airline = await api.Airline_get(6082);
147
+ const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
141
148
 
142
- expect(airline).to.be.an('Object');
149
+ expect(airline.data).to.be.an('Object');
143
150
  });
144
151
 
145
152
  it('Airline_getPilots(id) is called, it should return an array of valid Pilot objects', async function() {
146
- const airline: Airline = await api.Airline_get(6082);
147
- const pilots: Pilot[] = await api.Airline_getPilots(airline.id);
153
+ const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
154
+ const pilots: FSHubResponse<Pilot[]> = await api.Airline_getPilots(airline.data.id);
148
155
 
149
- expect(pilots).to.be.an('Array');
156
+ expect(pilots.data).to.be.an('Array');
150
157
  });
151
158
 
152
159
  it('Airline_getPilotStats(id, pilotId) is called, it should return a valid PilotStats object', async function() {
153
- const airline: Airline = await api.Airline_get(6082);
154
- const pilot: Pilot = await api.Pilot_getCurrent();
155
- const stats: PilotStats = await api.Airline_getPilotStats(airline.id, pilot.id);
160
+ const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
161
+ const pilot: FSHubResponse<Pilot> = await api.Pilot_getCurrent();
162
+ const stats: FSHubResponse<PilotStats> = await api.Airline_getPilotStats(airline.data.id, pilot.data.id);
156
163
 
157
- expect(stats).to.be.an('Object');
164
+ expect(stats.data).to.be.an('Object');
158
165
  });
159
166
 
160
167
  it('Airline_getFlights(id) is called, it should return an array of valid Flight objects', async function() {
161
- const airline: Airline = await api.Airline_get(6082);
162
- const flights: Flight[] = await api.Airline_getFlights(airline.id);
168
+ const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
169
+ const flights: FSHubResponse<Flight[]> = await api.Airline_getFlights(airline.data.id);
163
170
 
164
- expect(flights).to.be.an('Array');
171
+ expect(flights.data).to.be.an('Array');
165
172
  });
166
173
 
167
174
  it('Airline_getAllFlightsDepartures(id, airportCode) is called, it should return an array of valid Flight objects', async function() {
168
- const airline: Airline = await api.Airline_get(6082);
169
- const flights: Flight[] = await api.Airline_getAllFlightsDepartures(airline.id, 'KPHX');
175
+ const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
176
+ const flights: FSHubResponse<Flight[]> = await api.Airline_getAllFlightsDepartures(airline.data.id, 'KPHX');
170
177
 
171
- expect(flights).to.be.an('Array');
178
+ expect(flights.data).to.be.an('Array');
172
179
  });
173
180
 
174
181
  it('Airline_getAllFlightsArrivals(id, airportCode) is called, it should return an array of valid Flight objects', async function() {
175
- const airline: Airline = await api.Airline_get(6082);
176
- const flights: Flight[] = await api.Airline_getAllFlightsArrivals(airline.id, 'KPHX');
182
+ const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
183
+ const flights: FSHubResponse<Flight[]> = await api.Airline_getAllFlightsArrivals(airline.data.id, 'KPHX');
177
184
 
178
- expect(flights).to.be.an('Array');
185
+ expect(flights.data).to.be.an('Array');
179
186
  });
180
187
 
181
188
  it('Airline_getAllFlightDeparturesAndArrivals(id, departureAirportCode, arrivalAirportCode) is called, it should return an array of valid Flight objects', async function() {
182
- const airline: Airline = await api.Airline_get(6082);
183
- const flights: Flight[] = await api.Airline_getAllFlightDeparturesAndArrivals(airline.id, 'KPHX', 'KJAC');
189
+ const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
190
+ const flights: FSHubResponse<Flight[]> = await api.Airline_getAllFlightDeparturesAndArrivals(airline.data.id, 'KPHX', 'KJAC');
184
191
 
185
- expect(flights).to.be.an('Array');
192
+ expect(flights.data).to.be.an('Array');
186
193
  });
187
194
 
188
195
  it('Airline_getAllScreenshots(id) is called, it should return an array of valid Screenshot objects', async function() {
189
- const airline: Airline = await api.Airline_get(6082);
190
- const screenshots: Screenshot[] = await api.Airline_getAllScreenshots(airline.id);
196
+ const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
197
+ const screenshots: FSHubResponse<Screenshot[]> = await api.Airline_getAllScreenshots(airline.data.id);
191
198
 
192
- expect(screenshots).to.be.an('Array');
199
+ expect(screenshots.data).to.be.an('Array');
193
200
  });
194
201
 
195
202
  it('Airline_getStats(id) is called, it should return a valid object with airline statistics', async function() {
196
- const airline: Airline = await api.Airline_get(6082);
197
- const stats = await api.Airline_getStats(airline.id);
203
+ const airline: FSHubResponse<Airline> = await api.Airline_get(6082);
204
+ const stats: FSHubResponse<AirlineStats> = await api.Airline_getStats(airline.data.id);
198
205
 
199
- expect(stats).to.be.an('Object');
206
+ expect(stats.data).to.be.an('Object');
200
207
  });
201
208
  });
202
209
 
203
210
  describe('Flight', function() {
204
- it('Flight_getFlightById(id) is called, it should return a valid Flight object', async function() {
205
- const flight: Flight = await api.Flight_getFlightById(4009359);
206
-
207
- expect(flight).to.be.an('Object');
208
- });
209
-
210
- it('Flight_getFlightScreenshotsById(id) is called, it should return an array of valid Screenshot objects', async function() {
211
- const flight: Screenshot[] = await api.Flight_getFlightScreenshotsById(4009359);
212
-
213
- expect(flight).to.be.an('Array');
211
+ describe('Flight_getFlightById(id)', function() {
212
+ it('Flight_getFlightById(id) is called, it should return a valid Flight object', async function() {
213
+ const flight: FSHubResponse<Flight> = await api.Flight_getFlightById(4009359);
214
+
215
+ expect(flight.data).to.be.an('Object');
216
+ });
217
+ });
218
+
219
+ describe('Flight_getFlightScreenshotsById(id)', function() {
220
+ it('Flight_getFlightScreenshotsById(id) is called, it should return an array of valid Screenshot objects', async function() {
221
+ const flight: FSHubResponse<Screenshot[]> = await api.Flight_getFlightScreenshotsById(4009359);
222
+
223
+ expect(flight.data).to.be.an('Array');
224
+ });
225
+ });
226
+
227
+ describe('Flight_getFlights(options)', function() {
228
+ it('Flight_getFlights(options) is called, it should return an array of valid Flight objects', async function() {
229
+ const flights: FSHubResponse<Flight[]> = await api.Flight_getFlights();
230
+
231
+ expect(flights.data).to.be.an('Array');
232
+ expect(flights.data.length).to.be.equal(10);
233
+ });
234
+
235
+ it('Flight_getFlights(options) is called with limit option, it should limit the number of flights returned', async function() {
236
+ const flights: FSHubResponse<Flight[]> = await api.Flight_getFlights({ limit: 1 });
237
+
238
+ expect(flights.data).to.be.an('Array');
239
+ expect(flights.data.length).to.be.equal(1);
240
+ });
241
+
242
+ it('Flight_getFlights(options) is called with cursor option, it should return the next page of flights', async function() {
243
+ const flights: FSHubResponse<Flight[]> = await api.Flight_getFlights({ cursor: 100 });
244
+
245
+ expect(flights.data).to.be.an('Array');
246
+ expect(flights.data.length).to.be.equal(100);
247
+ });
214
248
  });
215
249
  });
216
250
  });
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import axios, { AxiosInstance } from 'axios';
2
- import type{ Config, FSHubApi } from './types';
2
+ import type{ Config, FSHubApi, FSHubRequestOptions } from './types';
3
3
  import { Api } from './api';
4
4
  export * from './types';
5
5
 
@@ -35,6 +35,21 @@ export default class FSHubApiClass implements FSHubApi {
35
35
  this.Pilot_getAllFlightsArrivals = this.Pilot_getAllFlightsArrivals.bind(this);
36
36
  this.Pilot_getAllFlightDeparturesAndArrivals = this.Pilot_getAllFlightDeparturesAndArrivals.bind(this);
37
37
  this.Pilot_getAllScreenshots = this.Pilot_getAllScreenshots.bind(this);
38
+
39
+ this.Airline_getAll = this.Airline_getAll.bind(this);
40
+ this.Airline_get = this.Airline_get.bind(this);
41
+ this.Airline_getPilots = this.Airline_getPilots.bind(this);
42
+ this.Airline_getPilotStats = this.Airline_getPilotStats.bind(this);
43
+ this.Airline_getFlights = this.Airline_getFlights.bind(this);
44
+ this.Airline_getAllFlightsDepartures = this.Airline_getAllFlightsDepartures.bind(this);
45
+ this.Airline_getAllFlightsArrivals = this.Airline_getAllFlightsArrivals.bind(this);
46
+ this.Airline_getAllFlightDeparturesAndArrivals = this.Airline_getAllFlightDeparturesAndArrivals.bind(this);
47
+ this.Airline_getAllScreenshots = this.Airline_getAllScreenshots.bind(this);
48
+ this.Airline_getStats = this.Airline_getStats.bind(this);
49
+
50
+ this.Flight_getFlightById = this.Flight_getFlightById.bind(this);
51
+ this.Flight_getFlightScreenshotsById = this.Flight_getFlightScreenshotsById.bind(this);
52
+ this.Flight_getFlights = this.Flight_getFlights.bind(this);
38
53
  }
39
54
 
40
55
  public async Pilot_getCurrent() {
@@ -128,4 +143,8 @@ export default class FSHubApiClass implements FSHubApi {
128
143
  public async Flight_getFlightScreenshotsById(id: number) {
129
144
  return await Api.flight.getFlightScreenshotsById(id, this);
130
145
  }
146
+
147
+ public async Flight_getFlights(options?: FSHubRequestOptions) {
148
+ return await Api.flight.getFlights(this, options);
149
+ }
131
150
  }
@@ -49,19 +49,6 @@ export type Gps = {
49
49
  lng: number
50
50
  }
51
51
 
52
- export type FSHubResponse<T> = {
53
- data: T
54
- }
55
-
56
- export type FSHubError = {
57
- message: string
58
- code: number
59
- error?: boolean
60
- details?: {
61
- pilot: number
62
- }
63
- }
64
-
65
52
  export type Flight = {
66
53
  id: number
67
54
  user: User
@@ -209,29 +196,56 @@ export type Urls = {
209
196
  thumbnail: string
210
197
  }
211
198
 
199
+ export type FSHubRequestOptions = {
200
+ cursor?: number;
201
+ limit?: number;
202
+ }
203
+
212
204
  export type FSHubApi = {
213
205
  axios: AxiosInstance
214
- Pilot_getCurrent: () => Promise<CurrentPilot>
215
- Pilot_getAll: () => Promise<Pilot[]>
216
- Pilot_get: (id: number) => Promise<Pilot>
217
- Pilot_getLatestFlight: (id: number) => Promise<Flight>
218
- Pilot_getAllFlights: (id: number) => Promise<Flight[]>
219
- Pilot_getAllAirlines: (id: number) => Promise<Airline[]>
220
- Pilot_getStats: (id: number) => Promise<PilotStats>
221
- Pilot_getAllFlightsDepartures:(id:number, airportCode:string) => Promise<Flight[]>
222
- Pilot_getAllFlightsArrivals:(id:number, airportCode:string) => Promise<Flight[]>
223
- Pilot_getAllFlightDeparturesAndArrivals:(id:number, departureAirportCode:string, arrivalAirportCode:string) => Promise<Flight[]>
224
- Pilot_getAllScreenshots: (id: number) => Promise<Screenshot[]>
225
- Airline_getAll: () => Promise<Airline[]>
226
- Airline_get: (id: number) => Promise<Airline>
227
- Airline_getPilots: (id: number) => Promise<Pilot[]>
228
- Airline_getPilotStats: (id: number, pilotId: number) => Promise<PilotStats>
229
- Airline_getFlights: (id: number) => Promise<Flight[]>
230
- Airline_getAllFlightsDepartures:(id:number, airportCode:string) => Promise<Flight[]>
231
- Airline_getAllFlightsArrivals:(id:number, airportCode:string) => Promise<Flight[]>
232
- Airline_getAllFlightDeparturesAndArrivals:(id:number, departureAirportCode:string, arrivalAirportCode:string) => Promise<Flight[]>
233
- Airline_getAllScreenshots: (id: number) => Promise<Screenshot[]>
234
- Airline_getStats: (id: number) => Promise<AirlineStats>
235
- Flight_getFlightById: (id: number) => Promise<Flight>
236
- Flight_getFlightScreenshotsById: (id: number) => Promise<Screenshot[]>
206
+ Pilot_getCurrent: () => Promise<FSHubResponse<CurrentPilot>>
207
+ Pilot_getAll: () => Promise<FSHubResponse<Pilot[]>>
208
+ Pilot_get: (id: number) => Promise<FSHubResponse<Pilot>>
209
+ Pilot_getLatestFlight: (id: number) => Promise<FSHubResponse<Flight>>
210
+ Pilot_getAllFlights: (id: number) => Promise<FSHubResponse<Flight[]>>
211
+ Pilot_getAllAirlines: (id: number) => Promise<FSHubResponse<Airline[]>>
212
+ Pilot_getStats: (id: number) => Promise<FSHubResponse<PilotStats>>
213
+ Pilot_getAllFlightsDepartures:(id:number, airportCode:string) => Promise<FSHubResponse<Flight[]>>
214
+ Pilot_getAllFlightsArrivals:(id:number, airportCode:string) => Promise<FSHubResponse<Flight[]>>
215
+ Pilot_getAllFlightDeparturesAndArrivals:(id:number, departureAirportCode:string, arrivalAirportCode:string) => Promise<FSHubResponse<Flight[]>>
216
+ Pilot_getAllScreenshots: (id: number) => Promise<FSHubResponse<Screenshot[]>>
217
+ Airline_getAll: () => Promise<FSHubResponse<Airline[]>>
218
+ Airline_get: (id: number) => Promise<FSHubResponse<Airline>>
219
+ Airline_getPilots: (id: number) => Promise<FSHubResponse<Pilot[]>>
220
+ Airline_getPilotStats: (id: number, pilotId: number) => Promise<FSHubResponse<PilotStats>>
221
+ Airline_getFlights: (id: number) => Promise<FSHubResponse<Flight[]>>
222
+ Airline_getAllFlightsDepartures:(id:number, airportCode:string) => Promise<FSHubResponse<Flight[]>>
223
+ Airline_getAllFlightsArrivals:(id:number, airportCode:string) => Promise<FSHubResponse<Flight[]>>
224
+ Airline_getAllFlightDeparturesAndArrivals:(id:number, departureAirportCode:string, arrivalAirportCode:string) => Promise<FSHubResponse<Flight[]>>
225
+ Airline_getAllScreenshots: (id: number) => Promise<FSHubResponse<Screenshot[]>>
226
+ Airline_getStats: (id: number) => Promise<FSHubResponse<AirlineStats>>
227
+ Flight_getFlightById: (id: number) => Promise<FSHubResponse<Flight>>
228
+ Flight_getFlightScreenshotsById: (id: number) => Promise<FSHubResponse<Screenshot[]>>
229
+ Flight_getFlights: (options?: FSHubRequestOptions) => Promise<FSHubResponse<Flight[]>>
230
+ }
231
+
232
+ export type FSHubResponse<T> = {
233
+ data: T
234
+ meta?: {
235
+ cursor: {
236
+ current: number
237
+ prev: number
238
+ next: number
239
+ count: number
240
+ }
241
+ }
242
+ }
243
+
244
+ export type FSHubError = {
245
+ message: string
246
+ code: number
247
+ error?: boolean
248
+ details?: {
249
+ pilot: number
250
+ }
237
251
  }