// GENERATED CODE - DO NOT MODIFY BY HAND part of 'create_diet_service.dart'; // ************************************************************************** // RetrofitGenerator // ************************************************************************** // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _CreateDietService implements CreateDietService { _CreateDietService( this._dio, { this.baseUrl, this.errorLogger, }); final Dio _dio; String? baseUrl; final ParseErrorLogger? errorLogger; @override Future createDiet({ String? name, int? duration, String? state, String? meatType, String? carbType, String? vegType, String? lightType, String? details, File? image, }) async { final _extra = {}; final queryParameters = {}; queryParameters.removeWhere((k, v) => v == null); final _headers = {}; final _data = FormData(); if (name != null) { _data.fields.add(MapEntry( 'name', name, )); } if (duration != null) { _data.fields.add(MapEntry( 'duration', duration.toString(), )); } if (state != null) { _data.fields.add(MapEntry( 'state', state, )); } if (meatType != null) { _data.fields.add(MapEntry( 'type[meat]', meatType, )); } if (carbType != null) { _data.fields.add(MapEntry( 'type[carb]', carbType, )); } if (vegType != null) { _data.fields.add(MapEntry( 'type[veg]', vegType, )); } if (lightType != null) { _data.fields.add(MapEntry( 'type[light]', lightType, )); } if (details != null) { _data.fields.add(MapEntry( 'details', details, )); } if (image != null) { if (image != null) { _data.files.add(MapEntry( 'image', MultipartFile.fromFileSync( image.path, filename: image.path.split(Platform.pathSeparator).last, ), )); } } final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'multipart/form-data', ) .compose( _dio.options, '/api/diets/create', queryParameters: queryParameters, data: _data, ) .copyWith( baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, ))); final _result = await _dio.fetch>(_options); late CreatedDiet _value; try { _value = CreatedDiet.fromJson(_result.data!); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; } return _value; } @override Future createDietDailySchedule({ required int id, required Map model, }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; final _data = {}; _data.addAll(model); final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) .compose( _dio.options, '/api/diets/create/${id}/daily_schedule', queryParameters: queryParameters, data: _data, ) .copyWith( baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, ))); await _dio.fetch(_options); } RequestOptions _setStreamType(RequestOptions requestOptions) { if (T != dynamic && !(requestOptions.responseType == ResponseType.bytes || requestOptions.responseType == ResponseType.stream)) { if (T == String) { requestOptions.responseType = ResponseType.plain; } else { requestOptions.responseType = ResponseType.json; } } return requestOptions; } String _combineBaseUrls( String dioBaseUrl, String? baseUrl, ) { if (baseUrl == null || baseUrl.trim().isEmpty) { return dioBaseUrl; } final url = Uri.parse(baseUrl); if (url.isAbsolute) { return url.toString(); } return Uri.parse(dioBaseUrl).resolveUri(url).toString(); } }