Skip to content

Commit

Permalink
レスポンスの型を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
shiosyakeyakini-info committed Jan 28, 2024
1 parent 1357ec7 commit bc82ac4
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/misskey_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, Object?> json) =>
_$UsersGetFrequentlyRepliedUsersResponseFromJson(json);
}
Original file line number Diff line number Diff line change
@@ -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>(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<String, dynamic> json) {
return _UsersGetFrequentlyRepliedUsersResponse.fromJson(json);
}

/// @nodoc
mixin _$UsersGetFrequentlyRepliedUsersResponse {
User get user => throw _privateConstructorUsedError;
double get weight => throw _privateConstructorUsedError;

Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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<String, dynamic> json) =
_$UsersGetFrequentlyRepliedUsersResponseImpl.fromJson;

@override
User get user;
@override
double get weight;
@override
@JsonKey(ignore: true)
_$$UsersGetFrequentlyRepliedUsersResponseImplCopyWith<
_$UsersGetFrequentlyRepliedUsersResponseImpl>
get copyWith => throw _privateConstructorUsedError;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions lib/src/misskey_users.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -85,12 +86,14 @@ class MisskeyUsers {
}

/// 対象のユーザーがよくリプライを送る相手を返します。
Future<Iterable<User>> getFrequentlyRepliedUsers(
Future<Iterable<UsersGetFrequentlyRepliedUsersResponse>>
getFrequentlyRepliedUsers(
UsersGetFrequentlyRepliedUsersRequest request,
) async {
final response = await _apiService.post<List>(
"users/get-frequently-replied-users", request.toJson());
return response.map((e) => User.fromJson(e));
return response
.map((e) => UsersGetFrequentlyRepliedUsersResponse.fromJson(e));
}

/// このAPIは必ずエラーを返し、動作していないようです。
Expand Down

0 comments on commit bc82ac4

Please sign in to comment.