diff --git a/lib/model/user/user.dart b/lib/model/user/user.dart index 1d8cb1b..ac1cfeb 100644 --- a/lib/model/user/user.dart +++ b/lib/model/user/user.dart @@ -1,14 +1,21 @@ import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; + part 'user.freezed.dart'; + part 'user.g.dart'; @freezed abstract class User with _$User { const factory User({ @required String id, - @required String nickname -}) = _User; + @required @JsonKey(name: 'full_name') String fullName, + @required @JsonKey(name: 'display_name') String displayName, +// @required @JsonKey(name: 'technical_stack') List technicalStack + @required @JsonKey(name: 'github_account') String githubAccount, + @required @JsonKey(name: 'twitter_account') String twitterAccount, + @required @JsonKey(name: 'icon_url') String iconUrl, + }) = _User; - factory User.fromJson(Map json) => _$UserFromJson(json); -} \ No newline at end of file + factory User.fromJson(Map json) => _$UserFromJson(json); +} diff --git a/lib/model/user/user.freezed.dart b/lib/model/user/user.freezed.dart index ca33ef8..49fffe5 100644 --- a/lib/model/user/user.freezed.dart +++ b/lib/model/user/user.freezed.dart @@ -15,10 +15,20 @@ User _$UserFromJson(Map json) { class _$UserTearOff { const _$UserTearOff(); - _User call({@required String id, @required String nickname}) { + _User call( + {@required String id, + @required @JsonKey(name: 'full_name') String fullName, + @required @JsonKey(name: 'display_name') String displayName, + @required @JsonKey(name: 'github_account') String githubAccount, + @required @JsonKey(name: 'twitter_account') String twitterAccount, + @required @JsonKey(name: 'icon_url') String iconUrl}) { return _User( id: id, - nickname: nickname, + fullName: fullName, + displayName: displayName, + githubAccount: githubAccount, + twitterAccount: twitterAccount, + iconUrl: iconUrl, ); } } @@ -28,7 +38,16 @@ const $User = _$UserTearOff(); mixin _$User { String get id; - String get nickname; + @JsonKey(name: 'full_name') + String get fullName; + @JsonKey(name: 'display_name') + String get displayName; + @JsonKey(name: 'github_account') + String get githubAccount; + @JsonKey(name: 'twitter_account') + String get twitterAccount; + @JsonKey(name: 'icon_url') + String get iconUrl; Map toJson(); $UserCopyWith get copyWith; @@ -37,7 +56,13 @@ mixin _$User { abstract class $UserCopyWith<$Res> { factory $UserCopyWith(User value, $Res Function(User) then) = _$UserCopyWithImpl<$Res>; - $Res call({String id, String nickname}); + $Res call( + {String id, + @JsonKey(name: 'full_name') String fullName, + @JsonKey(name: 'display_name') String displayName, + @JsonKey(name: 'github_account') String githubAccount, + @JsonKey(name: 'twitter_account') String twitterAccount, + @JsonKey(name: 'icon_url') String iconUrl}); } class _$UserCopyWithImpl<$Res> implements $UserCopyWith<$Res> { @@ -50,11 +75,24 @@ class _$UserCopyWithImpl<$Res> implements $UserCopyWith<$Res> { @override $Res call({ Object id = freezed, - Object nickname = freezed, + Object fullName = freezed, + Object displayName = freezed, + Object githubAccount = freezed, + Object twitterAccount = freezed, + Object iconUrl = freezed, }) { return _then(_value.copyWith( id: id == freezed ? _value.id : id as String, - nickname: nickname == freezed ? _value.nickname : nickname as String, + fullName: fullName == freezed ? _value.fullName : fullName as String, + displayName: + displayName == freezed ? _value.displayName : displayName as String, + githubAccount: githubAccount == freezed + ? _value.githubAccount + : githubAccount as String, + twitterAccount: twitterAccount == freezed + ? _value.twitterAccount + : twitterAccount as String, + iconUrl: iconUrl == freezed ? _value.iconUrl : iconUrl as String, )); } } @@ -63,7 +101,13 @@ abstract class _$UserCopyWith<$Res> implements $UserCopyWith<$Res> { factory _$UserCopyWith(_User value, $Res Function(_User) then) = __$UserCopyWithImpl<$Res>; @override - $Res call({String id, String nickname}); + $Res call( + {String id, + @JsonKey(name: 'full_name') String fullName, + @JsonKey(name: 'display_name') String displayName, + @JsonKey(name: 'github_account') String githubAccount, + @JsonKey(name: 'twitter_account') String twitterAccount, + @JsonKey(name: 'icon_url') String iconUrl}); } class __$UserCopyWithImpl<$Res> extends _$UserCopyWithImpl<$Res> @@ -77,20 +121,43 @@ class __$UserCopyWithImpl<$Res> extends _$UserCopyWithImpl<$Res> @override $Res call({ Object id = freezed, - Object nickname = freezed, + Object fullName = freezed, + Object displayName = freezed, + Object githubAccount = freezed, + Object twitterAccount = freezed, + Object iconUrl = freezed, }) { return _then(_User( id: id == freezed ? _value.id : id as String, - nickname: nickname == freezed ? _value.nickname : nickname as String, + fullName: fullName == freezed ? _value.fullName : fullName as String, + displayName: + displayName == freezed ? _value.displayName : displayName as String, + githubAccount: githubAccount == freezed + ? _value.githubAccount + : githubAccount as String, + twitterAccount: twitterAccount == freezed + ? _value.twitterAccount + : twitterAccount as String, + iconUrl: iconUrl == freezed ? _value.iconUrl : iconUrl as String, )); } } @JsonSerializable() class _$_User with DiagnosticableTreeMixin implements _User { - const _$_User({@required this.id, @required this.nickname}) + const _$_User( + {@required this.id, + @required @JsonKey(name: 'full_name') this.fullName, + @required @JsonKey(name: 'display_name') this.displayName, + @required @JsonKey(name: 'github_account') this.githubAccount, + @required @JsonKey(name: 'twitter_account') this.twitterAccount, + @required @JsonKey(name: 'icon_url') this.iconUrl}) : assert(id != null), - assert(nickname != null); + assert(fullName != null), + assert(displayName != null), + assert(githubAccount != null), + assert(twitterAccount != null), + assert(iconUrl != null); factory _$_User.fromJson(Map json) => _$_$_UserFromJson(json); @@ -98,11 +165,24 @@ class _$_User with DiagnosticableTreeMixin implements _User { @override final String id; @override - final String nickname; + @JsonKey(name: 'full_name') + final String fullName; + @override + @JsonKey(name: 'display_name') + final String displayName; + @override + @JsonKey(name: 'github_account') + final String githubAccount; + @override + @JsonKey(name: 'twitter_account') + final String twitterAccount; + @override + @JsonKey(name: 'icon_url') + final String iconUrl; @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'User(id: $id, nickname: $nickname)'; + return 'User(id: $id, fullName: $fullName, displayName: $displayName, githubAccount: $githubAccount, twitterAccount: $twitterAccount, iconUrl: $iconUrl)'; } @override @@ -111,7 +191,11 @@ class _$_User with DiagnosticableTreeMixin implements _User { properties ..add(DiagnosticsProperty('type', 'User')) ..add(DiagnosticsProperty('id', id)) - ..add(DiagnosticsProperty('nickname', nickname)); + ..add(DiagnosticsProperty('fullName', fullName)) + ..add(DiagnosticsProperty('displayName', displayName)) + ..add(DiagnosticsProperty('githubAccount', githubAccount)) + ..add(DiagnosticsProperty('twitterAccount', twitterAccount)) + ..add(DiagnosticsProperty('iconUrl', iconUrl)); } @override @@ -120,16 +204,31 @@ class _$_User with DiagnosticableTreeMixin implements _User { (other is _User && (identical(other.id, id) || const DeepCollectionEquality().equals(other.id, id)) && - (identical(other.nickname, nickname) || + (identical(other.fullName, fullName) || + const DeepCollectionEquality() + .equals(other.fullName, fullName)) && + (identical(other.displayName, displayName) || + const DeepCollectionEquality() + .equals(other.displayName, displayName)) && + (identical(other.githubAccount, githubAccount) || const DeepCollectionEquality() - .equals(other.nickname, nickname))); + .equals(other.githubAccount, githubAccount)) && + (identical(other.twitterAccount, twitterAccount) || + const DeepCollectionEquality() + .equals(other.twitterAccount, twitterAccount)) && + (identical(other.iconUrl, iconUrl) || + const DeepCollectionEquality().equals(other.iconUrl, iconUrl))); } @override int get hashCode => runtimeType.hashCode ^ const DeepCollectionEquality().hash(id) ^ - const DeepCollectionEquality().hash(nickname); + const DeepCollectionEquality().hash(fullName) ^ + const DeepCollectionEquality().hash(displayName) ^ + const DeepCollectionEquality().hash(githubAccount) ^ + const DeepCollectionEquality().hash(twitterAccount) ^ + const DeepCollectionEquality().hash(iconUrl); @override _$UserCopyWith<_User> get copyWith => @@ -142,15 +241,33 @@ class _$_User with DiagnosticableTreeMixin implements _User { } abstract class _User implements User { - const factory _User({@required String id, @required String nickname}) = - _$_User; + const factory _User( + {@required String id, + @required @JsonKey(name: 'full_name') String fullName, + @required @JsonKey(name: 'display_name') String displayName, + @required @JsonKey(name: 'github_account') String githubAccount, + @required @JsonKey(name: 'twitter_account') String twitterAccount, + @required @JsonKey(name: 'icon_url') String iconUrl}) = _$_User; factory _User.fromJson(Map json) = _$_User.fromJson; @override String get id; @override - String get nickname; + @JsonKey(name: 'full_name') + String get fullName; + @override + @JsonKey(name: 'display_name') + String get displayName; + @override + @JsonKey(name: 'github_account') + String get githubAccount; + @override + @JsonKey(name: 'twitter_account') + String get twitterAccount; + @override + @JsonKey(name: 'icon_url') + String get iconUrl; @override _$UserCopyWith<_User> get copyWith; } diff --git a/lib/model/user/user.g.dart b/lib/model/user/user.g.dart index beccefd..8dfe9fa 100644 --- a/lib/model/user/user.g.dart +++ b/lib/model/user/user.g.dart @@ -9,11 +9,19 @@ part of 'user.dart'; _$_User _$_$_UserFromJson(Map json) { return _$_User( id: json['id'] as String, - nickname: json['nickname'] as String, + fullName: json['full_name'] as String, + displayName: json['display_name'] as String, + githubAccount: json['github_account'] as String, + twitterAccount: json['twitter_account'] as String, + iconUrl: json['icon_url'] as String, ); } Map _$_$_UserToJson(_$_User instance) => { 'id': instance.id, - 'nickname': instance.nickname, + 'full_name': instance.fullName, + 'display_name': instance.displayName, + 'github_account': instance.githubAccount, + 'twitter_account': instance.twitterAccount, + 'icon_url': instance.iconUrl, };