feat: update user
This commit is contained in:
@@ -5,7 +5,7 @@ import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/analytic/analytic.dart';
|
||||
import '../../../domain/analytic/repositories/i_analytic_repository.dart';
|
||||
import '../../../domain/auth/auth.dart';
|
||||
import '../../../domain/user/user.dart';
|
||||
import '../../auth/datasources/local_data_provider.dart';
|
||||
import '../datasource/remote_data_provider.dart';
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../domain/auth/auth.dart';
|
||||
import '../../domain/user/user.dart';
|
||||
import '../user/user_dtos.dart';
|
||||
|
||||
part 'auth_dtos.freezed.dart';
|
||||
part 'auth_dtos.g.dart';
|
||||
|
||||
part 'dto/auth_dto.dart';
|
||||
part 'dto/user_dto.dart';
|
||||
|
||||
@@ -242,401 +242,3 @@ abstract class _AuthDto extends AuthDto {
|
||||
_$$AuthDtoImplCopyWith<_$AuthDtoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
UserDto _$UserDtoFromJson(Map<String, dynamic> json) {
|
||||
return _UserDto.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UserDto {
|
||||
@JsonKey(name: 'id')
|
||||
String? get id => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'organization_id')
|
||||
String? get organizationId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'outlet_id')
|
||||
String? get outletId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'name')
|
||||
String? get name => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'email')
|
||||
String? get email => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'role')
|
||||
String? get role => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'permissions')
|
||||
Map<String, dynamic>? get permissions => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'is_active')
|
||||
bool? get isActive => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'created_at')
|
||||
String? get createdAt => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'updated_at')
|
||||
String? get updatedAt => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this UserDto to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$UserDtoCopyWith<UserDto> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UserDtoCopyWith<$Res> {
|
||||
factory $UserDtoCopyWith(UserDto value, $Res Function(UserDto) then) =
|
||||
_$UserDtoCopyWithImpl<$Res, UserDto>;
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'organization_id') String? organizationId,
|
||||
@JsonKey(name: 'outlet_id') String? outletId,
|
||||
@JsonKey(name: 'name') String? name,
|
||||
@JsonKey(name: 'email') String? email,
|
||||
@JsonKey(name: 'role') String? role,
|
||||
@JsonKey(name: 'permissions') Map<String, dynamic>? permissions,
|
||||
@JsonKey(name: 'is_active') bool? isActive,
|
||||
@JsonKey(name: 'created_at') String? createdAt,
|
||||
@JsonKey(name: 'updated_at') String? updatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UserDtoCopyWithImpl<$Res, $Val extends UserDto>
|
||||
implements $UserDtoCopyWith<$Res> {
|
||||
_$UserDtoCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? organizationId = freezed,
|
||||
Object? outletId = freezed,
|
||||
Object? name = freezed,
|
||||
Object? email = freezed,
|
||||
Object? role = freezed,
|
||||
Object? permissions = freezed,
|
||||
Object? isActive = freezed,
|
||||
Object? createdAt = freezed,
|
||||
Object? updatedAt = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
organizationId: freezed == organizationId
|
||||
? _value.organizationId
|
||||
: organizationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
outletId: freezed == outletId
|
||||
? _value.outletId
|
||||
: outletId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
name: freezed == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
email: freezed == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
role: freezed == role
|
||||
? _value.role
|
||||
: role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
permissions: freezed == permissions
|
||||
? _value.permissions
|
||||
: permissions // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
isActive: freezed == isActive
|
||||
? _value.isActive
|
||||
: isActive // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
createdAt: freezed == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
updatedAt: freezed == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UserDtoImplCopyWith<$Res> implements $UserDtoCopyWith<$Res> {
|
||||
factory _$$UserDtoImplCopyWith(
|
||||
_$UserDtoImpl value,
|
||||
$Res Function(_$UserDtoImpl) then,
|
||||
) = __$$UserDtoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'organization_id') String? organizationId,
|
||||
@JsonKey(name: 'outlet_id') String? outletId,
|
||||
@JsonKey(name: 'name') String? name,
|
||||
@JsonKey(name: 'email') String? email,
|
||||
@JsonKey(name: 'role') String? role,
|
||||
@JsonKey(name: 'permissions') Map<String, dynamic>? permissions,
|
||||
@JsonKey(name: 'is_active') bool? isActive,
|
||||
@JsonKey(name: 'created_at') String? createdAt,
|
||||
@JsonKey(name: 'updated_at') String? updatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UserDtoImplCopyWithImpl<$Res>
|
||||
extends _$UserDtoCopyWithImpl<$Res, _$UserDtoImpl>
|
||||
implements _$$UserDtoImplCopyWith<$Res> {
|
||||
__$$UserDtoImplCopyWithImpl(
|
||||
_$UserDtoImpl _value,
|
||||
$Res Function(_$UserDtoImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? organizationId = freezed,
|
||||
Object? outletId = freezed,
|
||||
Object? name = freezed,
|
||||
Object? email = freezed,
|
||||
Object? role = freezed,
|
||||
Object? permissions = freezed,
|
||||
Object? isActive = freezed,
|
||||
Object? createdAt = freezed,
|
||||
Object? updatedAt = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$UserDtoImpl(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
organizationId: freezed == organizationId
|
||||
? _value.organizationId
|
||||
: organizationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
outletId: freezed == outletId
|
||||
? _value.outletId
|
||||
: outletId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
name: freezed == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
email: freezed == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
role: freezed == role
|
||||
? _value.role
|
||||
: role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
permissions: freezed == permissions
|
||||
? _value._permissions
|
||||
: permissions // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
isActive: freezed == isActive
|
||||
? _value.isActive
|
||||
: isActive // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
createdAt: freezed == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
updatedAt: freezed == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$UserDtoImpl extends _UserDto {
|
||||
const _$UserDtoImpl({
|
||||
@JsonKey(name: 'id') this.id,
|
||||
@JsonKey(name: 'organization_id') this.organizationId,
|
||||
@JsonKey(name: 'outlet_id') this.outletId,
|
||||
@JsonKey(name: 'name') this.name,
|
||||
@JsonKey(name: 'email') this.email,
|
||||
@JsonKey(name: 'role') this.role,
|
||||
@JsonKey(name: 'permissions') final Map<String, dynamic>? permissions,
|
||||
@JsonKey(name: 'is_active') this.isActive,
|
||||
@JsonKey(name: 'created_at') this.createdAt,
|
||||
@JsonKey(name: 'updated_at') this.updatedAt,
|
||||
}) : _permissions = permissions,
|
||||
super._();
|
||||
|
||||
factory _$UserDtoImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$UserDtoImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'id')
|
||||
final String? id;
|
||||
@override
|
||||
@JsonKey(name: 'organization_id')
|
||||
final String? organizationId;
|
||||
@override
|
||||
@JsonKey(name: 'outlet_id')
|
||||
final String? outletId;
|
||||
@override
|
||||
@JsonKey(name: 'name')
|
||||
final String? name;
|
||||
@override
|
||||
@JsonKey(name: 'email')
|
||||
final String? email;
|
||||
@override
|
||||
@JsonKey(name: 'role')
|
||||
final String? role;
|
||||
final Map<String, dynamic>? _permissions;
|
||||
@override
|
||||
@JsonKey(name: 'permissions')
|
||||
Map<String, dynamic>? get permissions {
|
||||
final value = _permissions;
|
||||
if (value == null) return null;
|
||||
if (_permissions is EqualUnmodifiableMapView) return _permissions;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'is_active')
|
||||
final bool? isActive;
|
||||
@override
|
||||
@JsonKey(name: 'created_at')
|
||||
final String? createdAt;
|
||||
@override
|
||||
@JsonKey(name: 'updated_at')
|
||||
final String? updatedAt;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UserDto(id: $id, organizationId: $organizationId, outletId: $outletId, name: $name, email: $email, role: $role, permissions: $permissions, isActive: $isActive, createdAt: $createdAt, updatedAt: $updatedAt)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UserDtoImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.organizationId, organizationId) ||
|
||||
other.organizationId == organizationId) &&
|
||||
(identical(other.outletId, outletId) ||
|
||||
other.outletId == outletId) &&
|
||||
(identical(other.name, name) || other.name == name) &&
|
||||
(identical(other.email, email) || other.email == email) &&
|
||||
(identical(other.role, role) || other.role == role) &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other._permissions,
|
||||
_permissions,
|
||||
) &&
|
||||
(identical(other.isActive, isActive) ||
|
||||
other.isActive == isActive) &&
|
||||
(identical(other.createdAt, createdAt) ||
|
||||
other.createdAt == createdAt) &&
|
||||
(identical(other.updatedAt, updatedAt) ||
|
||||
other.updatedAt == updatedAt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
id,
|
||||
organizationId,
|
||||
outletId,
|
||||
name,
|
||||
email,
|
||||
role,
|
||||
const DeepCollectionEquality().hash(_permissions),
|
||||
isActive,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
);
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith =>
|
||||
__$$UserDtoImplCopyWithImpl<_$UserDtoImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$UserDtoImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _UserDto extends UserDto {
|
||||
const factory _UserDto({
|
||||
@JsonKey(name: 'id') final String? id,
|
||||
@JsonKey(name: 'organization_id') final String? organizationId,
|
||||
@JsonKey(name: 'outlet_id') final String? outletId,
|
||||
@JsonKey(name: 'name') final String? name,
|
||||
@JsonKey(name: 'email') final String? email,
|
||||
@JsonKey(name: 'role') final String? role,
|
||||
@JsonKey(name: 'permissions') final Map<String, dynamic>? permissions,
|
||||
@JsonKey(name: 'is_active') final bool? isActive,
|
||||
@JsonKey(name: 'created_at') final String? createdAt,
|
||||
@JsonKey(name: 'updated_at') final String? updatedAt,
|
||||
}) = _$UserDtoImpl;
|
||||
const _UserDto._() : super._();
|
||||
|
||||
factory _UserDto.fromJson(Map<String, dynamic> json) = _$UserDtoImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'id')
|
||||
String? get id;
|
||||
@override
|
||||
@JsonKey(name: 'organization_id')
|
||||
String? get organizationId;
|
||||
@override
|
||||
@JsonKey(name: 'outlet_id')
|
||||
String? get outletId;
|
||||
@override
|
||||
@JsonKey(name: 'name')
|
||||
String? get name;
|
||||
@override
|
||||
@JsonKey(name: 'email')
|
||||
String? get email;
|
||||
@override
|
||||
@JsonKey(name: 'role')
|
||||
String? get role;
|
||||
@override
|
||||
@JsonKey(name: 'permissions')
|
||||
Map<String, dynamic>? get permissions;
|
||||
@override
|
||||
@JsonKey(name: 'is_active')
|
||||
bool? get isActive;
|
||||
@override
|
||||
@JsonKey(name: 'created_at')
|
||||
String? get createdAt;
|
||||
@override
|
||||
@JsonKey(name: 'updated_at')
|
||||
String? get updatedAt;
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
@@ -21,31 +21,3 @@ Map<String, dynamic> _$$AuthDtoImplToJson(_$AuthDtoImpl instance) =>
|
||||
'expires_at': instance.expiresAt,
|
||||
'user': instance.user,
|
||||
};
|
||||
|
||||
_$UserDtoImpl _$$UserDtoImplFromJson(Map<String, dynamic> json) =>
|
||||
_$UserDtoImpl(
|
||||
id: json['id'] as String?,
|
||||
organizationId: json['organization_id'] as String?,
|
||||
outletId: json['outlet_id'] as String?,
|
||||
name: json['name'] as String?,
|
||||
email: json['email'] as String?,
|
||||
role: json['role'] as String?,
|
||||
permissions: json['permissions'] as Map<String, dynamic>?,
|
||||
isActive: json['is_active'] as bool?,
|
||||
createdAt: json['created_at'] as String?,
|
||||
updatedAt: json['updated_at'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$UserDtoImplToJson(_$UserDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'organization_id': instance.organizationId,
|
||||
'outlet_id': instance.outletId,
|
||||
'name': instance.name,
|
||||
'email': instance.email,
|
||||
'role': instance.role,
|
||||
'permissions': instance.permissions,
|
||||
'is_active': instance.isActive,
|
||||
'created_at': instance.createdAt,
|
||||
'updated_at': instance.updatedAt,
|
||||
};
|
||||
|
||||
@@ -5,8 +5,8 @@ import 'package:injectable/injectable.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../common/constant/local_storage_key.dart';
|
||||
import '../../../domain/auth/auth.dart';
|
||||
import '../auth_dtos.dart';
|
||||
import '../../../domain/user/user.dart';
|
||||
import '../../user/user_dtos.dart';
|
||||
|
||||
@injectable
|
||||
class AuthLocalDataProvider {
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/auth/auth.dart';
|
||||
import '../../../domain/user/user.dart';
|
||||
import '../datasources/local_data_provider.dart';
|
||||
import '../datasources/remote_data_provider.dart';
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:data_channel/data_channel.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../common/api/api_client.dart';
|
||||
import '../../../common/api/api_failure.dart';
|
||||
import '../../../common/function/app_function.dart';
|
||||
import '../../../common/url/api_path.dart';
|
||||
import '../../../domain/user/user.dart';
|
||||
import '../user_dtos.dart';
|
||||
|
||||
@injectable
|
||||
class UserRemoteDataProvider {
|
||||
final ApiClient _apiClient;
|
||||
|
||||
static const _logName = 'UserRemoteDataProvider';
|
||||
|
||||
UserRemoteDataProvider(this._apiClient);
|
||||
|
||||
Future<DC<UserFailure, UserDto>> updateUser({
|
||||
required String name,
|
||||
required String userId,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _apiClient.put(
|
||||
'${ApiPath.user}/$userId',
|
||||
data: {'name': name, 'is_active': true},
|
||||
headers: getAuthorizationHeader(),
|
||||
);
|
||||
|
||||
if (response.statusCode == 400) {
|
||||
return DC.error(UserFailure.unexpectedError());
|
||||
}
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
return DC.error(
|
||||
UserFailure.dynamicErrorMessage(response.data['message']),
|
||||
);
|
||||
}
|
||||
|
||||
final dto = UserDto.fromJson(response.data);
|
||||
|
||||
return DC.data(dto);
|
||||
} on ApiFailure catch (e, s) {
|
||||
log('updateUser', name: _logName, error: e, stackTrace: s);
|
||||
return DC.error(UserFailure.serverError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
part of '../auth_dtos.dart';
|
||||
part of '../user_dtos.dart';
|
||||
|
||||
@freezed
|
||||
class UserDto with _$UserDto {
|
||||
@@ -0,0 +1,42 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/user/user.dart';
|
||||
import '../../auth/datasources/local_data_provider.dart';
|
||||
import '../datasource/remote_data_provider.dart';
|
||||
|
||||
@Injectable(as: IUserRepository)
|
||||
class UserRepository implements IUserRepository {
|
||||
final UserRemoteDataProvider _dataProvider;
|
||||
final AuthLocalDataProvider _authLocalDataProvider;
|
||||
|
||||
final String _logName = 'UserRepository';
|
||||
|
||||
UserRepository(this._dataProvider, this._authLocalDataProvider);
|
||||
|
||||
@override
|
||||
Future<Either<UserFailure, User>> editUser({required String name}) async {
|
||||
try {
|
||||
User currentUser = await _authLocalDataProvider.currentUser();
|
||||
final result = await _dataProvider.updateUser(
|
||||
name: name,
|
||||
userId: currentUser.id,
|
||||
);
|
||||
|
||||
if (result.hasError) {
|
||||
return left(result.error!);
|
||||
}
|
||||
|
||||
final auth = result.data!.toDomain();
|
||||
|
||||
await _authLocalDataProvider.saveCurrentUser(result.data!);
|
||||
|
||||
return right(auth);
|
||||
} catch (e, s) {
|
||||
log('editUserError', name: _logName, error: e, stackTrace: s);
|
||||
return left(const UserFailure.unexpectedError());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../domain/user/user.dart';
|
||||
|
||||
part 'user_dtos.freezed.dart';
|
||||
part 'user_dtos.g.dart';
|
||||
|
||||
part 'dto/user_dto.dart';
|
||||
@@ -0,0 +1,414 @@
|
||||
// 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 'user_dtos.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',
|
||||
);
|
||||
|
||||
UserDto _$UserDtoFromJson(Map<String, dynamic> json) {
|
||||
return _UserDto.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UserDto {
|
||||
@JsonKey(name: 'id')
|
||||
String? get id => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'organization_id')
|
||||
String? get organizationId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'outlet_id')
|
||||
String? get outletId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'name')
|
||||
String? get name => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'email')
|
||||
String? get email => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'role')
|
||||
String? get role => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'permissions')
|
||||
Map<String, dynamic>? get permissions => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'is_active')
|
||||
bool? get isActive => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'created_at')
|
||||
String? get createdAt => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'updated_at')
|
||||
String? get updatedAt => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this UserDto to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$UserDtoCopyWith<UserDto> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UserDtoCopyWith<$Res> {
|
||||
factory $UserDtoCopyWith(UserDto value, $Res Function(UserDto) then) =
|
||||
_$UserDtoCopyWithImpl<$Res, UserDto>;
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'organization_id') String? organizationId,
|
||||
@JsonKey(name: 'outlet_id') String? outletId,
|
||||
@JsonKey(name: 'name') String? name,
|
||||
@JsonKey(name: 'email') String? email,
|
||||
@JsonKey(name: 'role') String? role,
|
||||
@JsonKey(name: 'permissions') Map<String, dynamic>? permissions,
|
||||
@JsonKey(name: 'is_active') bool? isActive,
|
||||
@JsonKey(name: 'created_at') String? createdAt,
|
||||
@JsonKey(name: 'updated_at') String? updatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UserDtoCopyWithImpl<$Res, $Val extends UserDto>
|
||||
implements $UserDtoCopyWith<$Res> {
|
||||
_$UserDtoCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? organizationId = freezed,
|
||||
Object? outletId = freezed,
|
||||
Object? name = freezed,
|
||||
Object? email = freezed,
|
||||
Object? role = freezed,
|
||||
Object? permissions = freezed,
|
||||
Object? isActive = freezed,
|
||||
Object? createdAt = freezed,
|
||||
Object? updatedAt = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
organizationId: freezed == organizationId
|
||||
? _value.organizationId
|
||||
: organizationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
outletId: freezed == outletId
|
||||
? _value.outletId
|
||||
: outletId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
name: freezed == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
email: freezed == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
role: freezed == role
|
||||
? _value.role
|
||||
: role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
permissions: freezed == permissions
|
||||
? _value.permissions
|
||||
: permissions // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
isActive: freezed == isActive
|
||||
? _value.isActive
|
||||
: isActive // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
createdAt: freezed == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
updatedAt: freezed == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UserDtoImplCopyWith<$Res> implements $UserDtoCopyWith<$Res> {
|
||||
factory _$$UserDtoImplCopyWith(
|
||||
_$UserDtoImpl value,
|
||||
$Res Function(_$UserDtoImpl) then,
|
||||
) = __$$UserDtoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'organization_id') String? organizationId,
|
||||
@JsonKey(name: 'outlet_id') String? outletId,
|
||||
@JsonKey(name: 'name') String? name,
|
||||
@JsonKey(name: 'email') String? email,
|
||||
@JsonKey(name: 'role') String? role,
|
||||
@JsonKey(name: 'permissions') Map<String, dynamic>? permissions,
|
||||
@JsonKey(name: 'is_active') bool? isActive,
|
||||
@JsonKey(name: 'created_at') String? createdAt,
|
||||
@JsonKey(name: 'updated_at') String? updatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UserDtoImplCopyWithImpl<$Res>
|
||||
extends _$UserDtoCopyWithImpl<$Res, _$UserDtoImpl>
|
||||
implements _$$UserDtoImplCopyWith<$Res> {
|
||||
__$$UserDtoImplCopyWithImpl(
|
||||
_$UserDtoImpl _value,
|
||||
$Res Function(_$UserDtoImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? organizationId = freezed,
|
||||
Object? outletId = freezed,
|
||||
Object? name = freezed,
|
||||
Object? email = freezed,
|
||||
Object? role = freezed,
|
||||
Object? permissions = freezed,
|
||||
Object? isActive = freezed,
|
||||
Object? createdAt = freezed,
|
||||
Object? updatedAt = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$UserDtoImpl(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
organizationId: freezed == organizationId
|
||||
? _value.organizationId
|
||||
: organizationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
outletId: freezed == outletId
|
||||
? _value.outletId
|
||||
: outletId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
name: freezed == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
email: freezed == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
role: freezed == role
|
||||
? _value.role
|
||||
: role // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
permissions: freezed == permissions
|
||||
? _value._permissions
|
||||
: permissions // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
isActive: freezed == isActive
|
||||
? _value.isActive
|
||||
: isActive // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
createdAt: freezed == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
updatedAt: freezed == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$UserDtoImpl extends _UserDto {
|
||||
const _$UserDtoImpl({
|
||||
@JsonKey(name: 'id') this.id,
|
||||
@JsonKey(name: 'organization_id') this.organizationId,
|
||||
@JsonKey(name: 'outlet_id') this.outletId,
|
||||
@JsonKey(name: 'name') this.name,
|
||||
@JsonKey(name: 'email') this.email,
|
||||
@JsonKey(name: 'role') this.role,
|
||||
@JsonKey(name: 'permissions') final Map<String, dynamic>? permissions,
|
||||
@JsonKey(name: 'is_active') this.isActive,
|
||||
@JsonKey(name: 'created_at') this.createdAt,
|
||||
@JsonKey(name: 'updated_at') this.updatedAt,
|
||||
}) : _permissions = permissions,
|
||||
super._();
|
||||
|
||||
factory _$UserDtoImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$UserDtoImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'id')
|
||||
final String? id;
|
||||
@override
|
||||
@JsonKey(name: 'organization_id')
|
||||
final String? organizationId;
|
||||
@override
|
||||
@JsonKey(name: 'outlet_id')
|
||||
final String? outletId;
|
||||
@override
|
||||
@JsonKey(name: 'name')
|
||||
final String? name;
|
||||
@override
|
||||
@JsonKey(name: 'email')
|
||||
final String? email;
|
||||
@override
|
||||
@JsonKey(name: 'role')
|
||||
final String? role;
|
||||
final Map<String, dynamic>? _permissions;
|
||||
@override
|
||||
@JsonKey(name: 'permissions')
|
||||
Map<String, dynamic>? get permissions {
|
||||
final value = _permissions;
|
||||
if (value == null) return null;
|
||||
if (_permissions is EqualUnmodifiableMapView) return _permissions;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'is_active')
|
||||
final bool? isActive;
|
||||
@override
|
||||
@JsonKey(name: 'created_at')
|
||||
final String? createdAt;
|
||||
@override
|
||||
@JsonKey(name: 'updated_at')
|
||||
final String? updatedAt;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UserDto(id: $id, organizationId: $organizationId, outletId: $outletId, name: $name, email: $email, role: $role, permissions: $permissions, isActive: $isActive, createdAt: $createdAt, updatedAt: $updatedAt)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UserDtoImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.organizationId, organizationId) ||
|
||||
other.organizationId == organizationId) &&
|
||||
(identical(other.outletId, outletId) ||
|
||||
other.outletId == outletId) &&
|
||||
(identical(other.name, name) || other.name == name) &&
|
||||
(identical(other.email, email) || other.email == email) &&
|
||||
(identical(other.role, role) || other.role == role) &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other._permissions,
|
||||
_permissions,
|
||||
) &&
|
||||
(identical(other.isActive, isActive) ||
|
||||
other.isActive == isActive) &&
|
||||
(identical(other.createdAt, createdAt) ||
|
||||
other.createdAt == createdAt) &&
|
||||
(identical(other.updatedAt, updatedAt) ||
|
||||
other.updatedAt == updatedAt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
id,
|
||||
organizationId,
|
||||
outletId,
|
||||
name,
|
||||
email,
|
||||
role,
|
||||
const DeepCollectionEquality().hash(_permissions),
|
||||
isActive,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
);
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith =>
|
||||
__$$UserDtoImplCopyWithImpl<_$UserDtoImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$UserDtoImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _UserDto extends UserDto {
|
||||
const factory _UserDto({
|
||||
@JsonKey(name: 'id') final String? id,
|
||||
@JsonKey(name: 'organization_id') final String? organizationId,
|
||||
@JsonKey(name: 'outlet_id') final String? outletId,
|
||||
@JsonKey(name: 'name') final String? name,
|
||||
@JsonKey(name: 'email') final String? email,
|
||||
@JsonKey(name: 'role') final String? role,
|
||||
@JsonKey(name: 'permissions') final Map<String, dynamic>? permissions,
|
||||
@JsonKey(name: 'is_active') final bool? isActive,
|
||||
@JsonKey(name: 'created_at') final String? createdAt,
|
||||
@JsonKey(name: 'updated_at') final String? updatedAt,
|
||||
}) = _$UserDtoImpl;
|
||||
const _UserDto._() : super._();
|
||||
|
||||
factory _UserDto.fromJson(Map<String, dynamic> json) = _$UserDtoImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'id')
|
||||
String? get id;
|
||||
@override
|
||||
@JsonKey(name: 'organization_id')
|
||||
String? get organizationId;
|
||||
@override
|
||||
@JsonKey(name: 'outlet_id')
|
||||
String? get outletId;
|
||||
@override
|
||||
@JsonKey(name: 'name')
|
||||
String? get name;
|
||||
@override
|
||||
@JsonKey(name: 'email')
|
||||
String? get email;
|
||||
@override
|
||||
@JsonKey(name: 'role')
|
||||
String? get role;
|
||||
@override
|
||||
@JsonKey(name: 'permissions')
|
||||
Map<String, dynamic>? get permissions;
|
||||
@override
|
||||
@JsonKey(name: 'is_active')
|
||||
bool? get isActive;
|
||||
@override
|
||||
@JsonKey(name: 'created_at')
|
||||
String? get createdAt;
|
||||
@override
|
||||
@JsonKey(name: 'updated_at')
|
||||
String? get updatedAt;
|
||||
|
||||
/// Create a copy of UserDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_dtos.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$UserDtoImpl _$$UserDtoImplFromJson(Map<String, dynamic> json) =>
|
||||
_$UserDtoImpl(
|
||||
id: json['id'] as String?,
|
||||
organizationId: json['organization_id'] as String?,
|
||||
outletId: json['outlet_id'] as String?,
|
||||
name: json['name'] as String?,
|
||||
email: json['email'] as String?,
|
||||
role: json['role'] as String?,
|
||||
permissions: json['permissions'] as Map<String, dynamic>?,
|
||||
isActive: json['is_active'] as bool?,
|
||||
createdAt: json['created_at'] as String?,
|
||||
updatedAt: json['updated_at'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$UserDtoImplToJson(_$UserDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'organization_id': instance.organizationId,
|
||||
'outlet_id': instance.outletId,
|
||||
'name': instance.name,
|
||||
'email': instance.email,
|
||||
'role': instance.role,
|
||||
'permissions': instance.permissions,
|
||||
'is_active': instance.isActive,
|
||||
'created_at': instance.createdAt,
|
||||
'updated_at': instance.updatedAt,
|
||||
};
|
||||
Reference in New Issue
Block a user