From 2d44d22f5fb6065a35a64af4d19020f715eada28 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 25 Apr 2023 02:03:12 +0700 Subject: [PATCH] Wow, fuck autogenerators --- lib/src/api.dart | 44 +- lib/src/api/default_api.dart | 721 +++++------------- lib/src/api_util.dart | 77 -- lib/src/auth/basic_auth.dart | 37 - lib/src/auth/bearer_auth.dart | 26 - lib/src/auth/oauth.dart | 26 - lib/src/date_serializer.dart | 31 - lib/src/model/access_token_response.dart | 106 +-- lib/src/model/access_token_response.g.dart | 100 +-- lib/src/model/auth_model.dart | 16 +- lib/src/model/auth_model.g.dart | 17 + ...tems_from_table_items_table_name_post.dart | 23 - ...e_item_in_table_items_table_name_post.dart | 21 - lib/src/model/column_condition_compat.dart | 21 +- lib/src/model/column_condition_compat.g.dart | 39 + lib/src/model/create_asset_response.dart | 130 +--- lib/src/model/create_asset_response.g.dart | 111 +-- lib/src/model/create_user_definition.dart | 16 +- lib/src/model/create_user_definition.g.dart | 21 + lib/src/model/date.dart | 70 -- lib/src/model/error_response.dart | 108 +-- lib/src/model/error_response.g.dart | 94 +-- lib/src/model/http_validation_error.dart | 111 +-- lib/src/model/http_validation_error.g.dart | 111 +-- lib/src/model/item_update.dart | 23 + lib/src/model/item_update.g.dart | 18 + lib/src/model/items_field_selector_list.dart | 112 +-- .../model/items_field_selector_list.g.dart | 112 +-- lib/src/model/items_selector.dart | 24 + lib/src/model/items_selector.g.dart | 24 + lib/src/model/location_inner.dart | 68 -- lib/src/model/location_inner.g.dart | 93 --- lib/src/model/ok_response.dart | 109 +-- lib/src/model/ok_response.g.dart | 87 +-- lib/src/model/table_definition.dart | 184 +---- lib/src/model/table_definition.g.dart | 166 +--- lib/src/model/table_items_response.dart | 108 --- lib/src/model/table_items_response.g.dart | 109 --- lib/src/model/user_update_definition.dart | 15 +- lib/src/model/user_update_definition.g.dart | 23 + lib/src/model/validation_error.dart | 148 +--- lib/src/model/validation_error.g.dart | 142 +--- lib/src/serializers.dart | 74 -- lib/src/serializers.g.dart | 26 - lib/tuuli_api.dart | 13 +- pubspec.yaml | 14 +- 46 files changed, 630 insertions(+), 3139 deletions(-) delete mode 100644 lib/src/api_util.dart delete mode 100644 lib/src/auth/basic_auth.dart delete mode 100644 lib/src/auth/bearer_auth.dart delete mode 100644 lib/src/auth/oauth.dart delete mode 100644 lib/src/date_serializer.dart create mode 100644 lib/src/model/auth_model.g.dart delete mode 100644 lib/src/model/body_get_items_from_table_items_table_name_post.dart delete mode 100644 lib/src/model/body_update_item_in_table_items_table_name_post.dart create mode 100644 lib/src/model/column_condition_compat.g.dart create mode 100644 lib/src/model/create_user_definition.g.dart delete mode 100644 lib/src/model/date.dart create mode 100644 lib/src/model/item_update.dart create mode 100644 lib/src/model/item_update.g.dart create mode 100644 lib/src/model/items_selector.dart create mode 100644 lib/src/model/items_selector.g.dart delete mode 100644 lib/src/model/location_inner.dart delete mode 100644 lib/src/model/location_inner.g.dart delete mode 100644 lib/src/model/table_items_response.dart delete mode 100644 lib/src/model/table_items_response.g.dart create mode 100644 lib/src/model/user_update_definition.g.dart delete mode 100644 lib/src/serializers.dart delete mode 100644 lib/src/serializers.g.dart diff --git a/lib/src/api.dart b/lib/src/api.dart index dab5153..965d5f8 100644 --- a/lib/src/api.dart +++ b/lib/src/api.dart @@ -1,29 +1,17 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - import 'package:dio/dio.dart'; -import 'package:built_value/serializer.dart'; -import 'package:tuuli_api/src/serializers.dart'; import 'package:tuuli_api/src/auth/api_key_auth.dart'; -import 'package:tuuli_api/src/auth/basic_auth.dart'; -import 'package:tuuli_api/src/auth/bearer_auth.dart'; -import 'package:tuuli_api/src/auth/oauth.dart'; import 'package:tuuli_api/src/api/default_api.dart'; class TuuliApi { static const String basePath = r'http://localhost'; final Dio dio; - final Serializers serializers; TuuliApi({ Dio? dio, - Serializers? serializers, String? basePathOverride, List? interceptors, - }) : this.serializers = serializers ?? standardSerializers, - this.dio = dio ?? + }) : this.dio = dio ?? Dio(BaseOptions( baseUrl: basePathOverride ?? basePath, connectTimeout: const Duration(milliseconds: 5000), @@ -31,9 +19,6 @@ class TuuliApi { )) { if (interceptors == null) { this.dio.interceptors.addAll([ - OAuthInterceptor(), - BasicAuthInterceptor(), - BearerAuthInterceptor(), ApiKeyAuthInterceptor(), ]); } else { @@ -41,33 +26,20 @@ class TuuliApi { } } - void setOAuthToken(String name, String token) { - if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { - (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens[name] = token; - } - } - - void setBearerAuth(String name, String token) { - if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { - (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token; - } - } - - void setBasicAuth(String name, String username, String password) { - if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { - (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); - } - } - void setApiKey(String name, String apiKey) { if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { - (this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; + (this + .dio + .interceptors + .firstWhere((element) => element is ApiKeyAuthInterceptor) + as ApiKeyAuthInterceptor) + .apiKeys[name] = apiKey; } } /// Get DefaultApi instance, base route and serializer can be overridden by a given but be careful, /// by doing that all interceptors will not be executed DefaultApi getDefaultApi() { - return DefaultApi(dio, serializers); + return DefaultApi(dio); } } diff --git a/lib/src/api/default_api.dart b/lib/src/api/default_api.dart index 9ec5eee..b5ab359 100644 --- a/lib/src/api/default_api.dart +++ b/lib/src/api/default_api.dart @@ -4,22 +4,15 @@ import 'dart:async'; -import 'package:built_value/serializer.dart'; import 'package:dio/dio.dart'; -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/json_object.dart'; -import 'package:one_of/any_of.dart'; -import 'package:tuuli_api/src/api_util.dart'; import 'package:tuuli_api/src/model/access_token_response.dart'; import 'package:tuuli_api/src/model/auth_model.dart'; -import 'package:tuuli_api/src/model/body_get_items_from_table_items_table_name_post.dart'; -import 'package:tuuli_api/src/model/body_update_item_in_table_items_table_name_post.dart'; +import 'package:tuuli_api/src/model/items_selector.dart'; +import 'package:tuuli_api/src/model/item_update.dart'; import 'package:tuuli_api/src/model/column_condition_compat.dart'; import 'package:tuuli_api/src/model/create_asset_response.dart'; import 'package:tuuli_api/src/model/create_user_definition.dart'; -import 'package:tuuli_api/src/model/error_response.dart'; -import 'package:tuuli_api/src/model/http_validation_error.dart'; import 'package:tuuli_api/src/model/ok_response.dart'; import 'package:tuuli_api/src/model/table_definition.dart'; import 'package:tuuli_api/src/model/user_update_definition.dart'; @@ -27,20 +20,15 @@ import 'package:tuuli_api/src/model/user_update_definition.dart'; class DefaultApi { final Dio _dio; - final Serializers _serializers; - - const DefaultApi(this._dio, this._serializers); + const DefaultApi(this._dio); /// Create Item /// /// /// Parameters: /// * [tableName] - /// * [body] - /// * [accessToken] + /// * [itemDefinition] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -49,76 +37,42 @@ class DefaultApi { /// Throws [DioError] if API call or serialization fails Future> createItem({ required String tableName, - required Map body, - String? accessToken, + required Map itemDefinition, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/items/{tableName}/+' - .replaceAll('{' r'tableName' '}', tableName.toString()); + final _path = '/items/$tableName/+'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', contentType: 'application/json', validateStatus: validateStatus, ); - dynamic _bodyData; - - try { - _bodyData = body; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( + final _response = await _dio.request>( _path, - data: _bodyData, + data: itemDefinition, options: _options, cancelToken: cancelToken, onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -135,10 +89,7 @@ class DefaultApi { /// Parameters: /// * [tableName] /// * [requestBody] - /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -147,77 +98,42 @@ class DefaultApi { /// Throws [DioError] if API call or serialization fails Future> createTable({ required String tableName, - required List requestBody, - String? accessToken, + required List columnsDefinition, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/api/createTable/{tableName}' - .replaceAll('{' r'tableName' '}', tableName.toString()); + final _path = '/api/createTable/$tableName'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', contentType: 'application/json', validateStatus: validateStatus, ); - dynamic _bodyData; - - try { - const _type = FullType(List, [FullType(String)]); - _bodyData = _serializers.serialize(requestBody, specifiedType: _type); - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( + final _response = await _dio.request>( _path, - data: _bodyData, + data: columnsDefinition, options: _options, cancelToken: cancelToken, onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -233,10 +149,7 @@ class DefaultApi { /// /// Parameters: /// * [createUserDefinition] - /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -245,30 +158,19 @@ class DefaultApi { /// Throws [DioError] if API call or serialization fails Future> createUser({ required CreateUserDefinition createUserDefinition, - String? accessToken, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/api/users/+'; + final _path = '/api/users/+'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', contentType: 'application/json', validateStatus: validateStatus, ); - final _response = await _dio.request( + final _response = await _dio.request>( _path, data: createUserDefinition, options: _options, @@ -277,26 +179,20 @@ class DefaultApi { onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -313,10 +209,7 @@ class DefaultApi { /// Parameters: /// * [tableName] /// * [columnConditionCompat] - /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -326,31 +219,19 @@ class DefaultApi { Future> deleteItemFromTable({ required String tableName, required List columnConditionCompat, - String? accessToken, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/items/{tableName}/-' - .replaceAll('{' r'tableName' '}', tableName.toString()); + final _path = '/items/$tableName/-'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', contentType: 'application/json', validateStatus: validateStatus, ); - final _response = await _dio.request( + final _response = await _dio.request>( _path, data: columnConditionCompat, options: _options, @@ -359,26 +240,20 @@ class DefaultApi { onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -394,10 +269,7 @@ class DefaultApi { /// /// Parameters: /// * [tableName] - /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -406,30 +278,18 @@ class DefaultApi { /// Throws [DioError] if API call or serialization fails Future> dropTable({ required String tableName, - String? accessToken, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/api/dropTable/{tableName}' - .replaceAll('{' r'tableName' '}', tableName.toString()); + final _path = '/api/dropTable/$tableName'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', validateStatus: validateStatus, ); - final _response = await _dio.request( + final _response = await _dio.request>( _path, options: _options, cancelToken: cancelToken, @@ -437,26 +297,20 @@ class DefaultApi { onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -473,8 +327,6 @@ class DefaultApi { /// Parameters: /// * [authModel] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -484,27 +336,18 @@ class DefaultApi { Future> getAccessToken({ required AuthModel authModel, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/api/getAccessToken'; + final _path = '/api/getAccessToken'; final _options = Options( - method: r'POST', - headers: { - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', contentType: 'application/json', validateStatus: validateStatus, ); - final _response = await _dio.request( + final _response = await _dio.request>( _path, data: authModel, options: _options, @@ -513,26 +356,20 @@ class DefaultApi { onReceiveProgress: onReceiveProgress, ); - AccessTokenResponse _responseData; - - try { - const _responseType = FullType(AccessTokenResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as AccessTokenResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: AccessTokenResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -549,8 +386,6 @@ class DefaultApi { /// Parameters: /// * [fid] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -560,22 +395,13 @@ class DefaultApi { Future> getAsset({ required String fid, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/assets/{fid}'.replaceAll('{' r'fid' '}', fid.toString()); + final _path = '/assets/$fid'; final _options = Options( - method: r'GET', - headers: { - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'GET', validateStatus: validateStatus, ); @@ -604,73 +430,51 @@ class DefaultApi { /// /// Parameters: /// * [tableName] - /// * [accessToken] - /// * [bodyGetItemsFromTableItemsTableNamePost] + /// * [itemsSelector] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress /// /// Returns a [Future] containing a [Response] with a [List] as data /// Throws [DioError] if API call or serialization fails - Future>> getItemsFromTable({ + Future>>> getItemsFromTable({ required String tableName, - String? accessToken, - BodyGetItemsFromTableItemsTableNamePost? - bodyGetItemsFromTableItemsTableNamePost, + required ItemsSelector itemsSelector, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/items/{tableName}' - .replaceAll('{' r'tableName' '}', tableName.toString()); + final _path = '/items/$tableName'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', contentType: 'application/json', validateStatus: validateStatus, ); - final _response = await _dio.request( + final _response = await _dio.request>>( _path, - data: bodyGetItemsFromTableItemsTableNamePost, + data: itemsSelector, options: _options, cancelToken: cancelToken, onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ); - List _responseData; - - try { - const _responseType = FullType(List, [FullType(JsonObject)]); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as List; - } catch (error, stackTrace) { + List>? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } - return Response>( + return Response>>( data: _responseData, headers: _response.headers, isRedirect: _response.isRedirect, @@ -688,8 +492,6 @@ class DefaultApi { /// Parameters: /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -697,29 +499,18 @@ class DefaultApi { /// Returns a [Future] containing a [Response] with a [List] as data /// Throws [DioError] if API call or serialization fails Future>> listTables({ - String? accessToken, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/api/listTables'; + final _path = '/api/listTables'; final _options = Options( - method: r'GET', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'GET', validateStatus: validateStatus, ); - final _response = await _dio.request( + final _response = await _dio.request>>( _path, options: _options, cancelToken: cancelToken, @@ -727,26 +518,22 @@ class DefaultApi { onReceiveProgress: onReceiveProgress, ); - List _responseData; - - try { - const _responseType = FullType(List, [FullType(TableDefinition)]); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as List; - } catch (error, stackTrace) { + List>? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response>( - data: _responseData, + data: _responseData + .map((e) => TableDefinition.fromJson(e)) + .toList(growable: false), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -762,10 +549,7 @@ class DefaultApi { /// /// Parameters: /// * [asset] - /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -774,25 +558,14 @@ class DefaultApi { /// Throws [DioError] if API call or serialization fails Future> putAsset({ required MultipartFile asset, - String? accessToken, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/assets/+'; + final _path = '/assets/+'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', contentType: 'multipart/form-data', validateStatus: validateStatus, ); @@ -801,7 +574,7 @@ class DefaultApi { try { _bodyData = FormData.fromMap({ - r'asset': asset, + 'asset': asset, }); } catch (error, stackTrace) { throw DioError( @@ -815,7 +588,7 @@ class DefaultApi { ); } - final _response = await _dio.request( + final _response = await _dio.request>( _path, data: _bodyData, options: _options, @@ -824,26 +597,20 @@ class DefaultApi { onReceiveProgress: onReceiveProgress, ); - CreateAssetResponse _responseData; - - try { - const _responseType = FullType(CreateAssetResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as CreateAssetResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: CreateAssetResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -861,10 +628,7 @@ class DefaultApi { /// * [assetId] /// * [checkReferences] /// * [deleteReferencing] - /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -873,69 +637,45 @@ class DefaultApi { /// Throws [DioError] if API call or serialization fails Future> removeAsset({ required int assetId, - bool? checkReferences = true, - bool? deleteReferencing = false, - String? accessToken, + required bool checkReferences, + required bool deleteReferencing, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/assets/{asset_id}/-' - .replaceAll('{' r'asset_id' '}', assetId.toString()); + final _path = '/assets/$assetId/-'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', validateStatus: validateStatus, ); - final _queryParameters = { - if (checkReferences != null) - r'check_references': encodeQueryParameter( - _serializers, checkReferences, const FullType(bool)), - if (deleteReferencing != null) - r'delete_referencing': encodeQueryParameter( - _serializers, deleteReferencing, const FullType(bool)), - }; - - final _response = await _dio.request( + final _response = await _dio.request>( _path, + data: { + 'check_references': checkReferences, + 'delete_referencing': deleteReferencing, + }, options: _options, - queryParameters: _queryParameters, cancelToken: cancelToken, onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -951,10 +691,7 @@ class DefaultApi { /// /// Parameters: /// * [userId] - /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -963,62 +700,42 @@ class DefaultApi { /// Throws [DioError] if API call or serialization fails Future> removeUser({ required int userId, - String? accessToken, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/api/users/-'; + final _path = '/api/users/-'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', validateStatus: validateStatus, ); - final _queryParameters = { - r'user_id': - encodeQueryParameter(_serializers, userId, const FullType(int)), - }; - - final _response = await _dio.request( + final _response = await _dio.request>( _path, + data: { + 'user_id': userId, + }, options: _options, - queryParameters: _queryParameters, cancelToken: cancelToken, onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -1035,10 +752,7 @@ class DefaultApi { /// Parameters: /// * [assetId] /// * [assetDescription] - /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -1048,63 +762,42 @@ class DefaultApi { Future> updateAssetDescription({ required int assetId, required String assetDescription, - String? accessToken, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/assets/{asset_id}/*' - .replaceAll('{' r'asset_id' '}', assetId.toString()); + final _path = '/assets/$assetId/*'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', validateStatus: validateStatus, ); - final _queryParameters = { - r'asset_description': encodeQueryParameter( - _serializers, assetDescription, const FullType(String)), - }; - - final _response = await _dio.request( + final _response = await _dio.request>( _path, + data: { + 'asset_description': assetDescription, + }, options: _options, - queryParameters: _queryParameters, cancelToken: cancelToken, onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -1120,11 +813,8 @@ class DefaultApi { /// /// Parameters: /// * [tableName] - /// * [body] - /// * [accessToken] + /// * [itemUpdate] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -1133,60 +823,43 @@ class DefaultApi { /// Throws [DioError] if API call or serialization fails Future> updateItemInTable({ required String tableName, - required BodyUpdateItemInTableItemsTableNamePost body, - String? accessToken, + required ItemUpdate itemUpdate, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/items/{tableName}/*' - .replaceAll('{' r'tableName' '}', tableName.toString()); + final _path = '/items/{tableName}/*' + .replaceAll('{' 'tableName' '}', tableName.toString()); final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', contentType: 'application/json', validateStatus: validateStatus, ); - final _response = await _dio.request( + final _response = await _dio.request>( _path, - data: body, + data: itemUpdate, options: _options, cancelToken: cancelToken, onSendProgress: onSendProgress, onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, @@ -1202,10 +875,7 @@ class DefaultApi { /// /// Parameters: /// * [userUpdateDefinition] - /// * [accessToken] /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress @@ -1214,30 +884,19 @@ class DefaultApi { /// Throws [DioError] if API call or serialization fails Future> updateUser({ required UserUpdateDefinition userUpdateDefinition, - String? accessToken, CancelToken? cancelToken, - Map? headers, - Map? extra, ValidateStatus? validateStatus, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, }) async { - final _path = r'/api/users/*'; + final _path = '/api/users/*'; final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, + method: 'POST', contentType: 'application/json', validateStatus: validateStatus, ); - final _response = await _dio.request( + final _response = await _dio.request>( _path, data: userUpdateDefinition, options: _options, @@ -1246,26 +905,20 @@ class DefaultApi { onReceiveProgress: onReceiveProgress, ); - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { + Map? _responseData = _response.data; + if (_responseData == null) { throw DioError( - requestOptions: _response.requestOptions, - response: _response, + requestOptions: _options.compose( + _dio.options, + _path, + ), type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, + error: 'Response was null', ); } return Response( - data: _responseData, + data: OkResponse.fromJson(_responseData), headers: _response.headers, isRedirect: _response.isRedirect, requestOptions: _response.requestOptions, diff --git a/lib/src/api_util.dart b/lib/src/api_util.dart deleted file mode 100644 index ed3bb12..0000000 --- a/lib/src/api_util.dart +++ /dev/null @@ -1,77 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'dart:convert'; -import 'dart:typed_data'; - -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/serializer.dart'; -import 'package:dio/dio.dart'; - -/// Format the given form parameter object into something that Dio can handle. -/// Returns primitive or String. -/// Returns List/Map if the value is BuildList/BuiltMap. -dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) { - if (value == null) { - return ''; - } - if (value is String || value is num || value is bool) { - return value; - } - final serialized = serializers.serialize( - value as Object, - specifiedType: type, - ); - if (serialized is String) { - return serialized; - } - if (value is BuiltList || value is BuiltSet || value is BuiltMap) { - return serialized; - } - return json.encode(serialized); -} - -dynamic encodeQueryParameter( - Serializers serializers, - dynamic value, - FullType type, -) { - if (value == null) { - return ''; - } - if (value is String || value is num || value is bool) { - return value; - } - if (value is Uint8List) { - // Currently not sure how to serialize this - return value; - } - final serialized = serializers.serialize( - value as Object, - specifiedType: type, - ); - if (serialized == null) { - return ''; - } - if (serialized is String) { - return serialized; - } - return serialized; -} - -ListParam encodeCollectionQueryParameter( - Serializers serializers, - dynamic value, - FullType type, { - ListFormat format = ListFormat.multi, -}) { - final serialized = serializers.serialize( - value as Object, - specifiedType: type, - ); - if (value is BuiltList || value is BuiltSet) { - return ListParam(List.of((serialized as Iterable).cast()), format); - } - throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter'); -} diff --git a/lib/src/auth/basic_auth.dart b/lib/src/auth/basic_auth.dart deleted file mode 100644 index 3c1b489..0000000 --- a/lib/src/auth/basic_auth.dart +++ /dev/null @@ -1,37 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'dart:convert'; - -import 'package:dio/dio.dart'; -import 'package:tuuli_api/src/auth/auth.dart'; - -class BasicAuthInfo { - final String username; - final String password; - - const BasicAuthInfo(this.username, this.password); -} - -class BasicAuthInterceptor extends AuthInterceptor { - final Map authInfo = {}; - - @override - void onRequest( - RequestOptions options, - RequestInterceptorHandler handler, - ) { - final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic'); - for (final info in metadataAuthInfo) { - final authName = info['name'] as String; - final basicAuthInfo = authInfo[authName]; - if (basicAuthInfo != null) { - final basicAuth = 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}'; - options.headers['Authorization'] = basicAuth; - break; - } - } - super.onRequest(options, handler); - } -} diff --git a/lib/src/auth/bearer_auth.dart b/lib/src/auth/bearer_auth.dart deleted file mode 100644 index b206715..0000000 --- a/lib/src/auth/bearer_auth.dart +++ /dev/null @@ -1,26 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'package:dio/dio.dart'; -import 'package:tuuli_api/src/auth/auth.dart'; - -class BearerAuthInterceptor extends AuthInterceptor { - final Map tokens = {}; - - @override - void onRequest( - RequestOptions options, - RequestInterceptorHandler handler, - ) { - final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer'); - for (final info in authInfo) { - final token = tokens[info['name']]; - if (token != null) { - options.headers['Authorization'] = 'Bearer ${token}'; - break; - } - } - super.onRequest(options, handler); - } -} diff --git a/lib/src/auth/oauth.dart b/lib/src/auth/oauth.dart deleted file mode 100644 index 7f00317..0000000 --- a/lib/src/auth/oauth.dart +++ /dev/null @@ -1,26 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'package:dio/dio.dart'; -import 'package:tuuli_api/src/auth/auth.dart'; - -class OAuthInterceptor extends AuthInterceptor { - final Map tokens = {}; - - @override - void onRequest( - RequestOptions options, - RequestInterceptorHandler handler, - ) { - final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'oauth' || secure['type'] == 'oauth2'); - for (final info in authInfo) { - final token = tokens[info['name']]; - if (token != null) { - options.headers['Authorization'] = 'Bearer ${token}'; - break; - } - } - super.onRequest(options, handler); - } -} diff --git a/lib/src/date_serializer.dart b/lib/src/date_serializer.dart deleted file mode 100644 index b1f9d7e..0000000 --- a/lib/src/date_serializer.dart +++ /dev/null @@ -1,31 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/serializer.dart'; -import 'package:tuuli_api/src/model/date.dart'; - -class DateSerializer implements PrimitiveSerializer { - - const DateSerializer(); - - @override - Iterable get types => BuiltList.of([Date]); - - @override - String get wireName => 'Date'; - - @override - Date deserialize(Serializers serializers, Object serialized, - {FullType specifiedType = FullType.unspecified}) { - final parsed = DateTime.parse(serialized as String); - return Date(parsed.year, parsed.month, parsed.day); - } - - @override - Object serialize(Serializers serializers, Date date, - {FullType specifiedType = FullType.unspecified}) { - return date.toString(); - } -} diff --git a/lib/src/model/access_token_response.dart b/lib/src/model/access_token_response.dart index c7e4b29..71b2bd7 100644 --- a/lib/src/model/access_token_response.dart +++ b/lib/src/model/access_token_response.dart @@ -1,106 +1,18 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; +import 'package:json_annotation/json_annotation.dart'; part 'access_token_response.g.dart'; /// AccessTokenResponse /// /// Properties: -/// * [accessToken] -@BuiltValue() -abstract class AccessTokenResponse implements Built { - @BuiltValueField(wireName: r'access_token') - String get accessToken; +/// * [accessToken] +@JsonSerializable() +class AccessTokenResponse { + final String accessToken; - AccessTokenResponse._(); + const AccessTokenResponse({required this.accessToken}); - factory AccessTokenResponse([void updates(AccessTokenResponseBuilder b)]) = _$AccessTokenResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(AccessTokenResponseBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$AccessTokenResponseSerializer(); + factory AccessTokenResponse.fromJson(Map json) => + _$AccessTokenResponseFromJson(json); + Map toJson() => _$AccessTokenResponseToJson(this); } - -class _$AccessTokenResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [AccessTokenResponse, _$AccessTokenResponse]; - - @override - final String wireName = r'AccessTokenResponse'; - - Iterable _serializeProperties( - Serializers serializers, - AccessTokenResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'access_token'; - yield serializers.serialize( - object.accessToken, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - AccessTokenResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required AccessTokenResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'access_token': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.accessToken = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - AccessTokenResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = AccessTokenResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/src/model/access_token_response.g.dart b/lib/src/model/access_token_response.g.dart index 8432dd4..e90cccc 100644 --- a/lib/src/model/access_token_response.g.dart +++ b/lib/src/model/access_token_response.g.dart @@ -3,96 +3,16 @@ part of 'access_token_response.dart'; // ************************************************************************** -// BuiltValueGenerator +// JsonSerializableGenerator // ************************************************************************** -class _$AccessTokenResponse extends AccessTokenResponse { - @override - final String accessToken; +AccessTokenResponse _$AccessTokenResponseFromJson(Map json) => + AccessTokenResponse( + accessToken: json['accessToken'] as String, + ); - factory _$AccessTokenResponse( - [void Function(AccessTokenResponseBuilder)? updates]) => - (new AccessTokenResponseBuilder()..update(updates))._build(); - - _$AccessTokenResponse._({required this.accessToken}) : super._() { - BuiltValueNullFieldError.checkNotNull( - accessToken, r'AccessTokenResponse', 'accessToken'); - } - - @override - AccessTokenResponse rebuild( - void Function(AccessTokenResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - AccessTokenResponseBuilder toBuilder() => - new AccessTokenResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is AccessTokenResponse && accessToken == other.accessToken; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, accessToken.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'AccessTokenResponse') - ..add('accessToken', accessToken)) - .toString(); - } -} - -class AccessTokenResponseBuilder - implements Builder { - _$AccessTokenResponse? _$v; - - String? _accessToken; - String? get accessToken => _$this._accessToken; - set accessToken(String? accessToken) => _$this._accessToken = accessToken; - - AccessTokenResponseBuilder() { - AccessTokenResponse._defaults(this); - } - - AccessTokenResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _accessToken = $v.accessToken; - _$v = null; - } - return this; - } - - @override - void replace(AccessTokenResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$AccessTokenResponse; - } - - @override - void update(void Function(AccessTokenResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - AccessTokenResponse build() => _build(); - - _$AccessTokenResponse _build() { - final _$result = _$v ?? - new _$AccessTokenResponse._( - accessToken: BuiltValueNullFieldError.checkNotNull( - accessToken, r'AccessTokenResponse', 'accessToken')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint +Map _$AccessTokenResponseToJson( + AccessTokenResponse instance) => + { + 'accessToken': instance.accessToken, + }; diff --git a/lib/src/model/auth_model.dart b/lib/src/model/auth_model.dart index dbac330..f133bce 100644 --- a/lib/src/model/auth_model.dart +++ b/lib/src/model/auth_model.dart @@ -1,18 +1,20 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'auth_model.g.dart'; + /// AuthModel /// /// Properties: /// * [username] /// * [password] +@JsonSerializable() class AuthModel { final String username; final String password; - const AuthModel(this.username, this.password); + const AuthModel({required this.username, required this.password}); - Map toJson() { - return { - 'username': username, - 'password': password, - }; - } + factory AuthModel.fromJson(Map json) => + _$AuthModelFromJson(json); + Map toJson() => _$AuthModelToJson(this); } diff --git a/lib/src/model/auth_model.g.dart b/lib/src/model/auth_model.g.dart new file mode 100644 index 0000000..1fd0d3e --- /dev/null +++ b/lib/src/model/auth_model.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'auth_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +AuthModel _$AuthModelFromJson(Map json) => AuthModel( + username: json['username'] as String, + password: json['password'] as String, + ); + +Map _$AuthModelToJson(AuthModel instance) => { + 'username': instance.username, + 'password': instance.password, + }; diff --git a/lib/src/model/body_get_items_from_table_items_table_name_post.dart b/lib/src/model/body_get_items_from_table_items_table_name_post.dart deleted file mode 100644 index fe0bbaf..0000000 --- a/lib/src/model/body_get_items_from_table_items_table_name_post.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:tuuli_api/src/model/column_condition_compat.dart'; - -/// BodyGetItemsFromTableItemsTableNamePost -/// -/// Properties: -/// * [fields] -/// * [where] -class BodyGetItemsFromTableItemsTableNamePost { - final List fields; - final List where; - - const BodyGetItemsFromTableItemsTableNamePost({ - required this.fields, - required this.where, - }); - - Map toJson() { - return { - 'fields': fields, - 'where': where.map((e) => e.toJson()).toList(growable: false), - }; - } -} diff --git a/lib/src/model/body_update_item_in_table_items_table_name_post.dart b/lib/src/model/body_update_item_in_table_items_table_name_post.dart deleted file mode 100644 index 366b480..0000000 --- a/lib/src/model/body_update_item_in_table_items_table_name_post.dart +++ /dev/null @@ -1,21 +0,0 @@ -/// BodyUpdateItemInTableItemsTableNamePost -/// -/// Properties: -/// * [item] -/// * [oldItem] -class BodyUpdateItemInTableItemsTableNamePost { - final Map item; - final Map oldItem; - - const BodyUpdateItemInTableItemsTableNamePost({ - required this.item, - required this.oldItem, - }); - - Map toJson() { - return { - 'item': item, - 'oldItem': oldItem, - }; - } -} diff --git a/lib/src/model/column_condition_compat.dart b/lib/src/model/column_condition_compat.dart index 438b0f4..8158c19 100644 --- a/lib/src/model/column_condition_compat.dart +++ b/lib/src/model/column_condition_compat.dart @@ -1,3 +1,7 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'column_condition_compat.g.dart'; + enum ColumnConditionCompatOperator { eq, ne, @@ -19,18 +23,19 @@ enum ColumnConditionCompatOperator { /// * [column] /// * [operator_] /// * [value] +@JsonSerializable() class ColumnConditionCompat { final String column; final ColumnConditionCompatOperator operator_; final dynamic value; - const ColumnConditionCompat(this.column, this.operator_, this.value); + const ColumnConditionCompat({ + required this.column, + required this.operator_, + required this.value, + }); - Map toJson() { - return { - 'column': column, - 'operator': operator_.name, - 'value': value, - }; - } + factory ColumnConditionCompat.fromJson(Map json) => + _$ColumnConditionCompatFromJson(json); + Map toJson() => _$ColumnConditionCompatToJson(this); } diff --git a/lib/src/model/column_condition_compat.g.dart b/lib/src/model/column_condition_compat.g.dart new file mode 100644 index 0000000..d3d4d1e --- /dev/null +++ b/lib/src/model/column_condition_compat.g.dart @@ -0,0 +1,39 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'column_condition_compat.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ColumnConditionCompat _$ColumnConditionCompatFromJson( + Map json) => + ColumnConditionCompat( + column: json['column'] as String, + operator_: $enumDecode( + _$ColumnConditionCompatOperatorEnumMap, json['operator_']), + value: json['value'], + ); + +Map _$ColumnConditionCompatToJson( + ColumnConditionCompat instance) => + { + 'column': instance.column, + 'operator_': _$ColumnConditionCompatOperatorEnumMap[instance.operator_]!, + 'value': instance.value, + }; + +const _$ColumnConditionCompatOperatorEnumMap = { + ColumnConditionCompatOperator.eq: 'eq', + ColumnConditionCompatOperator.ne: 'ne', + ColumnConditionCompatOperator.gt: 'gt', + ColumnConditionCompatOperator.lt: 'lt', + ColumnConditionCompatOperator.ge: 'ge', + ColumnConditionCompatOperator.le: 'le', + ColumnConditionCompatOperator.contains: 'contains', + ColumnConditionCompatOperator.not_contains: 'not_contains', + ColumnConditionCompatOperator.starts_with: 'starts_with', + ColumnConditionCompatOperator.not_starts_with: 'not_starts_with', + ColumnConditionCompatOperator.ends_with: 'ends_with', + ColumnConditionCompatOperator.not_ends_with: 'not_ends_with', +}; diff --git a/lib/src/model/create_asset_response.dart b/lib/src/model/create_asset_response.dart index ef2943a..02fc246 100644 --- a/lib/src/model/create_asset_response.dart +++ b/lib/src/model/create_asset_response.dart @@ -1,125 +1,23 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; +import 'package:json_annotation/json_annotation.dart'; part 'create_asset_response.g.dart'; /// CreateAssetResponse /// /// Properties: -/// * [ok] -/// * [fid] -@BuiltValue() -abstract class CreateAssetResponse implements Built { - @BuiltValueField(wireName: r'ok') - bool? get ok; +/// * [ok] +/// * [fid] +@JsonSerializable() +class CreateAssetResponse { + final bool ok; + final String fid; - @BuiltValueField(wireName: r'fid') - String get fid; + const CreateAssetResponse({ + required this.ok, + required this.fid, + }); - CreateAssetResponse._(); - - factory CreateAssetResponse([void updates(CreateAssetResponseBuilder b)]) = _$CreateAssetResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(CreateAssetResponseBuilder b) => b - ..ok = true; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$CreateAssetResponseSerializer(); + factory CreateAssetResponse.fromJson(Map json) => + _$CreateAssetResponseFromJson(json); + Map toJson() => _$CreateAssetResponseToJson(this); } - -class _$CreateAssetResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [CreateAssetResponse, _$CreateAssetResponse]; - - @override - final String wireName = r'CreateAssetResponse'; - - Iterable _serializeProperties( - Serializers serializers, - CreateAssetResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - if (object.ok != null) { - yield r'ok'; - yield serializers.serialize( - object.ok, - specifiedType: const FullType(bool), - ); - } - yield r'fid'; - yield serializers.serialize( - object.fid, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - CreateAssetResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required CreateAssetResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'ok': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(bool), - ) as bool; - result.ok = valueDes; - break; - case r'fid': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.fid = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - CreateAssetResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = CreateAssetResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/src/model/create_asset_response.g.dart b/lib/src/model/create_asset_response.g.dart index adfdeae..4150643 100644 --- a/lib/src/model/create_asset_response.g.dart +++ b/lib/src/model/create_asset_response.g.dart @@ -3,105 +3,18 @@ part of 'create_asset_response.dart'; // ************************************************************************** -// BuiltValueGenerator +// JsonSerializableGenerator // ************************************************************************** -class _$CreateAssetResponse extends CreateAssetResponse { - @override - final bool? ok; - @override - final String fid; +CreateAssetResponse _$CreateAssetResponseFromJson(Map json) => + CreateAssetResponse( + ok: json['ok'] as bool, + fid: json['fid'] as String, + ); - factory _$CreateAssetResponse( - [void Function(CreateAssetResponseBuilder)? updates]) => - (new CreateAssetResponseBuilder()..update(updates))._build(); - - _$CreateAssetResponse._({this.ok, required this.fid}) : super._() { - BuiltValueNullFieldError.checkNotNull(fid, r'CreateAssetResponse', 'fid'); - } - - @override - CreateAssetResponse rebuild( - void Function(CreateAssetResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - CreateAssetResponseBuilder toBuilder() => - new CreateAssetResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is CreateAssetResponse && ok == other.ok && fid == other.fid; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, ok.hashCode); - _$hash = $jc(_$hash, fid.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'CreateAssetResponse') - ..add('ok', ok) - ..add('fid', fid)) - .toString(); - } -} - -class CreateAssetResponseBuilder - implements Builder { - _$CreateAssetResponse? _$v; - - bool? _ok; - bool? get ok => _$this._ok; - set ok(bool? ok) => _$this._ok = ok; - - String? _fid; - String? get fid => _$this._fid; - set fid(String? fid) => _$this._fid = fid; - - CreateAssetResponseBuilder() { - CreateAssetResponse._defaults(this); - } - - CreateAssetResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _ok = $v.ok; - _fid = $v.fid; - _$v = null; - } - return this; - } - - @override - void replace(CreateAssetResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$CreateAssetResponse; - } - - @override - void update(void Function(CreateAssetResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - CreateAssetResponse build() => _build(); - - _$CreateAssetResponse _build() { - final _$result = _$v ?? - new _$CreateAssetResponse._( - ok: ok, - fid: BuiltValueNullFieldError.checkNotNull( - fid, r'CreateAssetResponse', 'fid')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint +Map _$CreateAssetResponseToJson( + CreateAssetResponse instance) => + { + 'ok': instance.ok, + 'fid': instance.fid, + }; diff --git a/lib/src/model/create_user_definition.dart b/lib/src/model/create_user_definition.dart index c0cd454..5aecd25 100644 --- a/lib/src/model/create_user_definition.dart +++ b/lib/src/model/create_user_definition.dart @@ -1,18 +1,20 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'create_user_definition.g.dart'; + /// CreateUserDefinition /// /// Properties: /// * [username] /// * [password] +@JsonSerializable() class CreateUserDefinition { final String username; final String password; - const CreateUserDefinition(this.username, this.password); + const CreateUserDefinition({required this.username, required this.password}); - Map toJson() { - return { - 'username': username, - 'password': password, - }; - } + factory CreateUserDefinition.fromJson(Map json) => + _$CreateUserDefinitionFromJson(json); + Map toJson() => _$CreateUserDefinitionToJson(this); } diff --git a/lib/src/model/create_user_definition.g.dart b/lib/src/model/create_user_definition.g.dart new file mode 100644 index 0000000..09af2ae --- /dev/null +++ b/lib/src/model/create_user_definition.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_user_definition.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CreateUserDefinition _$CreateUserDefinitionFromJson( + Map json) => + CreateUserDefinition( + username: json['username'] as String, + password: json['password'] as String, + ); + +Map _$CreateUserDefinitionToJson( + CreateUserDefinition instance) => + { + 'username': instance.username, + 'password': instance.password, + }; diff --git a/lib/src/model/date.dart b/lib/src/model/date.dart deleted file mode 100644 index b21c7f5..0000000 --- a/lib/src/model/date.dart +++ /dev/null @@ -1,70 +0,0 @@ -/// A gregorian calendar date generated by -/// OpenAPI generator to differentiate -/// between [DateTime] and [Date] formats. -class Date implements Comparable { - final int year; - - /// January is 1. - final int month; - - /// First day is 1. - final int day; - - Date(this.year, this.month, this.day); - - /// The current date - static Date now({bool utc = false}) { - var now = DateTime.now(); - if (utc) { - now = now.toUtc(); - } - return now.toDate(); - } - - /// Convert to a [DateTime]. - DateTime toDateTime({bool utc = false}) { - if (utc) { - return DateTime.utc(year, month, day); - } else { - return DateTime(year, month, day); - } - } - - @override - int compareTo(Date other) { - int d = year.compareTo(other.year); - if (d != 0) { - return d; - } - d = month.compareTo(other.month); - if (d != 0) { - return d; - } - return day.compareTo(other.day); - } - - @override - bool operator ==(Object other) => - identical(this, other) || - other is Date && - runtimeType == other.runtimeType && - year == other.year && - month == other.month && - day == other.day; - - @override - int get hashCode => year.hashCode ^ month.hashCode ^ day.hashCode; - - @override - String toString() { - final yyyy = year.toString(); - final mm = month.toString().padLeft(2, '0'); - final dd = day.toString().padLeft(2, '0'); - - return '$yyyy-$mm-$dd'; - } -} - -extension DateTimeToDate on DateTime { - Date toDate() => Date(year, month, day); -} diff --git a/lib/src/model/error_response.dart b/lib/src/model/error_response.dart index a11a492..b52a41d 100644 --- a/lib/src/model/error_response.dart +++ b/lib/src/model/error_response.dart @@ -1,106 +1,20 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; +import 'package:json_annotation/json_annotation.dart'; part 'error_response.g.dart'; /// ErrorResponse /// /// Properties: -/// * [error] -@BuiltValue() -abstract class ErrorResponse implements Built { - @BuiltValueField(wireName: r'error') - String get error; +/// * [error] +@JsonSerializable() +class ErrorResponse { + final String error; - ErrorResponse._(); + const ErrorResponse({ + required this.error, + }); - factory ErrorResponse([void updates(ErrorResponseBuilder b)]) = _$ErrorResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(ErrorResponseBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ErrorResponseSerializer(); + factory ErrorResponse.fromJson(Map json) => + _$ErrorResponseFromJson(json); + Map toJson() => _$ErrorResponseToJson(this); } - -class _$ErrorResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [ErrorResponse, _$ErrorResponse]; - - @override - final String wireName = r'ErrorResponse'; - - Iterable _serializeProperties( - Serializers serializers, - ErrorResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'error'; - yield serializers.serialize( - object.error, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - ErrorResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required ErrorResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'error': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.error = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - ErrorResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = ErrorResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/src/model/error_response.g.dart b/lib/src/model/error_response.g.dart index 3d1df13..80b522d 100644 --- a/lib/src/model/error_response.g.dart +++ b/lib/src/model/error_response.g.dart @@ -3,91 +3,15 @@ part of 'error_response.dart'; // ************************************************************************** -// BuiltValueGenerator +// JsonSerializableGenerator // ************************************************************************** -class _$ErrorResponse extends ErrorResponse { - @override - final String error; +ErrorResponse _$ErrorResponseFromJson(Map json) => + ErrorResponse( + error: json['error'] as String, + ); - factory _$ErrorResponse([void Function(ErrorResponseBuilder)? updates]) => - (new ErrorResponseBuilder()..update(updates))._build(); - - _$ErrorResponse._({required this.error}) : super._() { - BuiltValueNullFieldError.checkNotNull(error, r'ErrorResponse', 'error'); - } - - @override - ErrorResponse rebuild(void Function(ErrorResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - ErrorResponseBuilder toBuilder() => new ErrorResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is ErrorResponse && error == other.error; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, error.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'ErrorResponse')..add('error', error)) - .toString(); - } -} - -class ErrorResponseBuilder - implements Builder { - _$ErrorResponse? _$v; - - String? _error; - String? get error => _$this._error; - set error(String? error) => _$this._error = error; - - ErrorResponseBuilder() { - ErrorResponse._defaults(this); - } - - ErrorResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _error = $v.error; - _$v = null; - } - return this; - } - - @override - void replace(ErrorResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$ErrorResponse; - } - - @override - void update(void Function(ErrorResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - ErrorResponse build() => _build(); - - _$ErrorResponse _build() { - final _$result = _$v ?? - new _$ErrorResponse._( - error: BuiltValueNullFieldError.checkNotNull( - error, r'ErrorResponse', 'error')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint +Map _$ErrorResponseToJson(ErrorResponse instance) => + { + 'error': instance.error, + }; diff --git a/lib/src/model/http_validation_error.dart b/lib/src/model/http_validation_error.dart index 12dfa85..4215ffe 100644 --- a/lib/src/model/http_validation_error.dart +++ b/lib/src/model/http_validation_error.dart @@ -1,110 +1,21 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; +import 'package:json_annotation/json_annotation.dart'; import 'package:tuuli_api/src/model/validation_error.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; part 'http_validation_error.g.dart'; /// HTTPValidationError /// /// Properties: -/// * [detail] -@BuiltValue() -abstract class HTTPValidationError implements Built { - @BuiltValueField(wireName: r'detail') - BuiltList? get detail; +/// * [detail] +@JsonSerializable() +class HTTPValidationError { + final List detail; - HTTPValidationError._(); + const HTTPValidationError({ + required this.detail, + }); - factory HTTPValidationError([void updates(HTTPValidationErrorBuilder b)]) = _$HTTPValidationError; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(HTTPValidationErrorBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$HTTPValidationErrorSerializer(); + factory HTTPValidationError.fromJson(Map json) => + _$HTTPValidationErrorFromJson(json); + Map toJson() => _$HTTPValidationErrorToJson(this); } - -class _$HTTPValidationErrorSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [HTTPValidationError, _$HTTPValidationError]; - - @override - final String wireName = r'HTTPValidationError'; - - Iterable _serializeProperties( - Serializers serializers, - HTTPValidationError object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - if (object.detail != null) { - yield r'detail'; - yield serializers.serialize( - object.detail, - specifiedType: const FullType(BuiltList, [FullType(ValidationError)]), - ); - } - } - - @override - Object serialize( - Serializers serializers, - HTTPValidationError object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required HTTPValidationErrorBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'detail': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(BuiltList, [FullType(ValidationError)]), - ) as BuiltList; - result.detail.replace(valueDes); - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - HTTPValidationError deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = HTTPValidationErrorBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/src/model/http_validation_error.g.dart b/lib/src/model/http_validation_error.g.dart index 40ab1a8..aec24b7 100644 --- a/lib/src/model/http_validation_error.g.dart +++ b/lib/src/model/http_validation_error.g.dart @@ -3,104 +3,19 @@ part of 'http_validation_error.dart'; // ************************************************************************** -// BuiltValueGenerator +// JsonSerializableGenerator // ************************************************************************** -class _$HTTPValidationError extends HTTPValidationError { - @override - final BuiltList? detail; +HTTPValidationError _$HTTPValidationErrorFromJson(Map json) => + HTTPValidationError( + detail: (json['detail'] as List) + .map((dynamic e) => + ValidationError.fromJson(e as Map)) + .toList(), + ); - factory _$HTTPValidationError( - [void Function(HTTPValidationErrorBuilder)? updates]) => - (new HTTPValidationErrorBuilder()..update(updates))._build(); - - _$HTTPValidationError._({this.detail}) : super._(); - - @override - HTTPValidationError rebuild( - void Function(HTTPValidationErrorBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - HTTPValidationErrorBuilder toBuilder() => - new HTTPValidationErrorBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is HTTPValidationError && detail == other.detail; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, detail.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'HTTPValidationError') - ..add('detail', detail)) - .toString(); - } -} - -class HTTPValidationErrorBuilder - implements Builder { - _$HTTPValidationError? _$v; - - ListBuilder? _detail; - ListBuilder get detail => - _$this._detail ??= new ListBuilder(); - set detail(ListBuilder? detail) => _$this._detail = detail; - - HTTPValidationErrorBuilder() { - HTTPValidationError._defaults(this); - } - - HTTPValidationErrorBuilder get _$this { - final $v = _$v; - if ($v != null) { - _detail = $v.detail?.toBuilder(); - _$v = null; - } - return this; - } - - @override - void replace(HTTPValidationError other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$HTTPValidationError; - } - - @override - void update(void Function(HTTPValidationErrorBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - HTTPValidationError build() => _build(); - - _$HTTPValidationError _build() { - _$HTTPValidationError _$result; - try { - _$result = _$v ?? new _$HTTPValidationError._(detail: _detail?.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'detail'; - _detail?.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'HTTPValidationError', _$failedField, e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint +Map _$HTTPValidationErrorToJson( + HTTPValidationError instance) => + { + 'detail': instance.detail, + }; diff --git a/lib/src/model/item_update.dart b/lib/src/model/item_update.dart new file mode 100644 index 0000000..72c79cf --- /dev/null +++ b/lib/src/model/item_update.dart @@ -0,0 +1,23 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'item_update.g.dart'; + +/// ItemUpdate +/// +/// Properties: +/// * [item] +/// * [oldItem] +@JsonSerializable() +class ItemUpdate { + final Map item; + final Map oldItem; + + const ItemUpdate({ + required this.item, + required this.oldItem, + }); + + factory ItemUpdate.fromJson(Map json) => + _$ItemUpdateFromJson(json); + Map toJson() => _$ItemUpdateToJson(this); +} diff --git a/lib/src/model/item_update.g.dart b/lib/src/model/item_update.g.dart new file mode 100644 index 0000000..5e43af1 --- /dev/null +++ b/lib/src/model/item_update.g.dart @@ -0,0 +1,18 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'item_update.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ItemUpdate _$ItemUpdateFromJson(Map json) => ItemUpdate( + item: Map.from(json['item'] as Map), + oldItem: Map.from(json['oldItem'] as Map), + ); + +Map _$ItemUpdateToJson(ItemUpdate instance) => + { + 'item': instance.item, + 'oldItem': instance.oldItem, + }; diff --git a/lib/src/model/items_field_selector_list.dart b/lib/src/model/items_field_selector_list.dart index 9d04644..430434b 100644 --- a/lib/src/model/items_field_selector_list.dart +++ b/lib/src/model/items_field_selector_list.dart @@ -1,110 +1,20 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; +import 'package:json_annotation/json_annotation.dart'; part 'items_field_selector_list.g.dart'; /// ItemsFieldSelectorList /// /// Properties: -/// * [fields] -@BuiltValue() -abstract class ItemsFieldSelectorList implements Built { - @BuiltValueField(wireName: r'fields') - BuiltList? get fields; +/// * [fields] +@JsonSerializable() +class ItemsFieldSelectorList { + final List fields; - ItemsFieldSelectorList._(); + const ItemsFieldSelectorList({ + required this.fields, + }); - factory ItemsFieldSelectorList([void updates(ItemsFieldSelectorListBuilder b)]) = _$ItemsFieldSelectorList; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(ItemsFieldSelectorListBuilder b) => b - ..fields = ListBuilder(); - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ItemsFieldSelectorListSerializer(); + factory ItemsFieldSelectorList.fromJson(Map json) => + _$ItemsFieldSelectorListFromJson(json); + Map toJson() => _$ItemsFieldSelectorListToJson(this); } - -class _$ItemsFieldSelectorListSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [ItemsFieldSelectorList, _$ItemsFieldSelectorList]; - - @override - final String wireName = r'ItemsFieldSelectorList'; - - Iterable _serializeProperties( - Serializers serializers, - ItemsFieldSelectorList object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - if (object.fields != null) { - yield r'fields'; - yield serializers.serialize( - object.fields, - specifiedType: const FullType(BuiltList, [FullType(String)]), - ); - } - } - - @override - Object serialize( - Serializers serializers, - ItemsFieldSelectorList object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required ItemsFieldSelectorListBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'fields': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(BuiltList, [FullType(String)]), - ) as BuiltList; - result.fields.replace(valueDes); - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - ItemsFieldSelectorList deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = ItemsFieldSelectorListBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/src/model/items_field_selector_list.g.dart b/lib/src/model/items_field_selector_list.g.dart index 18d1543..7037218 100644 --- a/lib/src/model/items_field_selector_list.g.dart +++ b/lib/src/model/items_field_selector_list.g.dart @@ -3,105 +3,19 @@ part of 'items_field_selector_list.dart'; // ************************************************************************** -// BuiltValueGenerator +// JsonSerializableGenerator // ************************************************************************** -class _$ItemsFieldSelectorList extends ItemsFieldSelectorList { - @override - final BuiltList? fields; +ItemsFieldSelectorList _$ItemsFieldSelectorListFromJson( + Map json) => + ItemsFieldSelectorList( + fields: (json['fields'] as List) + .map((dynamic e) => e as String) + .toList(), + ); - factory _$ItemsFieldSelectorList( - [void Function(ItemsFieldSelectorListBuilder)? updates]) => - (new ItemsFieldSelectorListBuilder()..update(updates))._build(); - - _$ItemsFieldSelectorList._({this.fields}) : super._(); - - @override - ItemsFieldSelectorList rebuild( - void Function(ItemsFieldSelectorListBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - ItemsFieldSelectorListBuilder toBuilder() => - new ItemsFieldSelectorListBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is ItemsFieldSelectorList && fields == other.fields; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, fields.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'ItemsFieldSelectorList') - ..add('fields', fields)) - .toString(); - } -} - -class ItemsFieldSelectorListBuilder - implements Builder { - _$ItemsFieldSelectorList? _$v; - - ListBuilder? _fields; - ListBuilder get fields => - _$this._fields ??= new ListBuilder(); - set fields(ListBuilder? fields) => _$this._fields = fields; - - ItemsFieldSelectorListBuilder() { - ItemsFieldSelectorList._defaults(this); - } - - ItemsFieldSelectorListBuilder get _$this { - final $v = _$v; - if ($v != null) { - _fields = $v.fields?.toBuilder(); - _$v = null; - } - return this; - } - - @override - void replace(ItemsFieldSelectorList other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$ItemsFieldSelectorList; - } - - @override - void update(void Function(ItemsFieldSelectorListBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - ItemsFieldSelectorList build() => _build(); - - _$ItemsFieldSelectorList _build() { - _$ItemsFieldSelectorList _$result; - try { - _$result = - _$v ?? new _$ItemsFieldSelectorList._(fields: _fields?.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'fields'; - _fields?.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'ItemsFieldSelectorList', _$failedField, e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint +Map _$ItemsFieldSelectorListToJson( + ItemsFieldSelectorList instance) => + { + 'fields': instance.fields, + }; diff --git a/lib/src/model/items_selector.dart b/lib/src/model/items_selector.dart new file mode 100644 index 0000000..3fbf520 --- /dev/null +++ b/lib/src/model/items_selector.dart @@ -0,0 +1,24 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:tuuli_api/src/model/column_condition_compat.dart'; + +part 'items_selector.g.dart'; + +/// BodyGetItemsFromTableItemsTableNamePost +/// +/// Properties: +/// * [fields] +/// * [where] +@JsonSerializable() +class ItemsSelector { + final List fields; + final List where; + + const ItemsSelector({ + required this.fields, + required this.where, + }); + + factory ItemsSelector.fromJson(Map json) => + _$ItemsSelectorFromJson(json); + Map toJson() => _$ItemsSelectorToJson(this); +} diff --git a/lib/src/model/items_selector.g.dart b/lib/src/model/items_selector.g.dart new file mode 100644 index 0000000..3448851 --- /dev/null +++ b/lib/src/model/items_selector.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'items_selector.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ItemsSelector _$ItemsSelectorFromJson(Map json) => + ItemsSelector( + fields: (json['fields'] as List) + .map((dynamic e) => e as String) + .toList(), + where: (json['where'] as List) + .map((dynamic e) => + ColumnConditionCompat.fromJson(e as Map)) + .toList(), + ); + +Map _$ItemsSelectorToJson(ItemsSelector instance) => + { + 'fields': instance.fields, + 'where': instance.where, + }; diff --git a/lib/src/model/location_inner.dart b/lib/src/model/location_inner.dart deleted file mode 100644 index 5a96d05..0000000 --- a/lib/src/model/location_inner.dart +++ /dev/null @@ -1,68 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'dart:core'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; -import 'package:one_of/any_of.dart'; - -part 'location_inner.g.dart'; - -/// LocationInner -@BuiltValue() -abstract class LocationInner implements Built { - /// Any Of [String], [int] - AnyOf get anyOf; - - LocationInner._(); - - factory LocationInner([void updates(LocationInnerBuilder b)]) = _$LocationInner; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(LocationInnerBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$LocationInnerSerializer(); -} - -class _$LocationInnerSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [LocationInner, _$LocationInner]; - - @override - final String wireName = r'LocationInner'; - - Iterable _serializeProperties( - Serializers serializers, - LocationInner object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - } - - @override - Object serialize( - Serializers serializers, - LocationInner object, { - FullType specifiedType = FullType.unspecified, - }) { - final anyOf = object.anyOf; - return serializers.serialize(anyOf, specifiedType: FullType(AnyOf, anyOf.valueTypes.map((type) => FullType(type)).toList()))!; - } - - @override - LocationInner deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = LocationInnerBuilder(); - Object? anyOfDataSrc; - final targetType = const FullType(AnyOf, [FullType(String), FullType(int), ]); - anyOfDataSrc = serialized; - result.anyOf = serializers.deserialize(anyOfDataSrc, specifiedType: targetType) as AnyOf; - return result.build(); - } -} - diff --git a/lib/src/model/location_inner.g.dart b/lib/src/model/location_inner.g.dart deleted file mode 100644 index 0cbf218..0000000 --- a/lib/src/model/location_inner.g.dart +++ /dev/null @@ -1,93 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'location_inner.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$LocationInner extends LocationInner { - @override - final AnyOf anyOf; - - factory _$LocationInner([void Function(LocationInnerBuilder)? updates]) => - (new LocationInnerBuilder()..update(updates))._build(); - - _$LocationInner._({required this.anyOf}) : super._() { - BuiltValueNullFieldError.checkNotNull(anyOf, r'LocationInner', 'anyOf'); - } - - @override - LocationInner rebuild(void Function(LocationInnerBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - LocationInnerBuilder toBuilder() => new LocationInnerBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is LocationInner && anyOf == other.anyOf; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, anyOf.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'LocationInner')..add('anyOf', anyOf)) - .toString(); - } -} - -class LocationInnerBuilder - implements Builder { - _$LocationInner? _$v; - - AnyOf? _anyOf; - AnyOf? get anyOf => _$this._anyOf; - set anyOf(AnyOf? anyOf) => _$this._anyOf = anyOf; - - LocationInnerBuilder() { - LocationInner._defaults(this); - } - - LocationInnerBuilder get _$this { - final $v = _$v; - if ($v != null) { - _anyOf = $v.anyOf; - _$v = null; - } - return this; - } - - @override - void replace(LocationInner other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$LocationInner; - } - - @override - void update(void Function(LocationInnerBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - LocationInner build() => _build(); - - _$LocationInner _build() { - final _$result = _$v ?? - new _$LocationInner._( - anyOf: BuiltValueNullFieldError.checkNotNull( - anyOf, r'LocationInner', 'anyOf')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/src/model/ok_response.dart b/lib/src/model/ok_response.dart index 9450d1a..349c262 100644 --- a/lib/src/model/ok_response.dart +++ b/lib/src/model/ok_response.dart @@ -1,109 +1,18 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; +import 'package:json_annotation/json_annotation.dart'; part 'ok_response.g.dart'; /// OkResponse /// /// Properties: -/// * [ok] -@BuiltValue() -abstract class OkResponse implements Built { - @BuiltValueField(wireName: r'ok') - bool? get ok; +/// * [ok] +@JsonSerializable() +class OkResponse { + final bool ok; - OkResponse._(); + const OkResponse({required this.ok}); - factory OkResponse([void updates(OkResponseBuilder b)]) = _$OkResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(OkResponseBuilder b) => b - ..ok = true; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$OkResponseSerializer(); + factory OkResponse.fromJson(Map json) => + _$OkResponseFromJson(json); + Map toJson() => _$OkResponseToJson(this); } - -class _$OkResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [OkResponse, _$OkResponse]; - - @override - final String wireName = r'OkResponse'; - - Iterable _serializeProperties( - Serializers serializers, - OkResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - if (object.ok != null) { - yield r'ok'; - yield serializers.serialize( - object.ok, - specifiedType: const FullType(bool), - ); - } - } - - @override - Object serialize( - Serializers serializers, - OkResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required OkResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'ok': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(bool), - ) as bool; - result.ok = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - OkResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = OkResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/src/model/ok_response.g.dart b/lib/src/model/ok_response.g.dart index 10a1287..0697602 100644 --- a/lib/src/model/ok_response.g.dart +++ b/lib/src/model/ok_response.g.dart @@ -3,85 +3,14 @@ part of 'ok_response.dart'; // ************************************************************************** -// BuiltValueGenerator +// JsonSerializableGenerator // ************************************************************************** -class _$OkResponse extends OkResponse { - @override - final bool? ok; +OkResponse _$OkResponseFromJson(Map json) => OkResponse( + ok: json['ok'] as bool, + ); - factory _$OkResponse([void Function(OkResponseBuilder)? updates]) => - (new OkResponseBuilder()..update(updates))._build(); - - _$OkResponse._({this.ok}) : super._(); - - @override - OkResponse rebuild(void Function(OkResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - OkResponseBuilder toBuilder() => new OkResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is OkResponse && ok == other.ok; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, ok.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'OkResponse')..add('ok', ok)) - .toString(); - } -} - -class OkResponseBuilder implements Builder { - _$OkResponse? _$v; - - bool? _ok; - bool? get ok => _$this._ok; - set ok(bool? ok) => _$this._ok = ok; - - OkResponseBuilder() { - OkResponse._defaults(this); - } - - OkResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _ok = $v.ok; - _$v = null; - } - return this; - } - - @override - void replace(OkResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$OkResponse; - } - - @override - void update(void Function(OkResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - OkResponse build() => _build(); - - _$OkResponse _build() { - final _$result = _$v ?? new _$OkResponse._(ok: ok); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint +Map _$OkResponseToJson(OkResponse instance) => + { + 'ok': instance.ok, + }; diff --git a/lib/src/model/table_definition.dart b/lib/src/model/table_definition.dart index 0356392..c4931c3 100644 --- a/lib/src/model/table_definition.dart +++ b/lib/src/model/table_definition.dart @@ -1,170 +1,32 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; +import 'package:json_annotation/json_annotation.dart'; part 'table_definition.g.dart'; /// TableDefinition /// /// Properties: -/// * [tableId] -/// * [tableName] -/// * [columns] -/// * [system] -/// * [hidden] -@BuiltValue() -abstract class TableDefinition implements Built { - @BuiltValueField(wireName: r'table_id') - String get tableId; +/// * [tableId] +/// * [tableName] +/// * [columns] +/// * [system] +/// * [hidden] +@JsonSerializable() +class TableDefinition { + final String tableId; + final String tableName; + final String columns; + final bool system; + final bool hidden; - @BuiltValueField(wireName: r'table_name') - String get tableName; + const TableDefinition({ + required this.tableId, + required this.tableName, + required this.columns, + required this.system, + required this.hidden, + }); - @BuiltValueField(wireName: r'columns') - String get columns; - - @BuiltValueField(wireName: r'system') - bool get system; - - @BuiltValueField(wireName: r'hidden') - bool get hidden; - - TableDefinition._(); - - factory TableDefinition([void updates(TableDefinitionBuilder b)]) = _$TableDefinition; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(TableDefinitionBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$TableDefinitionSerializer(); + factory TableDefinition.fromJson(Map json) => + _$TableDefinitionFromJson(json); + Map toJson() => _$TableDefinitionToJson(this); } - -class _$TableDefinitionSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [TableDefinition, _$TableDefinition]; - - @override - final String wireName = r'TableDefinition'; - - Iterable _serializeProperties( - Serializers serializers, - TableDefinition object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'table_id'; - yield serializers.serialize( - object.tableId, - specifiedType: const FullType(String), - ); - yield r'table_name'; - yield serializers.serialize( - object.tableName, - specifiedType: const FullType(String), - ); - yield r'columns'; - yield serializers.serialize( - object.columns, - specifiedType: const FullType(String), - ); - yield r'system'; - yield serializers.serialize( - object.system, - specifiedType: const FullType(bool), - ); - yield r'hidden'; - yield serializers.serialize( - object.hidden, - specifiedType: const FullType(bool), - ); - } - - @override - Object serialize( - Serializers serializers, - TableDefinition object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required TableDefinitionBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'table_id': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.tableId = valueDes; - break; - case r'table_name': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.tableName = valueDes; - break; - case r'columns': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.columns = valueDes; - break; - case r'system': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(bool), - ) as bool; - result.system = valueDes; - break; - case r'hidden': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(bool), - ) as bool; - result.hidden = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - TableDefinition deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = TableDefinitionBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/src/model/table_definition.g.dart b/lib/src/model/table_definition.g.dart index be971e9..da4cca9 100644 --- a/lib/src/model/table_definition.g.dart +++ b/lib/src/model/table_definition.g.dart @@ -3,155 +3,23 @@ part of 'table_definition.dart'; // ************************************************************************** -// BuiltValueGenerator +// JsonSerializableGenerator // ************************************************************************** -class _$TableDefinition extends TableDefinition { - @override - final String tableId; - @override - final String tableName; - @override - final String columns; - @override - final bool system; - @override - final bool hidden; +TableDefinition _$TableDefinitionFromJson(Map json) => + TableDefinition( + tableId: json['tableId'] as String, + tableName: json['tableName'] as String, + columns: json['columns'] as String, + system: json['system'] as bool, + hidden: json['hidden'] as bool, + ); - factory _$TableDefinition([void Function(TableDefinitionBuilder)? updates]) => - (new TableDefinitionBuilder()..update(updates))._build(); - - _$TableDefinition._( - {required this.tableId, - required this.tableName, - required this.columns, - required this.system, - required this.hidden}) - : super._() { - BuiltValueNullFieldError.checkNotNull( - tableId, r'TableDefinition', 'tableId'); - BuiltValueNullFieldError.checkNotNull( - tableName, r'TableDefinition', 'tableName'); - BuiltValueNullFieldError.checkNotNull( - columns, r'TableDefinition', 'columns'); - BuiltValueNullFieldError.checkNotNull(system, r'TableDefinition', 'system'); - BuiltValueNullFieldError.checkNotNull(hidden, r'TableDefinition', 'hidden'); - } - - @override - TableDefinition rebuild(void Function(TableDefinitionBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - TableDefinitionBuilder toBuilder() => - new TableDefinitionBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is TableDefinition && - tableId == other.tableId && - tableName == other.tableName && - columns == other.columns && - system == other.system && - hidden == other.hidden; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, tableId.hashCode); - _$hash = $jc(_$hash, tableName.hashCode); - _$hash = $jc(_$hash, columns.hashCode); - _$hash = $jc(_$hash, system.hashCode); - _$hash = $jc(_$hash, hidden.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'TableDefinition') - ..add('tableId', tableId) - ..add('tableName', tableName) - ..add('columns', columns) - ..add('system', system) - ..add('hidden', hidden)) - .toString(); - } -} - -class TableDefinitionBuilder - implements Builder { - _$TableDefinition? _$v; - - String? _tableId; - String? get tableId => _$this._tableId; - set tableId(String? tableId) => _$this._tableId = tableId; - - String? _tableName; - String? get tableName => _$this._tableName; - set tableName(String? tableName) => _$this._tableName = tableName; - - String? _columns; - String? get columns => _$this._columns; - set columns(String? columns) => _$this._columns = columns; - - bool? _system; - bool? get system => _$this._system; - set system(bool? system) => _$this._system = system; - - bool? _hidden; - bool? get hidden => _$this._hidden; - set hidden(bool? hidden) => _$this._hidden = hidden; - - TableDefinitionBuilder() { - TableDefinition._defaults(this); - } - - TableDefinitionBuilder get _$this { - final $v = _$v; - if ($v != null) { - _tableId = $v.tableId; - _tableName = $v.tableName; - _columns = $v.columns; - _system = $v.system; - _hidden = $v.hidden; - _$v = null; - } - return this; - } - - @override - void replace(TableDefinition other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$TableDefinition; - } - - @override - void update(void Function(TableDefinitionBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - TableDefinition build() => _build(); - - _$TableDefinition _build() { - final _$result = _$v ?? - new _$TableDefinition._( - tableId: BuiltValueNullFieldError.checkNotNull( - tableId, r'TableDefinition', 'tableId'), - tableName: BuiltValueNullFieldError.checkNotNull( - tableName, r'TableDefinition', 'tableName'), - columns: BuiltValueNullFieldError.checkNotNull( - columns, r'TableDefinition', 'columns'), - system: BuiltValueNullFieldError.checkNotNull( - system, r'TableDefinition', 'system'), - hidden: BuiltValueNullFieldError.checkNotNull( - hidden, r'TableDefinition', 'hidden')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint +Map _$TableDefinitionToJson(TableDefinition instance) => + { + 'tableId': instance.tableId, + 'tableName': instance.tableName, + 'columns': instance.columns, + 'system': instance.system, + 'hidden': instance.hidden, + }; diff --git a/lib/src/model/table_items_response.dart b/lib/src/model/table_items_response.dart deleted file mode 100644 index fabf448..0000000 --- a/lib/src/model/table_items_response.dart +++ /dev/null @@ -1,108 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/json_object.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'table_items_response.g.dart'; - -/// TableItemsResponse -/// -/// Properties: -/// * [items] -@BuiltValue() -abstract class TableItemsResponse implements Built { - @BuiltValueField(wireName: r'items') - BuiltList get items; - - TableItemsResponse._(); - - factory TableItemsResponse([void updates(TableItemsResponseBuilder b)]) = _$TableItemsResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(TableItemsResponseBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$TableItemsResponseSerializer(); -} - -class _$TableItemsResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [TableItemsResponse, _$TableItemsResponse]; - - @override - final String wireName = r'TableItemsResponse'; - - Iterable _serializeProperties( - Serializers serializers, - TableItemsResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'items'; - yield serializers.serialize( - object.items, - specifiedType: const FullType(BuiltList, [FullType(JsonObject)]), - ); - } - - @override - Object serialize( - Serializers serializers, - TableItemsResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required TableItemsResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'items': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(BuiltList, [FullType(JsonObject)]), - ) as BuiltList; - result.items.replace(valueDes); - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - TableItemsResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = TableItemsResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/src/model/table_items_response.g.dart b/lib/src/model/table_items_response.g.dart deleted file mode 100644 index d104f56..0000000 --- a/lib/src/model/table_items_response.g.dart +++ /dev/null @@ -1,109 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'table_items_response.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$TableItemsResponse extends TableItemsResponse { - @override - final BuiltList items; - - factory _$TableItemsResponse( - [void Function(TableItemsResponseBuilder)? updates]) => - (new TableItemsResponseBuilder()..update(updates))._build(); - - _$TableItemsResponse._({required this.items}) : super._() { - BuiltValueNullFieldError.checkNotNull( - items, r'TableItemsResponse', 'items'); - } - - @override - TableItemsResponse rebuild( - void Function(TableItemsResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - TableItemsResponseBuilder toBuilder() => - new TableItemsResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is TableItemsResponse && items == other.items; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, items.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'TableItemsResponse') - ..add('items', items)) - .toString(); - } -} - -class TableItemsResponseBuilder - implements Builder { - _$TableItemsResponse? _$v; - - ListBuilder? _items; - ListBuilder get items => - _$this._items ??= new ListBuilder(); - set items(ListBuilder? items) => _$this._items = items; - - TableItemsResponseBuilder() { - TableItemsResponse._defaults(this); - } - - TableItemsResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _items = $v.items.toBuilder(); - _$v = null; - } - return this; - } - - @override - void replace(TableItemsResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$TableItemsResponse; - } - - @override - void update(void Function(TableItemsResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - TableItemsResponse build() => _build(); - - _$TableItemsResponse _build() { - _$TableItemsResponse _$result; - try { - _$result = _$v ?? new _$TableItemsResponse._(items: items.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'items'; - items.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'TableItemsResponse', _$failedField, e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/src/model/user_update_definition.dart b/lib/src/model/user_update_definition.dart index 5303533..7330919 100644 --- a/lib/src/model/user_update_definition.dart +++ b/lib/src/model/user_update_definition.dart @@ -1,9 +1,14 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'user_update_definition.g.dart'; + /// UserUpdateDefinition /// /// Properties: /// * [userId] /// * [password] /// * [accessToken] +@JsonSerializable() class UserUpdateDefinition { final int userId; final String password; @@ -15,11 +20,7 @@ class UserUpdateDefinition { required this.accessToken, }); - Map toJson() { - return { - 'userId': userId, - 'password': password, - 'accessToken': accessToken, - }; - } + factory UserUpdateDefinition.fromJson(Map json) => + _$UserUpdateDefinitionFromJson(json); + Map toJson() => _$UserUpdateDefinitionToJson(this); } diff --git a/lib/src/model/user_update_definition.g.dart b/lib/src/model/user_update_definition.g.dart new file mode 100644 index 0000000..f5ec5fb --- /dev/null +++ b/lib/src/model/user_update_definition.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'user_update_definition.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +UserUpdateDefinition _$UserUpdateDefinitionFromJson( + Map json) => + UserUpdateDefinition( + userId: json['userId'] as int, + password: json['password'] as String, + accessToken: json['accessToken'] as String, + ); + +Map _$UserUpdateDefinitionToJson( + UserUpdateDefinition instance) => + { + 'userId': instance.userId, + 'password': instance.password, + 'accessToken': instance.accessToken, + }; diff --git a/lib/src/model/validation_error.dart b/lib/src/model/validation_error.dart index a8832b5..ed8d8c5 100644 --- a/lib/src/model/validation_error.dart +++ b/lib/src/model/validation_error.dart @@ -1,140 +1,26 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; -import 'package:tuuli_api/src/model/location_inner.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; +import 'package:json_annotation/json_annotation.dart'; part 'validation_error.g.dart'; /// ValidationError /// /// Properties: -/// * [loc] -/// * [msg] -/// * [type] -@BuiltValue() -abstract class ValidationError implements Built { - @BuiltValueField(wireName: r'loc') - BuiltList get loc; +/// * [loc] +/// * [msg] +/// * [type] +@JsonSerializable() +class ValidationError { + final List loc; + final String msg; + final String type; - @BuiltValueField(wireName: r'msg') - String get msg; + const ValidationError({ + required this.loc, + required this.msg, + required this.type, + }); - @BuiltValueField(wireName: r'type') - String get type; - - ValidationError._(); - - factory ValidationError([void updates(ValidationErrorBuilder b)]) = _$ValidationError; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(ValidationErrorBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ValidationErrorSerializer(); + factory ValidationError.fromJson(Map json) => + _$ValidationErrorFromJson(json); + Map toJson() => _$ValidationErrorToJson(this); } - -class _$ValidationErrorSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [ValidationError, _$ValidationError]; - - @override - final String wireName = r'ValidationError'; - - Iterable _serializeProperties( - Serializers serializers, - ValidationError object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'loc'; - yield serializers.serialize( - object.loc, - specifiedType: const FullType(BuiltList, [FullType(LocationInner)]), - ); - yield r'msg'; - yield serializers.serialize( - object.msg, - specifiedType: const FullType(String), - ); - yield r'type'; - yield serializers.serialize( - object.type, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - ValidationError object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required ValidationErrorBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'loc': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(BuiltList, [FullType(LocationInner)]), - ) as BuiltList; - result.loc.replace(valueDes); - break; - case r'msg': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.msg = valueDes; - break; - case r'type': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.type = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - ValidationError deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = ValidationErrorBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/src/model/validation_error.g.dart b/lib/src/model/validation_error.g.dart index ff3d21b..1b551b3 100644 --- a/lib/src/model/validation_error.g.dart +++ b/lib/src/model/validation_error.g.dart @@ -3,135 +3,19 @@ part of 'validation_error.dart'; // ************************************************************************** -// BuiltValueGenerator +// JsonSerializableGenerator // ************************************************************************** -class _$ValidationError extends ValidationError { - @override - final BuiltList loc; - @override - final String msg; - @override - final String type; +ValidationError _$ValidationErrorFromJson(Map json) => + ValidationError( + loc: json['loc'] as List, + msg: json['msg'] as String, + type: json['type'] as String, + ); - factory _$ValidationError([void Function(ValidationErrorBuilder)? updates]) => - (new ValidationErrorBuilder()..update(updates))._build(); - - _$ValidationError._( - {required this.loc, required this.msg, required this.type}) - : super._() { - BuiltValueNullFieldError.checkNotNull(loc, r'ValidationError', 'loc'); - BuiltValueNullFieldError.checkNotNull(msg, r'ValidationError', 'msg'); - BuiltValueNullFieldError.checkNotNull(type, r'ValidationError', 'type'); - } - - @override - ValidationError rebuild(void Function(ValidationErrorBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - ValidationErrorBuilder toBuilder() => - new ValidationErrorBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is ValidationError && - loc == other.loc && - msg == other.msg && - type == other.type; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, loc.hashCode); - _$hash = $jc(_$hash, msg.hashCode); - _$hash = $jc(_$hash, type.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'ValidationError') - ..add('loc', loc) - ..add('msg', msg) - ..add('type', type)) - .toString(); - } -} - -class ValidationErrorBuilder - implements Builder { - _$ValidationError? _$v; - - ListBuilder? _loc; - ListBuilder get loc => - _$this._loc ??= new ListBuilder(); - set loc(ListBuilder? loc) => _$this._loc = loc; - - String? _msg; - String? get msg => _$this._msg; - set msg(String? msg) => _$this._msg = msg; - - String? _type; - String? get type => _$this._type; - set type(String? type) => _$this._type = type; - - ValidationErrorBuilder() { - ValidationError._defaults(this); - } - - ValidationErrorBuilder get _$this { - final $v = _$v; - if ($v != null) { - _loc = $v.loc.toBuilder(); - _msg = $v.msg; - _type = $v.type; - _$v = null; - } - return this; - } - - @override - void replace(ValidationError other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$ValidationError; - } - - @override - void update(void Function(ValidationErrorBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - ValidationError build() => _build(); - - _$ValidationError _build() { - _$ValidationError _$result; - try { - _$result = _$v ?? - new _$ValidationError._( - loc: loc.build(), - msg: BuiltValueNullFieldError.checkNotNull( - msg, r'ValidationError', 'msg'), - type: BuiltValueNullFieldError.checkNotNull( - type, r'ValidationError', 'type')); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'loc'; - loc.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'ValidationError', _$failedField, e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint +Map _$ValidationErrorToJson(ValidationError instance) => + { + 'loc': instance.loc, + 'msg': instance.msg, + 'type': instance.type, + }; diff --git a/lib/src/serializers.dart b/lib/src/serializers.dart deleted file mode 100644 index df03301..0000000 --- a/lib/src/serializers.dart +++ /dev/null @@ -1,74 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_import - -import 'package:one_of_serializer/any_of_serializer.dart'; -import 'package:one_of_serializer/one_of_serializer.dart'; -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/json_object.dart'; -import 'package:built_value/serializer.dart'; -import 'package:built_value/standard_json_plugin.dart'; -import 'package:built_value/iso_8601_date_time_serializer.dart'; -import 'package:tuuli_api/src/date_serializer.dart'; -import 'package:tuuli_api/src/model/date.dart'; - -import 'package:tuuli_api/src/model/access_token_response.dart'; -import 'package:tuuli_api/src/model/auth_model.dart'; -import 'package:tuuli_api/src/model/body_get_items_from_table_items_table_name_post.dart'; -import 'package:tuuli_api/src/model/body_update_item_in_table_items_table_name_post.dart'; -import 'package:tuuli_api/src/model/column_condition_compat.dart'; -import 'package:tuuli_api/src/model/create_asset_response.dart'; -import 'package:tuuli_api/src/model/create_user_definition.dart'; -import 'package:tuuli_api/src/model/error_response.dart'; -import 'package:tuuli_api/src/model/http_validation_error.dart'; -import 'package:tuuli_api/src/model/location_inner.dart'; -import 'package:tuuli_api/src/model/ok_response.dart'; -import 'package:tuuli_api/src/model/table_definition.dart'; -import 'package:tuuli_api/src/model/user_update_definition.dart'; -import 'package:tuuli_api/src/model/validation_error.dart'; - -part 'serializers.g.dart'; - -@SerializersFor([ - AccessTokenResponse, - AuthModel, - BodyGetItemsFromTableItemsTableNamePost, - BodyUpdateItemInTableItemsTableNamePost, - ColumnConditionCompat, - CreateAssetResponse, - CreateUserDefinition, - ErrorResponse, - HTTPValidationError, - LocationInner, - OkResponse, - TableDefinition, - UserUpdateDefinition, - ValidationError, -]) -Serializers serializers = (_$serializers.toBuilder() - ..addBuilderFactory( - const FullType(BuiltList, [FullType(ColumnConditionCompat)]), - () => ListBuilder(), - ) - ..addBuilderFactory( - const FullType(BuiltList, [FullType(JsonObject)]), - () => ListBuilder(), - ) - ..addBuilderFactory( - const FullType(BuiltList, [FullType(String)]), - () => ListBuilder(), - ) - ..addBuilderFactory( - const FullType(BuiltList, [FullType(TableDefinition)]), - () => ListBuilder(), - ) - ..add(const OneOfSerializer()) - ..add(const AnyOfSerializer()) - ..add(const DateSerializer()) - ..add(Iso8601DateTimeSerializer())) - .build(); - -Serializers standardSerializers = - (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build(); diff --git a/lib/src/serializers.g.dart b/lib/src/serializers.g.dart deleted file mode 100644 index 19bd73c..0000000 --- a/lib/src/serializers.g.dart +++ /dev/null @@ -1,26 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'serializers.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -Serializers _$serializers = (new Serializers().toBuilder() - ..add(AccessTokenResponse.serializer) - ..add(CreateAssetResponse.serializer) - ..add(ErrorResponse.serializer) - ..add(HTTPValidationError.serializer) - ..add(LocationInner.serializer) - ..add(OkResponse.serializer) - ..add(TableDefinition.serializer) - ..add(ValidationError.serializer) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType(LocationInner)]), - () => new ListBuilder()) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType(ValidationError)]), - () => new ListBuilder())) - .build(); - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/tuuli_api.dart b/lib/tuuli_api.dart index 158b7e1..be24ce3 100644 --- a/lib/tuuli_api.dart +++ b/lib/tuuli_api.dart @@ -1,26 +1,17 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - export 'package:tuuli_api/src/api.dart'; export 'package:tuuli_api/src/auth/api_key_auth.dart'; -export 'package:tuuli_api/src/auth/basic_auth.dart'; -export 'package:tuuli_api/src/auth/oauth.dart'; -export 'package:tuuli_api/src/serializers.dart'; -export 'package:tuuli_api/src/model/date.dart'; export 'package:tuuli_api/src/api/default_api.dart'; export 'package:tuuli_api/src/model/access_token_response.dart'; export 'package:tuuli_api/src/model/auth_model.dart'; -export 'package:tuuli_api/src/model/body_get_items_from_table_items_table_name_post.dart'; -export 'package:tuuli_api/src/model/body_update_item_in_table_items_table_name_post.dart'; +export 'package:tuuli_api/src/model/items_selector.dart'; +export 'package:tuuli_api/src/model/item_update.dart'; export 'package:tuuli_api/src/model/column_condition_compat.dart'; export 'package:tuuli_api/src/model/create_asset_response.dart'; export 'package:tuuli_api/src/model/create_user_definition.dart'; export 'package:tuuli_api/src/model/error_response.dart'; export 'package:tuuli_api/src/model/http_validation_error.dart'; -export 'package:tuuli_api/src/model/location_inner.dart'; export 'package:tuuli_api/src/model/ok_response.dart'; export 'package:tuuli_api/src/model/table_definition.dart'; export 'package:tuuli_api/src/model/user_update_definition.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 874c797..28f4f5f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,16 +4,12 @@ description: OpenAPI API client homepage: homepage environment: - sdk: '>=2.15.0 <3.0.0' + sdk: ">=2.15.0 <3.0.0" dependencies: - dio: '^5.0.0' - one_of: '>=1.5.0 <2.0.0' - one_of_serializer: '>=1.5.0 <2.0.0' - built_value: '>=8.4.0 <9.0.0' - built_collection: '>=5.1.1 <6.0.0' + dio: "^5.0.0" dev_dependencies: - built_value_generator: '>=8.4.0 <9.0.0' - build_runner: any - test: ^1.16.0 + build_runner: any + json_serializable: ^6.6.1 + test: ^1.16.0