| 1 | // |
| 2 | // AUTO-GENERATED FILE, DO NOT MODIFY! |
| 3 | // |
| 4 | |
| 5 | import 'dart:async'; |
| 6 | |
| 7 | import 'package:built_value/json_object.dart'; |
| 8 | import 'package:built_value/serializer.dart'; |
| 9 | import 'package:dio/dio.dart'; |
| 10 | |
| 11 | import 'package:openapi/src/api_util.dart'; |
| 12 | import 'package:openapi/src/model/flight_response_entity.dart'; |
| 13 | import 'package:openapi/src/model/flight_track_response_entity.dart'; |
| 14 | import 'package:openapi/src/model/generic_error_entity.dart'; |
| 15 | |
| 16 | class FlightApi { |
| 17 | |
| 18 | final Dio _dio; |
| 19 | |
| 20 | final Serializers _serializers; |
| 21 | |
| 22 | const FlightApi(this |
| 23 | |
| 24 | /// Get flight track/path |
| 25 | /// Get the flight path with all position data points for a specific flight |
| 26 | /// |
| 27 | /// Parameters: |
| 28 | /// * [iata] - IATA flight number |
| 29 | /// * [icao] - ICAO flight number |
| 30 | /// * [timezone] - The timezone from which the request is being made. |
| 31 | /// * [date] - Flight date (ISO format). Defaults to current date if not provided |
| 32 | /// * [cancelToken] - A [CancelToken] |
| 33 | /// * [headers] - Can be used to add additional headers to the request |
| 34 | /// * [extras] - Can be used to add flags to the request |
| 35 | /// * [validateStatus] - A [ValidateStatus] |
| 36 | /// * [onSendProgress] - A [ProgressCallback] |
| 37 | /// * [onReceiveProgress] - A [ProgressCallback] |
| 38 | /// |
| 39 | /// Returns a [Future] containing a [Response] |
| 40 | /// Throws [DioException] if API call or serialization fails |
| 41 | Future<Response<FlightTrackResponseEntity |
| 42 | required String iata, |
| 43 | required String icao, |
| 44 | required String timezone, |
| 45 | String? date, |
| 46 | CancelToken? cancelToken, |
| 47 | Map<String, dynamic |
| 48 | Map<String, dynamic |
| 49 | ValidateStatus? validateStatus, |
| 50 | ProgressCallback? onSendProgress, |
| 51 | ProgressCallback? onReceiveProgress, |
| 52 | }) async { |
| 53 | final _path = r'/v1/flight/track'; |
| 54 | final _options = Options( |
| 55 | method: r'GET', |
| 56 | headers: <String, dynamic |
| 57 | ...?headers, |
| 58 | }, |
| 59 | extra: <String, dynamic |
| 60 | 'secure': <Map<String |
| 61 | { |
| 62 | 'type': 'http', |
| 63 | 'scheme': 'bearer', |
| 64 | 'name': 'JWT-auth', |
| 65 | }, |
| 66 | ], |
| 67 | ...?extra, |
| 68 | }, |
| 69 | validateStatus: validateStatus, |
| 70 | ); |
| 71 | |
| 72 | final _queryParameters = <String |
| 73 | r'iata': encodeQueryParameter(_serializers, iata |
| 74 | r'icao': encodeQueryParameter(_serializers, icao |
| 75 | if (date != null) r'date': |
| 76 | r'timezone': encodeQueryParameter(_serializers, timezone |
| 77 | }; |
| 78 | |
| 79 | final _response = await _dio. |
| 80 | _path, |
| 81 | options: _options, |
| 82 | queryParameters: _queryParameters, |
| 83 | cancelToken: cancelToken, |
| 84 | onSendProgress: onSendProgress, |
| 85 | onReceiveProgress: onReceiveProgress, |
| 86 | ); |
| 87 | |
| 88 | FlightTrackResponseEntity? _responseData; |
| 89 | |
| 90 | try { |
| 91 | final rawResponse = _response.data; |
| 92 | _responseData = rawResponse == null ? null |
| 93 | rawResponse, |
| 94 | specifiedType: const FullType( |
| 95 | ) as FlightTrackResponseEntity; |
| 96 | |
| 97 | } catch (error, stackTrace) { |
| 98 | throw DioException( |
| 99 | requestOptions: _response.requestOptions, |
| 100 | response: _response, |
| 101 | type: DioExceptionType.unknown, |
| 102 | error: error, |
| 103 | stackTrace: stackTrace, |
| 104 | ); |
| 105 | } |
| 106 | |
| 107 | return Response<FlightTrackResponseEntity |
| 108 | data: _responseData, |
| 109 | headers: _response.headers, |
| 110 | isRedirect: _response.isRedirect, |
| 111 | requestOptions: _response.requestOptions, |
| 112 | redirects: _response.redirects, |
| 113 | statusCode: _response.statusCode, |
| 114 | statusMessage: _response.statusMessage, |
| 115 | extra: _response.extra, |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | /// Get flight details |
| 120 | /// Get detailed information about a specific flight including real-time tracking data |
| 121 | /// |
| 122 | /// Parameters: |
| 123 | /// * [iata] - IATA flight number |
| 124 | /// * [icao] - ICAO flight number |
| 125 | /// * [timezone] - The timezone from which the request is being made. |
| 126 | /// * [date] - Flight date (ISO format). Defaults to current date if not provided |
| 127 | /// * [forceUpdate] - Force update the flight data(used to refresh the flight data) |
| 128 | /// * [cancelToken] - A [CancelToken] |
| 129 | /// * [headers] - Can be used to add additional headers to the request |
| 130 | /// * [extras] - Can be used to add flags to the request |
| 131 | /// * [validateStatus] - A [ValidateStatus] |
| 132 | /// * [onSendProgress] - A [ProgressCallback] |
| 133 | /// * [onReceiveProgress] - A [ProgressCallback] |
| 134 | /// |
| 135 | /// Returns a [Future] containing a [Response] |
| 136 | /// Throws [DioException] if API call or serialization fails |
| 137 | Future<Response<FlightResponseEntity |
| 138 | required String iata, |
| 139 | required String icao, |
| 140 | required String timezone, |
| 141 | String? date, |
| 142 | bool? forceUpdate = false, |
| 143 | CancelToken? cancelToken, |
| 144 | Map<String, dynamic |
| 145 | Map<String, dynamic |
| 146 | ValidateStatus? validateStatus, |
| 147 | ProgressCallback? onSendProgress, |
| 148 | ProgressCallback? onReceiveProgress, |
| 149 | }) async { |
| 150 | final _path = r'/v1/flight'; |
| 151 | final _options = Options( |
| 152 | method: r'GET', |
| 153 | headers: <String, dynamic |
| 154 | ...?headers, |
| 155 | }, |
| 156 | extra: <String, dynamic |
| 157 | 'secure': <Map<String |
| 158 | { |
| 159 | 'type': 'http', |
| 160 | 'scheme': 'bearer', |
| 161 | 'name': 'JWT-auth', |
| 162 | }, |
| 163 | ], |
| 164 | ...?extra, |
| 165 | }, |
| 166 | validateStatus: validateStatus, |
| 167 | ); |
| 168 | |
| 169 | final _queryParameters = <String |
| 170 | r'iata': encodeQueryParameter(_serializers, iata |
| 171 | r'icao': encodeQueryParameter(_serializers, icao |
| 172 | if (date != null) r'date': |
| 173 | r'timezone': encodeQueryParameter(_serializers, timezone |
| 174 | if (forceUpdate != null) r'forceUpdate': |
| 175 | }; |
| 176 | |
| 177 | final _response = await _dio. |
| 178 | _path, |
| 179 | options: _options, |
| 180 | queryParameters: _queryParameters, |
| 181 | cancelToken: cancelToken, |
| 182 | onSendProgress: onSendProgress, |
| 183 | onReceiveProgress: onReceiveProgress, |
| 184 | ); |
| 185 | |
| 186 | FlightResponseEntity? _responseData; |
| 187 | |
| 188 | try { |
| 189 | final rawResponse = _response.data; |
| 190 | _responseData = rawResponse == null ? null |
| 191 | rawResponse, |
| 192 | specifiedType: const FullType( |
| 193 | ) as FlightResponseEntity; |
| 194 | |
| 195 | } catch (error, stackTrace) { |
| 196 | throw DioException( |
| 197 | requestOptions: _response.requestOptions, |
| 198 | response: _response, |
| 199 | type: DioExceptionType.unknown, |
| 200 | error: error, |
| 201 | stackTrace: stackTrace, |
| 202 | ); |
| 203 | } |
| 204 | |
| 205 | return Response<FlightResponseEntity |
| 206 | data: _responseData, |
| 207 | headers: _response.headers, |
| 208 | isRedirect: _response.isRedirect, |
| 209 | requestOptions: _response.requestOptions, |
| 210 | redirects: _response.redirects, |
| 211 | statusCode: _response.statusCode, |
| 212 | statusMessage: _response.statusMessage, |
| 213 | extra: _response.extra, |
| 214 | ); |
| 215 | } |
| 216 | |
| 217 | } |