feat(profile): subscribers and subscriptions

This commit is contained in:
mso7nueh
2024-11-22 15:27:51 +03:00
parent f805505cb3
commit c909c75d47
45 changed files with 2790 additions and 451 deletions

View File

@@ -0,0 +1,38 @@
import 'package:eatvio_app/core/models/pagination_model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'sub_model.freezed.dart';
part 'sub_model.g.dart';
@freezed
class SubPaginationModel with _$SubPaginationModel {
const factory SubPaginationModel({
required List<SubModel> data,
required Links links,
required Meta meta,
}) = _SubPaginationModel;
factory SubPaginationModel.fromJson(Map<String, Object?> json) => _$SubPaginationModelFromJson(json);
}
@freezed
class SubModel with _$SubModel {
const factory SubModel({
required int id,
required String slug,
required String name,
required String city,
required DateTime birthdate,
@JsonKey(name: 'is_subscribe')
required bool isSubscribe,
required String email,
@JsonKey(name: 'profile_photo_url') required String profilePhotoUrl,
required String role,
@JsonKey(name: 'is_public_profile') required bool isPublicProfile,
@JsonKey(name: 'created_at') required DateTime createdAt,
@JsonKey(name: 'updated_at') required DateTime updatedAt,
}) = _SubModel;
factory SubModel.fromJson(Map<String, Object?> json) => _$SubModelFromJson(json);
}

View File

