Skip to content

Commit

Permalink
Merge pull request #70 from poppingmoon/play-featured-pagination
Browse files Browse the repository at this point in the history
flash/featuredのページネーションに対応
  • Loading branch information
shiosyakeyakini-info authored Oct 14, 2024
2 parents 91d4c3f + 89a5875 commit afac1ef
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/misskey_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export 'src/data/federation/federation_show_instance_response.dart';
export 'src/data/federation/federation_users_request.dart';
export 'src/data/flash/flash_create_request.dart';
export 'src/data/flash/flash_delete_request.dart';
export 'src/data/flash/flash_featured_request.dart';
export 'src/data/flash/flash_like_request.dart';
export 'src/data/flash/flash_my_likes_request.dart';
export 'src/data/flash/flash_my_likes_response.dart';
Expand Down
15 changes: 15 additions & 0 deletions lib/src/data/flash/flash_featured_request.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'flash_featured_request.freezed.dart';
part 'flash_featured_request.g.dart';

@freezed
class FlashFeaturedRequest with _$FlashFeaturedRequest {
const factory FlashFeaturedRequest({
int? offset,
int? limit,
}) = _FlashFeaturedRequest;

factory FlashFeaturedRequest.fromJson(Map<String, Object?> json) =>
_$FlashFeaturedRequestFromJson(json);
}
171 changes: 171 additions & 0 deletions lib/src/data/flash/flash_featured_request.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// 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 'flash_featured_request.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');

FlashFeaturedRequest _$FlashFeaturedRequestFromJson(Map<String, dynamic> json) {
return _FlashFeaturedRequest.fromJson(json);
}

/// @nodoc
mixin _$FlashFeaturedRequest {
int? get offset => throw _privateConstructorUsedError;
int? get limit => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$FlashFeaturedRequestCopyWith<FlashFeaturedRequest> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $FlashFeaturedRequestCopyWith<$Res> {
factory $FlashFeaturedRequestCopyWith(FlashFeaturedRequest value,
$Res Function(FlashFeaturedRequest) then) =
_$FlashFeaturedRequestCopyWithImpl<$Res, FlashFeaturedRequest>;
@useResult
$Res call({int? offset, int? limit});
}

/// @nodoc
class _$FlashFeaturedRequestCopyWithImpl<$Res,
$Val extends FlashFeaturedRequest>
implements $FlashFeaturedRequestCopyWith<$Res> {
_$FlashFeaturedRequestCopyWithImpl(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? offset = freezed,
Object? limit = freezed,
}) {
return _then(_value.copyWith(
offset: freezed == offset
? _value.offset
: offset // ignore: cast_nullable_to_non_nullable
as int?,
limit: freezed == limit
? _value.limit
: limit // ignore: cast_nullable_to_non_nullable
as int?,
) as $Val);
}
}

/// @nodoc
abstract class _$$FlashFeaturedRequestImplCopyWith<$Res>
implements $FlashFeaturedRequestCopyWith<$Res> {
factory _$$FlashFeaturedRequestImplCopyWith(_$FlashFeaturedRequestImpl value,
$Res Function(_$FlashFeaturedRequestImpl) then) =
__$$FlashFeaturedRequestImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({int? offset, int? limit});
}

/// @nodoc
class __$$FlashFeaturedRequestImplCopyWithImpl<$Res>
extends _$FlashFeaturedRequestCopyWithImpl<$Res, _$FlashFeaturedRequestImpl>
implements _$$FlashFeaturedRequestImplCopyWith<$Res> {
__$$FlashFeaturedRequestImplCopyWithImpl(_$FlashFeaturedRequestImpl _value,
$Res Function(_$FlashFeaturedRequestImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? offset = freezed,
Object? limit = freezed,
}) {
return _then(_$FlashFeaturedRequestImpl(
offset: freezed == offset
? _value.offset
: offset // ignore: cast_nullable_to_non_nullable
as int?,
limit: freezed == limit
? _value.limit
: limit // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}

/// @nodoc
@JsonSerializable()
class _$FlashFeaturedRequestImpl implements _FlashFeaturedRequest {
const _$FlashFeaturedRequestImpl({this.offset, this.limit});

factory _$FlashFeaturedRequestImpl.fromJson(Map<String, dynamic> json) =>
_$$FlashFeaturedRequestImplFromJson(json);

@override
final int? offset;
@override
final int? limit;

@override
String toString() {
return 'FlashFeaturedRequest(offset: $offset, limit: $limit)';
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FlashFeaturedRequestImpl &&
(identical(other.offset, offset) || other.offset == offset) &&
(identical(other.limit, limit) || other.limit == limit));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, offset, limit);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$FlashFeaturedRequestImplCopyWith<_$FlashFeaturedRequestImpl>
get copyWith =>
__$$FlashFeaturedRequestImplCopyWithImpl<_$FlashFeaturedRequestImpl>(
this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$FlashFeaturedRequestImplToJson(
this,
);
}
}

abstract class _FlashFeaturedRequest implements FlashFeaturedRequest {
const factory _FlashFeaturedRequest({final int? offset, final int? limit}) =
_$FlashFeaturedRequestImpl;

factory _FlashFeaturedRequest.fromJson(Map<String, dynamic> json) =
_$FlashFeaturedRequestImpl.fromJson;

@override
int? get offset;
@override
int? get limit;
@override
@JsonKey(ignore: true)
_$$FlashFeaturedRequestImplCopyWith<_$FlashFeaturedRequestImpl>
get copyWith => throw _privateConstructorUsedError;
}
21 changes: 21 additions & 0 deletions lib/src/data/flash/flash_featured_request.g.dart

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

5 changes: 3 additions & 2 deletions lib/src/misskey_flash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ class MisskeyFlash {
}

/// 人気なPlayの一覧を取得します。
Future<Iterable<Flash>> featured() async {
final response = await _apiService.post<List>("flash/featured", {});
Future<Iterable<Flash>> featured(FlashFeaturedRequest request) async {
final response =
await _apiService.post<List>("flash/featured", request.toJson());
return response.map((e) => Flash.fromJson(e));
}

Expand Down
2 changes: 1 addition & 1 deletion test/misskey_flash_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main() async {
test("featured", () async {
final flash = await adminClient.createFlash();
await userClient.apiService.post("flash/like", {"flashId": flash.id});
final response = await userClient.flash.featured();
final response = await userClient.flash.featured(FlashFeaturedRequest());
expect(response.toList(), isNotEmpty);
});

Expand Down

0 comments on commit afac1ef

Please sign in to comment.