From bc82ac4e036beb1e9d1123e7c97d1b67885a8d19 Mon Sep 17 00:00:00 2001 From: sorairo Date: Sun, 28 Jan 2024 17:30:10 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AC=E3=82=B9=E3=83=9D=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=81=AE=E5=9E=8B=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/misskey_dart.dart | 1 + ...get_frequently_replied_users_response.dart | 18 ++ ...uently_replied_users_response.freezed.dart | 187 ++++++++++++++++++ ...t_frequently_replied_users_response.g.dart | 22 +++ lib/src/misskey_users.dart | 7 +- 5 files changed, 233 insertions(+), 2 deletions(-) create mode 100644 lib/src/data/users/users_get_frequently_replied_users_response.dart create mode 100644 lib/src/data/users/users_get_frequently_replied_users_response.freezed.dart create mode 100644 lib/src/data/users/users_get_frequently_replied_users_response.g.dart diff --git a/lib/misskey_dart.dart b/lib/misskey_dart.dart index aaee6810..83ce89d4 100644 --- a/lib/misskey_dart.dart +++ b/lib/misskey_dart.dart @@ -174,6 +174,7 @@ export 'src/data/users/users_users_request.dart'; export 'src/data/users/users_update_memo_request.dart'; export 'src/data/users/users_pages_request.dart'; export 'src/data/users/users_get_frequently_replied_users_request.dart'; +export 'src/data/users/users_get_frequently_replied_users_response.dart'; export 'src/data/block/block_create_request.dart'; export 'src/data/block/block_delete_request.dart'; export 'src/data/renote_mute/renote_mute_create_request.dart'; diff --git a/lib/src/data/users/users_get_frequently_replied_users_response.dart b/lib/src/data/users/users_get_frequently_replied_users_response.dart new file mode 100644 index 00000000..c049b655 --- /dev/null +++ b/lib/src/data/users/users_get_frequently_replied_users_response.dart @@ -0,0 +1,18 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:misskey_dart/misskey_dart.dart'; + +part 'users_get_frequently_replied_users_response.freezed.dart'; +part 'users_get_frequently_replied_users_response.g.dart'; + +@freezed +class UsersGetFrequentlyRepliedUsersResponse + with _$UsersGetFrequentlyRepliedUsersResponse { + const factory UsersGetFrequentlyRepliedUsersResponse({ + required User user, + required double weight, + }) = _UsersGetFrequentlyRepliedUsersResponse; + + factory UsersGetFrequentlyRepliedUsersResponse.fromJson( + Map json) => + _$UsersGetFrequentlyRepliedUsersResponseFromJson(json); +} diff --git a/lib/src/data/users/users_get_frequently_replied_users_response.freezed.dart b/lib/src/data/users/users_get_frequently_replied_users_response.freezed.dart new file mode 100644 index 00000000..cea04f94 --- /dev/null +++ b/lib/src/data/users/users_get_frequently_replied_users_response.freezed.dart @@ -0,0 +1,187 @@ +// 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 'users_get_frequently_replied_users_response.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(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#custom-getters-and-methods'); + +UsersGetFrequentlyRepliedUsersResponse + _$UsersGetFrequentlyRepliedUsersResponseFromJson( + Map json) { + return _UsersGetFrequentlyRepliedUsersResponse.fromJson(json); +} + +/// @nodoc +mixin _$UsersGetFrequentlyRepliedUsersResponse { + User get user => throw _privateConstructorUsedError; + double get weight => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $UsersGetFrequentlyRepliedUsersResponseCopyWith< + UsersGetFrequentlyRepliedUsersResponse> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $UsersGetFrequentlyRepliedUsersResponseCopyWith<$Res> { + factory $UsersGetFrequentlyRepliedUsersResponseCopyWith( + UsersGetFrequentlyRepliedUsersResponse value, + $Res Function(UsersGetFrequentlyRepliedUsersResponse) then) = + _$UsersGetFrequentlyRepliedUsersResponseCopyWithImpl<$Res, + UsersGetFrequentlyRepliedUsersResponse>; + @useResult + $Res call({User user, double weight}); +} + +/// @nodoc +class _$UsersGetFrequentlyRepliedUsersResponseCopyWithImpl<$Res, + $Val extends UsersGetFrequentlyRepliedUsersResponse> + implements $UsersGetFrequentlyRepliedUsersResponseCopyWith<$Res> { + _$UsersGetFrequentlyRepliedUsersResponseCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? user = null, + Object? weight = null, + }) { + return _then(_value.copyWith( + user: null == user + ? _value.user + : user // ignore: cast_nullable_to_non_nullable + as User, + weight: null == weight + ? _value.weight + : weight // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$UsersGetFrequentlyRepliedUsersResponseImplCopyWith<$Res> + implements $UsersGetFrequentlyRepliedUsersResponseCopyWith<$Res> { + factory _$$UsersGetFrequentlyRepliedUsersResponseImplCopyWith( + _$UsersGetFrequentlyRepliedUsersResponseImpl value, + $Res Function(_$UsersGetFrequentlyRepliedUsersResponseImpl) then) = + __$$UsersGetFrequentlyRepliedUsersResponseImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({User user, double weight}); +} + +/// @nodoc +class __$$UsersGetFrequentlyRepliedUsersResponseImplCopyWithImpl<$Res> + extends _$UsersGetFrequentlyRepliedUsersResponseCopyWithImpl<$Res, + _$UsersGetFrequentlyRepliedUsersResponseImpl> + implements _$$UsersGetFrequentlyRepliedUsersResponseImplCopyWith<$Res> { + __$$UsersGetFrequentlyRepliedUsersResponseImplCopyWithImpl( + _$UsersGetFrequentlyRepliedUsersResponseImpl _value, + $Res Function(_$UsersGetFrequentlyRepliedUsersResponseImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? user = null, + Object? weight = null, + }) { + return _then(_$UsersGetFrequentlyRepliedUsersResponseImpl( + user: null == user + ? _value.user + : user // ignore: cast_nullable_to_non_nullable + as User, + weight: null == weight + ? _value.weight + : weight // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$UsersGetFrequentlyRepliedUsersResponseImpl + implements _UsersGetFrequentlyRepliedUsersResponse { + const _$UsersGetFrequentlyRepliedUsersResponseImpl( + {required this.user, required this.weight}); + + factory _$UsersGetFrequentlyRepliedUsersResponseImpl.fromJson( + Map json) => + _$$UsersGetFrequentlyRepliedUsersResponseImplFromJson(json); + + @override + final User user; + @override + final double weight; + + @override + String toString() { + return 'UsersGetFrequentlyRepliedUsersResponse(user: $user, weight: $weight)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UsersGetFrequentlyRepliedUsersResponseImpl && + (identical(other.user, user) || other.user == user) && + (identical(other.weight, weight) || other.weight == weight)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, user, weight); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$UsersGetFrequentlyRepliedUsersResponseImplCopyWith< + _$UsersGetFrequentlyRepliedUsersResponseImpl> + get copyWith => + __$$UsersGetFrequentlyRepliedUsersResponseImplCopyWithImpl< + _$UsersGetFrequentlyRepliedUsersResponseImpl>(this, _$identity); + + @override + Map toJson() { + return _$$UsersGetFrequentlyRepliedUsersResponseImplToJson( + this, + ); + } +} + +abstract class _UsersGetFrequentlyRepliedUsersResponse + implements UsersGetFrequentlyRepliedUsersResponse { + const factory _UsersGetFrequentlyRepliedUsersResponse( + {required final User user, required final double weight}) = + _$UsersGetFrequentlyRepliedUsersResponseImpl; + + factory _UsersGetFrequentlyRepliedUsersResponse.fromJson( + Map json) = + _$UsersGetFrequentlyRepliedUsersResponseImpl.fromJson; + + @override + User get user; + @override + double get weight; + @override + @JsonKey(ignore: true) + _$$UsersGetFrequentlyRepliedUsersResponseImplCopyWith< + _$UsersGetFrequentlyRepliedUsersResponseImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/src/data/users/users_get_frequently_replied_users_response.g.dart b/lib/src/data/users/users_get_frequently_replied_users_response.g.dart new file mode 100644 index 00000000..0aa10f68 --- /dev/null +++ b/lib/src/data/users/users_get_frequently_replied_users_response.g.dart @@ -0,0 +1,22 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'users_get_frequently_replied_users_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$UsersGetFrequentlyRepliedUsersResponseImpl + _$$UsersGetFrequentlyRepliedUsersResponseImplFromJson( + Map json) => + _$UsersGetFrequentlyRepliedUsersResponseImpl( + user: User.fromJson(json['user'] as Map), + weight: (json['weight'] as num).toDouble(), + ); + +Map _$$UsersGetFrequentlyRepliedUsersResponseImplToJson( + _$UsersGetFrequentlyRepliedUsersResponseImpl instance) => + { + 'user': instance.user.toJson(), + 'weight': instance.weight, + }; diff --git a/lib/src/misskey_users.dart b/lib/src/misskey_users.dart index 6e1c454f..e0b5662d 100644 --- a/lib/src/misskey_users.dart +++ b/lib/src/misskey_users.dart @@ -1,5 +1,6 @@ import 'package:misskey_dart/misskey_dart.dart'; import 'package:misskey_dart/src/data/users/users_get_frequently_replied_users_request.dart'; +import 'package:misskey_dart/src/data/users/users_get_frequently_replied_users_response.dart'; import 'package:misskey_dart/src/services/api_service.dart'; class MisskeyUsers { @@ -85,12 +86,14 @@ class MisskeyUsers { } /// 対象のユーザーがよくリプライを送る相手を返します。 - Future> getFrequentlyRepliedUsers( + Future> + getFrequentlyRepliedUsers( UsersGetFrequentlyRepliedUsersRequest request, ) async { final response = await _apiService.post( "users/get-frequently-replied-users", request.toJson()); - return response.map((e) => User.fromJson(e)); + return response + .map((e) => UsersGetFrequentlyRepliedUsersResponse.fromJson(e)); } /// このAPIは必ずエラーを返し、動作していないようです。