added TenderDetailRequest
This commit is contained in:
@@ -11,7 +11,7 @@ const tenderDetailMockData = '''
|
||||
"deliveryLocation": "Norrbotten County",
|
||||
"referenceNumber": "KLF 2025/120",
|
||||
"country": "UK",
|
||||
"flagAsset": "assets/icons/SE.pngtest@example.compassword123",
|
||||
"flagAsset": "assets/icons/SE.png",
|
||||
"locationTitle": "Lorem ipsum is amet",
|
||||
"locationDescription": "Luleå Municipality is procuring on behalf of Norrbotten’s e-board (all municipalities in Norrbotten). The procurement includes operation, support, and further development of the existing open e-platform. No additional information, amendments, or answers to questions will be provided after June 16.",
|
||||
"documentName": "PDF, Document",
|
||||
@@ -21,4 +21,4 @@ const tenderDetailMockData = '''
|
||||
"incompleteResumeReason": "No experience in e-platform development"
|
||||
}
|
||||
}
|
||||
''';
|
||||
''';
|
||||
@@ -0,0 +1,16 @@
|
||||
// ignore_for_file: invalid_annotation_target
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'tender_detail_request.freezed.dart';
|
||||
part 'tender_detail_request.g.dart';
|
||||
|
||||
@freezed
|
||||
class TenderDetailRequest with _$TenderDetailRequest {
|
||||
const factory TenderDetailRequest({
|
||||
@JsonKey(name: 'id') required String id,
|
||||
}) = _TenderDetailRequest;
|
||||
|
||||
factory TenderDetailRequest.fromJson(Map<String, dynamic> json) =>
|
||||
_$TenderDetailRequestFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'tender_detail_request.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
TenderDetailRequest _$TenderDetailRequestFromJson(Map<String, dynamic> json) {
|
||||
return _TenderDetailRequest.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$TenderDetailRequest {
|
||||
@JsonKey(name: "id")
|
||||
String get id => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this TenderDetailRequest to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of TenderDetailRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$TenderDetailRequestCopyWith<TenderDetailRequest> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $TenderDetailRequestCopyWith<$Res> {
|
||||
factory $TenderDetailRequestCopyWith(
|
||||
TenderDetailRequest value,
|
||||
$Res Function(TenderDetailRequest) then,
|
||||
) = _$TenderDetailRequestCopyWithImpl<$Res, TenderDetailRequest>;
|
||||
@useResult
|
||||
$Res call({@JsonKey(name: "id") String id});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$TenderDetailRequestCopyWithImpl<$Res, $Val extends TenderDetailRequest>
|
||||
implements $TenderDetailRequestCopyWith<$Res> {
|
||||
_$TenderDetailRequestCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of TenderDetailRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? id = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
id:
|
||||
null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$TenderDetailRequestImplCopyWith<$Res>
|
||||
implements $TenderDetailRequestCopyWith<$Res> {
|
||||
factory _$$TenderDetailRequestImplCopyWith(
|
||||
_$TenderDetailRequestImpl value,
|
||||
$Res Function(_$TenderDetailRequestImpl) then,
|
||||
) = __$$TenderDetailRequestImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({@JsonKey(name: "id") String id});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$TenderDetailRequestImplCopyWithImpl<$Res>
|
||||
extends _$TenderDetailRequestCopyWithImpl<$Res, _$TenderDetailRequestImpl>
|
||||
implements _$$TenderDetailRequestImplCopyWith<$Res> {
|
||||
__$$TenderDetailRequestImplCopyWithImpl(
|
||||
_$TenderDetailRequestImpl _value,
|
||||
$Res Function(_$TenderDetailRequestImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of TenderDetailRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? id = null}) {
|
||||
return _then(
|
||||
_$TenderDetailRequestImpl(
|
||||
id:
|
||||
null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$TenderDetailRequestImpl implements _TenderDetailRequest {
|
||||
const _$TenderDetailRequestImpl({@JsonKey(name: "id") required this.id});
|
||||
|
||||
factory _$TenderDetailRequestImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$TenderDetailRequestImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: "id")
|
||||
final String id;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TenderDetailRequest(id: $id)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$TenderDetailRequestImpl &&
|
||||
(identical(other.id, id) || other.id == id));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id);
|
||||
|
||||
/// Create a copy of TenderDetailRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$TenderDetailRequestImplCopyWith<_$TenderDetailRequestImpl> get copyWith =>
|
||||
__$$TenderDetailRequestImplCopyWithImpl<_$TenderDetailRequestImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$TenderDetailRequestImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _TenderDetailRequest implements TenderDetailRequest {
|
||||
const factory _TenderDetailRequest({
|
||||
@JsonKey(name: "id") required final String id,
|
||||
}) = _$TenderDetailRequestImpl;
|
||||
|
||||
factory _TenderDetailRequest.fromJson(Map<String, dynamic> json) =
|
||||
_$TenderDetailRequestImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: "id")
|
||||
String get id;
|
||||
|
||||
/// Create a copy of TenderDetailRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$TenderDetailRequestImplCopyWith<_$TenderDetailRequestImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'tender_detail_request.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$TenderDetailRequestImpl _$$TenderDetailRequestImplFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$TenderDetailRequestImpl(id: json['id'] as String);
|
||||
|
||||
Map<String, dynamic> _$$TenderDetailRequestImplToJson(
|
||||
_$TenderDetailRequestImpl instance,
|
||||
) => <String, dynamic>{'id': instance.id};
|
||||
@@ -4,6 +4,7 @@ import 'package:dio/dio.dart';
|
||||
import 'package:tm_app/core/utils/logger.dart';
|
||||
import 'package:tm_app/core/utils/result.dart';
|
||||
import 'package:tm_app/data/services/mock_data/tender_detail_mock.dart';
|
||||
import 'package:tm_app/data/services/model/tender_detail_request/tender_detail_request.dart';
|
||||
import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart';
|
||||
import 'package:tm_app/data/services/network_manager.dart';
|
||||
|
||||
@@ -13,22 +14,23 @@ class TenderDetailService {
|
||||
|
||||
final NetworkManager _networkManager;
|
||||
|
||||
Future<Result<TenderDetailResponseModel>> getTenderDetail({required String id}) async {
|
||||
try {
|
||||
await Future.delayed(Duration(seconds: 2)); // شبیه سازی لود
|
||||
appLogger.info('get tender detail success');
|
||||
Future<Result<TenderDetailResponseModel>> getTenderDetail({
|
||||
required TenderDetailRequest request,
|
||||
}) async {
|
||||
try {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
appLogger.info('get tender detail success');
|
||||
|
||||
return Result.ok(
|
||||
TenderDetailResponseModel.fromJson(
|
||||
jsonDecode(tenderDetailMockData)['data'],
|
||||
),
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
appLogger.error('get tender detail failed: $e');
|
||||
return Result.error(e);
|
||||
} on Exception catch (e, stackTrace) {
|
||||
appLogger.error('get tender detail failed: $e', stackTrace: stackTrace);
|
||||
return Result.error(Exception(e));
|
||||
}
|
||||
return Result.ok(
|
||||
TenderDetailResponseModel.fromJson(
|
||||
jsonDecode(tenderDetailMockData)['data'],
|
||||
),
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
appLogger.error('get tender detail failed: $e', stackTrace: stackTrace);
|
||||
return Result.error(Exception(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user