| 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/model/generic_error_entity.dart'; |
| 12 | import 'package:openapi/src/model/login_dto.dart'; |
| 13 | import 'package:openapi/src/model/login_entity.dart'; |
| 14 | import 'package:openapi/src/model/register_dto.dart'; |
| 15 | import 'package:openapi/src/model/register_entity.dart'; |
| 16 | import 'package:openapi/src/model/user_entity.dart'; |
| 17 | |
| 18 | class AuthenticationApi { |
| 19 | |
| 20 | final Dio _dio; |
| 21 | |
| 22 | final Serializers _serializers; |
| 23 | |
| 24 | const AuthenticationApi(this |
| 25 | |
| 26 | /// Get current user |
| 27 | /// Get current user |
| 28 | /// |
| 29 | /// Parameters: |
| 30 | /// * [cancelToken] - A [CancelToken] |
| 31 | /// * [headers] - Can be used to add additional headers to the request |
| 32 | /// * [extras] - Can be used to add flags to the request |
| 33 | /// * [validateStatus] - A [ValidateStatus] |
| 34 | /// * [onSendProgress] - A [ProgressCallback] |
| 35 | /// * [onReceiveProgress] - A [ProgressCallback] |
| 36 | /// |
| 37 | /// Returns a [Future] containing a [Response] |
| 38 | /// Throws [DioException] if API call or serialization fails |
| 39 | Future<Response<UserEntity |
| 40 | CancelToken? cancelToken, |
| 41 | Map<String, dynamic |
| 42 | Map<String, dynamic |
| 43 | ValidateStatus? validateStatus, |
| 44 | ProgressCallback? onSendProgress, |
| 45 | ProgressCallback? onReceiveProgress, |
| 46 | }) async { |
| 47 | final _path = r'/v1/auth/@me'; |
| 48 | final _options = Options( |
| 49 | method: r'GET', |
| 50 | headers: <String, dynamic |
| 51 | ...?headers, |
| 52 | }, |
| 53 | extra: <String, dynamic |
| 54 | 'secure': <Map<String |
| 55 | { |
| 56 | 'type': 'http', |
| 57 | 'scheme': 'bearer', |
| 58 | 'name': 'JWT-auth', |
| 59 | }, |
| 60 | ], |
| 61 | ...?extra, |
| 62 | }, |
| 63 | validateStatus: validateStatus, |
| 64 | ); |
| 65 | |
| 66 | final _response = await _dio. |
| 67 | _path, |
| 68 | options: _options, |
| 69 | cancelToken: cancelToken, |
| 70 | onSendProgress: onSendProgress, |
| 71 | onReceiveProgress: onReceiveProgress, |
| 72 | ); |
| 73 | |
| 74 | UserEntity? _responseData; |
| 75 | |
| 76 | try { |
| 77 | final rawResponse = _response.data; |
| 78 | _responseData = rawResponse == null ? null |
| 79 | rawResponse, |
| 80 | specifiedType: const FullType( |
| 81 | ) as UserEntity; |
| 82 | |
| 83 | } catch (error, stackTrace) { |
| 84 | throw DioException( |
| 85 | requestOptions: _response.requestOptions, |
| 86 | response: _response, |
| 87 | type: DioExceptionType.unknown, |
| 88 | error: error, |
| 89 | stackTrace: stackTrace, |
| 90 | ); |
| 91 | } |
| 92 | |
| 93 | return Response<UserEntity |
| 94 | data: _responseData, |
| 95 | headers: _response.headers, |
| 96 | isRedirect: _response.isRedirect, |
| 97 | requestOptions: _response.requestOptions, |
| 98 | redirects: _response.redirects, |
| 99 | statusCode: _response.statusCode, |
| 100 | statusMessage: _response.statusMessage, |
| 101 | extra: _response.extra, |
| 102 | ); |
| 103 | } |
| 104 | |
| 105 | /// Login |
| 106 | /// Login |
| 107 | /// |
| 108 | /// Parameters: |
| 109 | /// * [loginDTO] |
| 110 | /// * [cancelToken] - A [CancelToken] |
| 111 | /// * [headers] - Can be used to add additional headers to the request |
| 112 | /// * [extras] - Can be used to add flags to the request |
| 113 | /// * [validateStatus] - A [ValidateStatus] |
| 114 | /// * [onSendProgress] - A [ProgressCallback] |
| 115 | /// * [onReceiveProgress] - A [ProgressCallback] |
| 116 | /// |
| 117 | /// Returns a [Future] containing a [Response] |
| 118 | /// Throws [DioException] if API call or serialization fails |
| 119 | Future<Response<LoginEntity |
| 120 | required LoginDTO loginDTO, |
| 121 | CancelToken? cancelToken, |
| 122 | Map<String, dynamic |
| 123 | Map<String, dynamic |
| 124 | ValidateStatus? validateStatus, |
| 125 | ProgressCallback? onSendProgress, |
| 126 | ProgressCallback? onReceiveProgress, |
| 127 | }) async { |
| 128 | final _path = r'/v1/auth/login'; |
| 129 | final _options = Options( |
| 130 | method: r'POST', |
| 131 | headers: <String, dynamic |
| 132 | ...?headers, |
| 133 | }, |
| 134 | extra: <String, dynamic |
| 135 | 'secure': <Map<String |
| 136 | ...?extra, |
| 137 | }, |
| 138 | contentType: 'application/json', |
| 139 | validateStatus: validateStatus, |
| 140 | ); |
| 141 | |
| 142 | dynamic _bodyData; |
| 143 | |
| 144 | try { |
| 145 | const _type = FullType( |
| 146 | _bodyData = _serializers.serialize(loginDTO, specifiedType |
| 147 | |
| 148 | } catch(error, stackTrace) { |
| 149 | throw DioException( |
| 150 | requestOptions: _options.compose( |
| 151 | _dio.options, |
| 152 | _path, |
| 153 | ), |
| 154 | type: DioExceptionType.unknown, |
| 155 | error: error, |
| 156 | stackTrace: stackTrace, |
| 157 | ); |
| 158 | } |
| 159 | |
| 160 | final _response = await _dio. |
| 161 | _path, |
| 162 | data: _bodyData, |
| 163 | options: _options, |
| 164 | cancelToken: cancelToken, |
| 165 | onSendProgress: onSendProgress, |
| 166 | onReceiveProgress: onReceiveProgress, |
| 167 | ); |
| 168 | |
| 169 | LoginEntity? _responseData; |
| 170 | |
| 171 | try { |
| 172 | final rawResponse = _response.data; |
| 173 | _responseData = rawResponse == null ? null |
| 174 | rawResponse, |
| 175 | specifiedType: const FullType( |
| 176 | ) as LoginEntity; |
| 177 | |
| 178 | } catch (error, stackTrace) { |
| 179 | throw DioException( |
| 180 | requestOptions: _response.requestOptions, |
| 181 | response: _response, |
| 182 | type: DioExceptionType.unknown, |
| 183 | error: error, |
| 184 | stackTrace: stackTrace, |
| 185 | ); |
| 186 | } |
| 187 | |
| 188 | return Response<LoginEntity |
| 189 | data: _responseData, |
| 190 | headers: _response.headers, |
| 191 | isRedirect: _response.isRedirect, |
| 192 | requestOptions: _response.requestOptions, |
| 193 | redirects: _response.redirects, |
| 194 | statusCode: _response.statusCode, |
| 195 | statusMessage: _response.statusMessage, |
| 196 | extra: _response.extra, |
| 197 | ); |
| 198 | } |
| 199 | |
| 200 | /// Register |
| 201 | /// Create a new user |
| 202 | /// |
| 203 | /// Parameters: |
| 204 | /// * [registerDTO] |
| 205 | /// * [cancelToken] - A [CancelToken] |
| 206 | /// * [headers] - Can be used to add additional headers to the request |
| 207 | /// * [extras] - Can be used to add flags to the request |
| 208 | /// * [validateStatus] - A [ValidateStatus] |
| 209 | /// * [onSendProgress] - A [ProgressCallback] |
| 210 | /// * [onReceiveProgress] - A [ProgressCallback] |
| 211 | /// |
| 212 | /// Returns a [Future] containing a [Response] |
| 213 | /// Throws [DioException] if API call or serialization fails |
| 214 | Future<Response<RegisterEntity |
| 215 | required RegisterDTO registerDTO, |
| 216 | CancelToken? cancelToken, |
| 217 | Map<String, dynamic |
| 218 | Map<String, dynamic |
| 219 | ValidateStatus? validateStatus, |
| 220 | ProgressCallback? onSendProgress, |
| 221 | ProgressCallback? onReceiveProgress, |
| 222 | }) async { |
| 223 | final _path = r'/v1/auth/register'; |
| 224 | final _options = Options( |
| 225 | method: r'POST', |
| 226 | headers: <String, dynamic |
| 227 | ...?headers, |
| 228 | }, |
| 229 | extra: <String, dynamic |
| 230 | 'secure': <Map<String |
| 231 | ...?extra, |
| 232 | }, |
| 233 | contentType: 'application/json', |
| 234 | validateStatus: validateStatus, |
| 235 | ); |
| 236 | |
| 237 | dynamic _bodyData; |
| 238 | |
| 239 | try { |
| 240 | const _type = FullType( |
| 241 | _bodyData = _serializers.serialize(registerDTO, specifiedType |
| 242 | |
| 243 | } catch(error, stackTrace) { |
| 244 | throw DioException( |
| 245 | requestOptions: _options.compose( |
| 246 | _dio.options, |
| 247 | _path, |
| 248 | ), |
| 249 | type: DioExceptionType.unknown, |
| 250 | error: error, |
| 251 | stackTrace: stackTrace, |
| 252 | ); |
| 253 | } |
| 254 | |
| 255 | final _response = await _dio. |
| 256 | _path, |
| 257 | data: _bodyData, |
| 258 | options: _options, |
| 259 | cancelToken: cancelToken, |
| 260 | onSendProgress: onSendProgress, |
| 261 | onReceiveProgress: onReceiveProgress, |
| 262 | ); |
| 263 | |
| 264 | RegisterEntity? _responseData; |
| 265 | |
| 266 | try { |
| 267 | final rawResponse = _response.data; |
| 268 | _responseData = rawResponse == null ? null |
| 269 | rawResponse, |
| 270 | specifiedType: const FullType( |
| 271 | ) as RegisterEntity; |
| 272 | |
| 273 | } catch (error, stackTrace) { |
| 274 | throw DioException( |
| 275 | requestOptions: _response.requestOptions, |
| 276 | response: _response, |
| 277 | type: DioExceptionType.unknown, |
| 278 | error: error, |
| 279 | stackTrace: stackTrace, |
| 280 | ); |
| 281 | } |
| 282 | |
| 283 | return Response<RegisterEntity |
| 284 | data: _responseData, |
| 285 | headers: _response.headers, |
| 286 | isRedirect: _response.isRedirect, |
| 287 | requestOptions: _response.requestOptions, |
| 288 | redirects: _response.redirects, |
| 289 | statusCode: _response.statusCode, |
| 290 | statusMessage: _response.statusMessage, |
| 291 | extra: _response.extra, |
| 292 | ); |
| 293 | } |
| 294 | |
| 295 | } |