@@ -0,0 +1,646 @@
// 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 'sub_model.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');
SubPaginationModel _$SubPaginationModelFromJson(Map<String, dynamic> json) {
return _SubPaginationModel.fromJson(json);
}
/// @nodoc
mixin _$SubPaginationModel {
List<SubModel> get data => throw _privateConstructorUsedError;
Links get links => throw _privateConstructorUsedError;
Meta get meta => throw _privateConstructorUsedError;
/// Serializes this SubPaginationModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of SubPaginationModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$SubPaginationModelCopyWith<SubPaginationModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SubPaginationModelCopyWith<$Res> {
factory $SubPaginationModelCopyWith(
SubPaginationModel value, $Res Function(SubPaginationModel) then) =
_$SubPaginationModelCopyWithImpl<$Res, SubPaginationModel>;
@useResult
$Res call({List<SubModel> data, Links links, Meta meta});
$LinksCopyWith<$Res> get links;
$MetaCopyWith<$Res> get meta;
}
/// @nodoc
class _$SubPaginationModelCopyWithImpl<$Res, $Val extends SubPaginationModel>
implements $SubPaginationModelCopyWith<$Res> {
_$SubPaginationModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SubPaginationModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? data = null,
Object? links = null,
Object? meta = null,
}) {
return _then(_value.copyWith(
data: null == data
? _value.data
: data // ignore: cast_nullable_to_non_nullable
as List<SubModel>,
links: null == links
? _value.links
: links // ignore: cast_nullable_to_non_nullable
as Links,
meta: null == meta
? _value.meta
: meta // ignore: cast_nullable_to_non_nullable
as Meta,
) as $Val);
}
/// Create a copy of SubPaginationModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$LinksCopyWith<$Res> get links {
return $LinksCopyWith<$Res>(_value.links, (value) {
return _then(_value.copyWith(links: value) as $Val);
});
}
/// Create a copy of SubPaginationModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$MetaCopyWith<$Res> get meta {
return $MetaCopyWith<$Res>(_value.meta, (value) {
return _then(_value.copyWith(meta: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$SubPaginationModelImplCopyWith<$Res>
implements $SubPaginationModelCopyWith<$Res> {
factory _$$SubPaginationModelImplCopyWith(_$SubPaginationModelImpl value,
$Res Function(_$SubPaginationModelImpl) then) =
__$$SubPaginationModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({List<SubModel> data, Links links, Meta meta});
@override
$LinksCopyWith<$Res> get links;
@override
$MetaCopyWith<$Res> get meta;
}
/// @nodoc
class __$$SubPaginationModelImplCopyWithImpl<$Res>
extends _$SubPaginationModelCopyWithImpl<$Res, _$SubPaginationModelImpl>
implements _$$SubPaginationModelImplCopyWith<$Res> {
__$$SubPaginationModelImplCopyWithImpl(_$SubPaginationModelImpl _value,
$Res Function(_$SubPaginationModelImpl) _then)
: super(_value, _then);
/// Create a copy of SubPaginationModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? data = null,
Object? links = null,
Object? meta = null,
}) {
return _then(_$SubPaginationModelImpl(
data: null == data
? _value._data
: data // ignore: cast_nullable_to_non_nullable
as List<SubModel>,
links: null == links
? _value.links
: links // ignore: cast_nullable_to_non_nullable
as Links,
meta: null == meta
? _value.meta
: meta // ignore: cast_nullable_to_non_nullable
as Meta,
));
}
}
/// @nodoc
@JsonSerializable()
class _$SubPaginationModelImpl implements _SubPaginationModel {
const _$SubPaginationModelImpl(
{required final List<SubModel> data,
required this.links,
required this.meta})
: _data = data;
factory _$SubPaginationModelImpl.fromJson(Map<String, dynamic> json) =>
_$$SubPaginationModelImplFromJson(json);
final List<SubModel> _data;
@override
List<SubModel> get data {
if (_data is EqualUnmodifiableListView) return _data;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_data);
}
@override
final Links links;
@override
final Meta meta;
@override
String toString() {
return 'SubPaginationModel(data: $data, links: $links, meta: $meta)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SubPaginationModelImpl &&
const DeepCollectionEquality().equals(other._data, _data) &&
(identical(other.links, links) || other.links == links) &&
(identical(other.meta, meta) || other.meta == meta));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType, const DeepCollectionEquality().hash(_data), links, meta);
/// Create a copy of SubPaginationModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SubPaginationModelImplCopyWith<_$SubPaginationModelImpl> get copyWith =>
__$$SubPaginationModelImplCopyWithImpl<_$SubPaginationModelImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$SubPaginationModelImplToJson(
this,
);
}
}
abstract class _SubPaginationModel implements SubPaginationModel {
const factory _SubPaginationModel(
{required final List<SubModel> data,
required final Links links,
required final Meta meta}) = _$SubPaginationModelImpl;
factory _SubPaginationModel.fromJson(Map<String, dynamic> json) =
_$SubPaginationModelImpl.fromJson;
@override
List<SubModel> get data;
@override
Links get links;
@override
Meta get meta;
/// Create a copy of SubPaginationModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SubPaginationModelImplCopyWith<_$SubPaginationModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}
SubModel _$SubModelFromJson(Map<String, dynamic> json) {
return _SubModel.fromJson(json);
}
/// @nodoc
mixin _$SubModel {
int get id => throw _privateConstructorUsedError;
String get slug => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String get city => throw _privateConstructorUsedError;
DateTime get birthdate => throw _privateConstructorUsedError;
@JsonKey(name: 'is_subscribe')
bool get isSubscribe => throw _privateConstructorUsedError;
String get email => throw _privateConstructorUsedError;
@JsonKey(name: 'profile_photo_url')
String get profilePhotoUrl => throw _privateConstructorUsedError;
String get role => throw _privateConstructorUsedError;
@JsonKey(name: 'is_public_profile')
bool get isPublicProfile => throw _privateConstructorUsedError;
@JsonKey(name: 'created_at')
DateTime get createdAt => throw _privateConstructorUsedError;
@JsonKey(name: 'updated_at')
DateTime get updatedAt => throw _privateConstructorUsedError;
/// Serializes this SubModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of SubModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$SubModelCopyWith<SubModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SubModelCopyWith<$Res> {
factory $SubModelCopyWith(SubModel value, $Res Function(SubModel) then) =
_$SubModelCopyWithImpl<$Res, SubModel>;
@useResult
$Res call(
{int id,
String slug,
String name,
String city,
DateTime birthdate,
@JsonKey(name: 'is_subscribe') bool isSubscribe,
String email,
@JsonKey(name: 'profile_photo_url') String profilePhotoUrl,
String role,
@JsonKey(name: 'is_public_profile') bool isPublicProfile,
@JsonKey(name: 'created_at') DateTime createdAt,
@JsonKey(name: 'updated_at') DateTime updatedAt});
}
/// @nodoc
class _$SubModelCopyWithImpl<$Res, $Val extends SubModel>
implements $SubModelCopyWith<$Res> {
_$SubModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SubModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? slug = null,
Object? name = null,
Object? city = null,
Object? birthdate = null,
Object? isSubscribe = null,
Object? email = null,
Object? profilePhotoUrl = null,
Object? role = null,
Object? isPublicProfile = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
slug: null == slug
? _value.slug
: slug // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
city: null == city
? _value.city
: city // ignore: cast_nullable_to_non_nullable
as String,
birthdate: null == birthdate
? _value.birthdate
: birthdate // ignore: cast_nullable_to_non_nullable
as DateTime,
isSubscribe: null == isSubscribe
? _value.isSubscribe
: isSubscribe // ignore: cast_nullable_to_non_nullable
as bool,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
profilePhotoUrl: null == profilePhotoUrl
? _value.profilePhotoUrl
: profilePhotoUrl // ignore: cast_nullable_to_non_nullable
as String,
role: null == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String,
isPublicProfile: null == isPublicProfile
? _value.isPublicProfile
: isPublicProfile // ignore: cast_nullable_to_non_nullable
as bool,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
) as $Val);
}
}
/// @nodoc
abstract class _$$SubModelImplCopyWith<$Res>
implements $SubModelCopyWith<$Res> {
factory _$$SubModelImplCopyWith(
_$SubModelImpl value, $Res Function(_$SubModelImpl) then) =
__$$SubModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id,
String slug,
String name,
String city,
DateTime birthdate,
@JsonKey(name: 'is_subscribe') bool isSubscribe,
String email,
@JsonKey(name: 'profile_photo_url') String profilePhotoUrl,
String role,
@JsonKey(name: 'is_public_profile') bool isPublicProfile,
@JsonKey(name: 'created_at') DateTime createdAt,
@JsonKey(name: 'updated_at') DateTime updatedAt});
}
/// @nodoc
class __$$SubModelImplCopyWithImpl<$Res>
extends _$SubModelCopyWithImpl<$Res, _$SubModelImpl>
implements _$$SubModelImplCopyWith<$Res> {
__$$SubModelImplCopyWithImpl(
_$SubModelImpl _value, $Res Function(_$SubModelImpl) _then)
: super(_value, _then);
/// Create a copy of SubModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? slug = null,
Object? name = null,
Object? city = null,
Object? birthdate = null,
Object? isSubscribe = null,
Object? email = null,
Object? profilePhotoUrl = null,
Object? role = null,
Object? isPublicProfile = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(_$SubModelImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
slug: null == slug
? _value.slug
: slug // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
city: null == city
? _value.city
: city // ignore: cast_nullable_to_non_nullable
as String,
birthdate: null == birthdate
? _value.birthdate
: birthdate // ignore: cast_nullable_to_non_nullable
as DateTime,
isSubscribe: null == isSubscribe
? _value.isSubscribe
: isSubscribe // ignore: cast_nullable_to_non_nullable
as bool,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
profilePhotoUrl: null == profilePhotoUrl
? _value.profilePhotoUrl
: profilePhotoUrl // ignore: cast_nullable_to_non_nullable
as String,
role: null == role
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String,
isPublicProfile: null == isPublicProfile
? _value.isPublicProfile
: isPublicProfile // ignore: cast_nullable_to_non_nullable
as bool,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
));
}
}
/// @nodoc
@JsonSerializable()
class _$SubModelImpl implements _SubModel {
const _$SubModelImpl(
{required this.id,
required this.slug,
required this.name,
required this.city,
required this.birthdate,
@JsonKey(name: 'is_subscribe') required this.isSubscribe,
required this.email,
@JsonKey(name: 'profile_photo_url') required this.profilePhotoUrl,
required this.role,
@JsonKey(name: 'is_public_profile') required this.isPublicProfile,
@JsonKey(name: 'created_at') required this.createdAt,
@JsonKey(name: 'updated_at') required this.updatedAt});
factory _$SubModelImpl.fromJson(Map<String, dynamic> json) =>
_$$SubModelImplFromJson(json);
@override
final int id;
@override
final String slug;
@override
final String name;
@override
final String city;
@override
final DateTime birthdate;
@override
@JsonKey(name: 'is_subscribe')
final bool isSubscribe;
@override
final String email;
@override
@JsonKey(name: 'profile_photo_url')
final String profilePhotoUrl;
@override
final String role;
@override
@JsonKey(name: 'is_public_profile')
final bool isPublicProfile;
@override
@JsonKey(name: 'created_at')
final DateTime createdAt;
@override
@JsonKey(name: 'updated_at')
final DateTime updatedAt;
@override
String toString() {
return 'SubModel(id: $id, slug: $slug, name: $name, city: $city, birthdate: $birthdate, isSubscribe: $isSubscribe, email: $email, profilePhotoUrl: $profilePhotoUrl, role: $role, isPublicProfile: $isPublicProfile, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SubModelImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.slug, slug) || other.slug == slug) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.city, city) || other.city == city) &&
(identical(other.birthdate, birthdate) ||
other.birthdate == birthdate) &&
(identical(other.isSubscribe, isSubscribe) ||
other.isSubscribe == isSubscribe) &&
(identical(other.email, email) || other.email == email) &&
(identical(other.profilePhotoUrl, profilePhotoUrl) ||
other.profilePhotoUrl == profilePhotoUrl) &&
(identical(other.role, role) || other.role == role) &&
(identical(other.isPublicProfile, isPublicProfile) ||
other.isPublicProfile == isPublicProfile) &&
(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,
slug,
name,
city,
birthdate,
isSubscribe,
email,
profilePhotoUrl,
role,
isPublicProfile,
createdAt,
updatedAt);
/// Create a copy of SubModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SubModelImplCopyWith<_$SubModelImpl> get copyWith =>
__$$SubModelImplCopyWithImpl<_$SubModelImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$SubModelImplToJson(
this,
);
}
}
abstract class _SubModel implements SubModel {
const factory _SubModel(
{required final int id,
required final String slug,
required final String name,
required final String city,
required final DateTime birthdate,
@JsonKey(name: 'is_subscribe') required final bool isSubscribe,
required final String email,
@JsonKey(name: 'profile_photo_url') required final String profilePhotoUrl,
required final String role,
@JsonKey(name: 'is_public_profile') required final bool isPublicProfile,
@JsonKey(name: 'created_at') required final DateTime createdAt,
@JsonKey(name: 'updated_at')
required final DateTime updatedAt}) = _$SubModelImpl;
factory _SubModel.fromJson(Map<String, dynamic> json) =
_$SubModelImpl.fromJson;
@override
int get id;
@override
String get slug;
@override
String get name;
@override
String get city;
@override
DateTime get birthdate;
@override
@JsonKey(name: 'is_subscribe')
bool get isSubscribe;
@override
String get email;
@override
@JsonKey(name: 'profile_photo_url')
String get profilePhotoUrl;
@override
String get role;
@override
@JsonKey(name: 'is_public_profile')
bool get isPublicProfile;
@override
@JsonKey(name: 'created_at')
DateTime get createdAt;
@override
@JsonKey(name: 'updated_at')
DateTime get updatedAt;
/// Create a copy of SubModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SubModelImplCopyWith<_$SubModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,57 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'sub_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$SubPaginationModelImpl _$$SubPaginationModelImplFromJson(
Map<String, dynamic> json) =>
_$SubPaginationModelImpl(
data: (json['data'] as List<dynamic>)
.map((e) => SubModel.fromJson(e as Map<String, dynamic>))
.toList(),
links: Links.fromJson(json['links'] as Map<String, dynamic>),
meta: Meta.fromJson(json['meta'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$SubPaginationModelImplToJson(
_$SubPaginationModelImpl instance) =>
<String, dynamic>{
'data': instance.data,
'links': instance.links,
'meta': instance.meta,
};
_$SubModelImpl _$$SubModelImplFromJson(Map<String, dynamic> json) =>
_$SubModelImpl(
id: (json['id'] as num).toInt(),
slug: json['slug'] as String,
name: json['name'] as String,
city: json['city'] as String,
birthdate: DateTime.parse(json['birthdate'] as String),
isSubscribe: json['is_subscribe'] as bool,
email: json['email'] as String,
profilePhotoUrl: json['profile_photo_url'] as String,
role: json['role'] as String,
isPublicProfile: json['is_public_profile'] as bool,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
);
Map<String, dynamic> _$$SubModelImplToJson(_$SubModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'slug': instance.slug,
'name': instance.name,
'city': instance.city,
'birthdate': instance.birthdate.toIso8601String(),
'is_subscribe': instance.isSubscribe,
'email': instance.email,
'profile_photo_url': instance.profilePhotoUrl,
'role': instance.role,
'is_public_profile': instance.isPublicProfile,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
};