Regenerate bindings for comments.

This commit is contained in:
Kavin 2022-06-25 10:55:47 +01:00
parent 70f4ecc760
commit abb6f6e71c
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
15 changed files with 1092 additions and 0 deletions

View file

@ -2,6 +2,8 @@
README.md
analysis_options.yaml
doc/ChannelInfo.md
doc/Comment.md
doc/CommentsPage.md
doc/ExceptionError.md
doc/Regions.md
doc/Stream.md
@ -21,6 +23,8 @@ lib/src/auth/bearer_auth.dart
lib/src/auth/oauth.dart
lib/src/date_serializer.dart
lib/src/model/channel_info.dart
lib/src/model/comment.dart
lib/src/model/comments_page.dart
lib/src/model/date.dart
lib/src/model/exception_error.dart
lib/src/model/regions.dart
@ -31,3 +35,5 @@ lib/src/model/subtitle.dart
lib/src/model/video_info.dart
lib/src/serializers.dart
pubspec.yaml
test/comment_test.dart
test/comments_page_test.dart

View file

@ -69,6 +69,8 @@ Class | Method | HTTP request | Description
[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelInfoName**](doc/UnauthenticatedApi.md#channelinfoname) | **GET** /c/{name} | Gets Channel Information
[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelInfoUsername**](doc/UnauthenticatedApi.md#channelinfousername) | **GET** /user/{username} | Gets Channel Information
[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelNextPage**](doc/UnauthenticatedApi.md#channelnextpage) | **GET** /nextpage/channel/{channelId} | Gets more channel videos
[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**comments**](doc/UnauthenticatedApi.md#comments) | **GET** /comments/{videoId} | Gets Comments
[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**commentsNextPage**](doc/UnauthenticatedApi.md#commentsnextpage) | **GET** /nextpage/comments/{videoId} | Gets more comments
[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**streamInfo**](doc/UnauthenticatedApi.md#streaminfo) | **GET** /streams/{videoId} | Gets Video Information
[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**trending**](doc/UnauthenticatedApi.md#trending) | **GET** /trending | Gets all Trending Videos
@ -76,6 +78,8 @@ Class | Method | HTTP request | Description
## Documentation For Models
- [ChannelInfo](doc/ChannelInfo.md)
- [Comment](doc/Comment.md)
- [CommentsPage](doc/CommentsPage.md)
- [ExceptionError](doc/ExceptionError.md)
- [Regions](doc/Regions.md)
- [Stream](doc/Stream.md)

25
doc/Comment.md Normal file
View file

@ -0,0 +1,25 @@
# piped_api.model.Comment
## Load the model package
```dart
import 'package:piped_api/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**author** | **String** | The name of the author of the comment. | [optional]
**thumbnail** | **String** | The thumbnail/avatar of the author of the comment. | [optional]
**commentId** | **String** | The ID of the comment. | [optional]
**commentText** | **String** | The text of the comment. | [optional]
**commentedTime** | **String** | The relative time the comment was made. | [optional]
**commentorUrl** | **String** | The relative URL of the author of the comment. | [optional]
**repliesPage** | **String** | The parameter used as the nextpage to fetch replies for this comment. | [optional]
**likeCount** | **int** | The number of likes the comment has. | [optional]
**hearted** | **bool** | Whether the comment was hearted by the video's uploader. | [optional]
**pinned** | **bool** | Whether the comment was pinned by the video's uploader. | [optional]
**verified** | **bool** | Whether the author of the comment is verified. | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

17
doc/CommentsPage.md Normal file
View file

@ -0,0 +1,17 @@
# piped_api.model.CommentsPage
## Load the model package
```dart
import 'package:piped_api/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**comments** | [**BuiltList<Comment>**](Comment.md) | | [optional]
**nextpage** | **String** | The parameter used to get the next page of comments. | [optional]
**disabled** | **bool** | Whether or not comments are disabled on the video. | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View file

@ -13,6 +13,8 @@ Method | HTTP request | Description
[**channelInfoName**](UnauthenticatedApi.md#channelinfoname) | **GET** /c/{name} | Gets Channel Information
[**channelInfoUsername**](UnauthenticatedApi.md#channelinfousername) | **GET** /user/{username} | Gets Channel Information
[**channelNextPage**](UnauthenticatedApi.md#channelnextpage) | **GET** /nextpage/channel/{channelId} | Gets more channel videos
[**comments**](UnauthenticatedApi.md#comments) | **GET** /comments/{videoId} | Gets Comments
[**commentsNextPage**](UnauthenticatedApi.md#commentsnextpage) | **GET** /nextpage/comments/{videoId} | Gets more comments
[**streamInfo**](UnauthenticatedApi.md#streaminfo) | **GET** /streams/{videoId} | Gets Video Information
[**trending**](UnauthenticatedApi.md#trending) | **GET** /trending | Gets all Trending Videos
@ -191,6 +193,94 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **comments**
> CommentsPage comments(videoId)
Gets Comments
Gets the comments for a video.
### Example
```dart
import 'package:piped_api/api.dart';
final api = PipedApi().getUnauthenticatedApi();
final String videoId = dQw4w9WgXcQ; // String | The video ID of the YouTube video you want to get comments from.
try {
final response = api.comments(videoId);
print(response);
} catch on DioError (e) {
print('Exception when calling UnauthenticatedApi->comments: $e\n');
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**videoId** | **String**| The video ID of the YouTube video you want to get comments from. |
### Return type
[**CommentsPage**](CommentsPage.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **commentsNextPage**
> CommentsPage commentsNextPage(videoId, nextpage)
Gets more comments
Gets more comments.
### Example
```dart
import 'package:piped_api/api.dart';
final api = PipedApi().getUnauthenticatedApi();
final String videoId = dQw4w9WgXcQ; // String | The video ID of the YouTube video you want to get more comments from.
final String nextpage = nextpage_example; // String | The next page token to get more comments from.
try {
final response = api.commentsNextPage(videoId, nextpage);
print(response);
} catch on DioError (e) {
print('Exception when calling UnauthenticatedApi->commentsNextPage: $e\n');
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**videoId** | **String**| The video ID of the YouTube video you want to get more comments from. |
**nextpage** | **String**| The next page token to get more comments from. |
### Return type
[**CommentsPage**](CommentsPage.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **streamInfo**
> VideoInfo streamInfo(videoId)

View file

@ -12,6 +12,8 @@ export 'package:piped_api/src/model/date.dart';
export 'package:piped_api/src/api/unauthenticated_api.dart';
export 'package:piped_api/src/model/channel_info.dart';
export 'package:piped_api/src/model/comment.dart';
export 'package:piped_api/src/model/comments_page.dart';
export 'package:piped_api/src/model/exception_error.dart';
export 'package:piped_api/src/model/regions.dart';
export 'package:piped_api/src/model/stream.dart';

View file

@ -10,6 +10,7 @@ import 'package:dio/dio.dart';
import 'package:built_collection/built_collection.dart';
import 'package:piped_api/src/api_util.dart';
import 'package:piped_api/src/model/channel_info.dart';
import 'package:piped_api/src/model/comments_page.dart';
import 'package:piped_api/src/model/exception_error.dart';
import 'package:piped_api/src/model/regions.dart';
import 'package:piped_api/src/model/stream_item.dart';
@ -327,6 +328,161 @@ class UnauthenticatedApi {
);
}
/// Gets Comments
/// Gets the comments for a video.
///
/// Parameters:
/// * [videoId] - The video ID of the YouTube video you want to get comments from.
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
/// * [headers] - Can be used to add additional headers to the request
/// * [extras] - Can be used to add flags to the request
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
///
/// Returns a [Future] containing a [Response] with a [CommentsPage] as data
/// Throws [DioError] if API call or serialization fails
Future<Response<CommentsPage>> comments({
required String videoId,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/comments/{videoId}'.replaceAll('{' r'videoId' '}', videoId.toString());
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_path,
options: _options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
CommentsPage _responseData;
try {
const _responseType = FullType(CommentsPage);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as CommentsPage;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<CommentsPage>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
/// Gets more comments
/// Gets more comments.
///
/// Parameters:
/// * [videoId] - The video ID of the YouTube video you want to get more comments from.
/// * [nextpage] - The next page token to get more comments from.
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
/// * [headers] - Can be used to add additional headers to the request
/// * [extras] - Can be used to add flags to the request
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
///
/// Returns a [Future] containing a [Response] with a [CommentsPage] as data
/// Throws [DioError] if API call or serialization fails
Future<Response<CommentsPage>> commentsNextPage({
required String videoId,
required String nextpage,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/nextpage/comments/{videoId}'.replaceAll('{' r'videoId' '}', videoId.toString());
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
r'nextpage': encodeQueryParameter(_serializers, nextpage, const FullType(String)),
};
final _response = await _dio.request<Object>(
_path,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
CommentsPage _responseData;
try {
const _responseType = FullType(CommentsPage);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as CommentsPage;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<CommentsPage>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
/// Gets Video Information
/// Gets all available Stream information about a video.
///

232
lib/src/model/comment.dart Normal file
View file

@ -0,0 +1,232 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'comment.g.dart';
/// Comment
///
/// Properties:
/// * [author] - The name of the author of the comment.
/// * [thumbnail] - The thumbnail/avatar of the author of the comment.
/// * [commentId] - The ID of the comment.
/// * [commentText] - The text of the comment.
/// * [commentedTime] - The relative time the comment was made.
/// * [commentorUrl] - The relative URL of the author of the comment.
/// * [repliesPage] - The parameter used as the nextpage to fetch replies for this comment.
/// * [likeCount] - The number of likes the comment has.
/// * [hearted] - Whether the comment was hearted by the video's uploader.
/// * [pinned] - Whether the comment was pinned by the video's uploader.
/// * [verified] - Whether the author of the comment is verified.
abstract class Comment implements Built<Comment, CommentBuilder> {
/// The name of the author of the comment.
@BuiltValueField(wireName: r'author')
String? get author;
/// The thumbnail/avatar of the author of the comment.
@BuiltValueField(wireName: r'thumbnail')
String? get thumbnail;
/// The ID of the comment.
@BuiltValueField(wireName: r'commentId')
String? get commentId;
/// The text of the comment.
@BuiltValueField(wireName: r'commentText')
String? get commentText;
/// The relative time the comment was made.
@BuiltValueField(wireName: r'commentedTime')
String? get commentedTime;
/// The relative URL of the author of the comment.
@BuiltValueField(wireName: r'commentorUrl')
String? get commentorUrl;
/// The parameter used as the nextpage to fetch replies for this comment.
@BuiltValueField(wireName: r'repliesPage')
String? get repliesPage;
/// The number of likes the comment has.
@BuiltValueField(wireName: r'likeCount')
int? get likeCount;
/// Whether the comment was hearted by the video's uploader.
@BuiltValueField(wireName: r'hearted')
bool? get hearted;
/// Whether the comment was pinned by the video's uploader.
@BuiltValueField(wireName: r'pinned')
bool? get pinned;
/// Whether the author of the comment is verified.
@BuiltValueField(wireName: r'verified')
bool? get verified;
Comment._();
@BuiltValueHook(initializeBuilder: true)
static void _defaults(CommentBuilder b) => b;
factory Comment([void updates(CommentBuilder b)]) = _$Comment;
@BuiltValueSerializer(custom: true)
static Serializer<Comment> get serializer => _$CommentSerializer();
}
class _$CommentSerializer implements StructuredSerializer<Comment> {
@override
final Iterable<Type> types = const [Comment, _$Comment];
@override
final String wireName = r'Comment';
@override
Iterable<Object?> serialize(Serializers serializers, Comment object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[];
if (object.author != null) {
result
..add(r'author')
..add(serializers.serialize(object.author,
specifiedType: const FullType(String)));
}
if (object.thumbnail != null) {
result
..add(r'thumbnail')
..add(serializers.serialize(object.thumbnail,
specifiedType: const FullType(String)));
}
if (object.commentId != null) {
result
..add(r'commentId')
..add(serializers.serialize(object.commentId,
specifiedType: const FullType(String)));
}
if (object.commentText != null) {
result
..add(r'commentText')
..add(serializers.serialize(object.commentText,
specifiedType: const FullType(String)));
}
if (object.commentedTime != null) {
result
..add(r'commentedTime')
..add(serializers.serialize(object.commentedTime,
specifiedType: const FullType(String)));
}
if (object.commentorUrl != null) {
result
..add(r'commentorUrl')
..add(serializers.serialize(object.commentorUrl,
specifiedType: const FullType(String)));
}
if (object.repliesPage != null) {
result
..add(r'repliesPage')
..add(serializers.serialize(object.repliesPage,
specifiedType: const FullType(String)));
}
if (object.likeCount != null) {
result
..add(r'likeCount')
..add(serializers.serialize(object.likeCount,
specifiedType: const FullType(int)));
}
if (object.hearted != null) {
result
..add(r'hearted')
..add(serializers.serialize(object.hearted,
specifiedType: const FullType(bool)));
}
if (object.pinned != null) {
result
..add(r'pinned')
..add(serializers.serialize(object.pinned,
specifiedType: const FullType(bool)));
}
if (object.verified != null) {
result
..add(r'verified')
..add(serializers.serialize(object.verified,
specifiedType: const FullType(bool)));
}
return result;
}
@override
Comment deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = CommentBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case r'author':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.author = valueDes;
break;
case r'thumbnail':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.thumbnail = valueDes;
break;
case r'commentId':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.commentId = valueDes;
break;
case r'commentText':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.commentText = valueDes;
break;
case r'commentedTime':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.commentedTime = valueDes;
break;
case r'commentorUrl':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.commentorUrl = valueDes;
break;
case r'repliesPage':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.repliesPage = valueDes;
break;
case r'likeCount':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.likeCount = valueDes;
break;
case r'hearted':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
result.hearted = valueDes;
break;
case r'pinned':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
result.pinned = valueDes;
break;
case r'verified':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
result.verified = valueDes;
break;
}
}
return result.build();
}
}

View file

@ -0,0 +1,218 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'comment.dart';
// **************************************************************************
// BuiltValueGenerator
// **************************************************************************
class _$Comment extends Comment {
@override
final String? author;
@override
final String? thumbnail;
@override
final String? commentId;
@override
final String? commentText;
@override
final String? commentedTime;
@override
final String? commentorUrl;
@override
final String? repliesPage;
@override
final int? likeCount;
@override
final bool? hearted;
@override
final bool? pinned;
@override
final bool? verified;
factory _$Comment([void Function(CommentBuilder)? updates]) =>
(new CommentBuilder()..update(updates)).build();
_$Comment._(
{this.author,
this.thumbnail,
this.commentId,
this.commentText,
this.commentedTime,
this.commentorUrl,
this.repliesPage,
this.likeCount,
this.hearted,
this.pinned,
this.verified})
: super._();
@override
Comment rebuild(void Function(CommentBuilder) updates) =>
(toBuilder()..update(updates)).build();
@override
CommentBuilder toBuilder() => new CommentBuilder()..replace(this);
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is Comment &&
author == other.author &&
thumbnail == other.thumbnail &&
commentId == other.commentId &&
commentText == other.commentText &&
commentedTime == other.commentedTime &&
commentorUrl == other.commentorUrl &&
repliesPage == other.repliesPage &&
likeCount == other.likeCount &&
hearted == other.hearted &&
pinned == other.pinned &&
verified == other.verified;
}
@override
int get hashCode {
return $jf($jc(
$jc(
$jc(
$jc(
$jc(
$jc(
$jc(
$jc(
$jc(
$jc($jc(0, author.hashCode),
thumbnail.hashCode),
commentId.hashCode),
commentText.hashCode),
commentedTime.hashCode),
commentorUrl.hashCode),
repliesPage.hashCode),
likeCount.hashCode),
hearted.hashCode),
pinned.hashCode),
verified.hashCode));
}
@override
String toString() {
return (newBuiltValueToStringHelper('Comment')
..add('author', author)
..add('thumbnail', thumbnail)
..add('commentId', commentId)
..add('commentText', commentText)
..add('commentedTime', commentedTime)
..add('commentorUrl', commentorUrl)
..add('repliesPage', repliesPage)
..add('likeCount', likeCount)
..add('hearted', hearted)
..add('pinned', pinned)
..add('verified', verified))
.toString();
}
}
class CommentBuilder implements Builder<Comment, CommentBuilder> {
_$Comment? _$v;
String? _author;
String? get author => _$this._author;
set author(String? author) => _$this._author = author;
String? _thumbnail;
String? get thumbnail => _$this._thumbnail;
set thumbnail(String? thumbnail) => _$this._thumbnail = thumbnail;
String? _commentId;
String? get commentId => _$this._commentId;
set commentId(String? commentId) => _$this._commentId = commentId;
String? _commentText;
String? get commentText => _$this._commentText;
set commentText(String? commentText) => _$this._commentText = commentText;
String? _commentedTime;
String? get commentedTime => _$this._commentedTime;
set commentedTime(String? commentedTime) =>
_$this._commentedTime = commentedTime;
String? _commentorUrl;
String? get commentorUrl => _$this._commentorUrl;
set commentorUrl(String? commentorUrl) => _$this._commentorUrl = commentorUrl;
String? _repliesPage;
String? get repliesPage => _$this._repliesPage;
set repliesPage(String? repliesPage) => _$this._repliesPage = repliesPage;
int? _likeCount;
int? get likeCount => _$this._likeCount;
set likeCount(int? likeCount) => _$this._likeCount = likeCount;
bool? _hearted;
bool? get hearted => _$this._hearted;
set hearted(bool? hearted) => _$this._hearted = hearted;
bool? _pinned;
bool? get pinned => _$this._pinned;
set pinned(bool? pinned) => _$this._pinned = pinned;
bool? _verified;
bool? get verified => _$this._verified;
set verified(bool? verified) => _$this._verified = verified;
CommentBuilder() {
Comment._defaults(this);
}
CommentBuilder get _$this {
final $v = _$v;
if ($v != null) {
_author = $v.author;
_thumbnail = $v.thumbnail;
_commentId = $v.commentId;
_commentText = $v.commentText;
_commentedTime = $v.commentedTime;
_commentorUrl = $v.commentorUrl;
_repliesPage = $v.repliesPage;
_likeCount = $v.likeCount;
_hearted = $v.hearted;
_pinned = $v.pinned;
_verified = $v.verified;
_$v = null;
}
return this;
}
@override
void replace(Comment other) {
ArgumentError.checkNotNull(other, 'other');
_$v = other as _$Comment;
}
@override
void update(void Function(CommentBuilder)? updates) {
if (updates != null) updates(this);
}
@override
_$Comment build() {
final _$result = _$v ??
new _$Comment._(
author: author,
thumbnail: thumbnail,
commentId: commentId,
commentText: commentText,
commentedTime: commentedTime,
commentorUrl: commentorUrl,
repliesPage: repliesPage,
likeCount: likeCount,
hearted: hearted,
pinned: pinned,
verified: verified);
replace(_$result);
return _$result;
}
}
// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new

View file

@ -0,0 +1,106 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:built_collection/built_collection.dart';
import 'package:piped_api/src/model/comment.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'comments_page.g.dart';
/// CommentsPage
///
/// Properties:
/// * [comments]
/// * [nextpage] - The parameter used to get the next page of comments.
/// * [disabled] - Whether or not comments are disabled on the video.
abstract class CommentsPage implements Built<CommentsPage, CommentsPageBuilder> {
@BuiltValueField(wireName: r'comments')
BuiltList<Comment>? get comments;
/// The parameter used to get the next page of comments.
@BuiltValueField(wireName: r'nextpage')
String? get nextpage;
/// Whether or not comments are disabled on the video.
@BuiltValueField(wireName: r'disabled')
bool? get disabled;
CommentsPage._();
@BuiltValueHook(initializeBuilder: true)
static void _defaults(CommentsPageBuilder b) => b;
factory CommentsPage([void updates(CommentsPageBuilder b)]) = _$CommentsPage;
@BuiltValueSerializer(custom: true)
static Serializer<CommentsPage> get serializer => _$CommentsPageSerializer();
}
class _$CommentsPageSerializer implements StructuredSerializer<CommentsPage> {
@override
final Iterable<Type> types = const [CommentsPage, _$CommentsPage];
@override
final String wireName = r'CommentsPage';
@override
Iterable<Object?> serialize(Serializers serializers, CommentsPage object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[];
if (object.comments != null) {
result
..add(r'comments')
..add(serializers.serialize(object.comments,
specifiedType: const FullType(BuiltList, [FullType(Comment)])));
}
if (object.nextpage != null) {
result
..add(r'nextpage')
..add(serializers.serialize(object.nextpage,
specifiedType: const FullType.nullable(String)));
}
if (object.disabled != null) {
result
..add(r'disabled')
..add(serializers.serialize(object.disabled,
specifiedType: const FullType(bool)));
}
return result;
}
@override
CommentsPage deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = CommentsPageBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case r'comments':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(BuiltList, [FullType(Comment)])) as BuiltList<Comment>;
result.comments.replace(valueDes);
break;
case r'nextpage':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType.nullable(String)) as String?;
if (valueDes == null) continue;
result.nextpage = valueDes;
break;
case r'disabled':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
result.disabled = valueDes;
break;
}
}
return result.build();
}
}

View file

@ -0,0 +1,122 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'comments_page.dart';
// **************************************************************************
// BuiltValueGenerator
// **************************************************************************
class _$CommentsPage extends CommentsPage {
@override
final BuiltList<Comment>? comments;
@override
final String? nextpage;
@override
final bool? disabled;
factory _$CommentsPage([void Function(CommentsPageBuilder)? updates]) =>
(new CommentsPageBuilder()..update(updates)).build();
_$CommentsPage._({this.comments, this.nextpage, this.disabled}) : super._();
@override
CommentsPage rebuild(void Function(CommentsPageBuilder) updates) =>
(toBuilder()..update(updates)).build();
@override
CommentsPageBuilder toBuilder() => new CommentsPageBuilder()..replace(this);
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is CommentsPage &&
comments == other.comments &&
nextpage == other.nextpage &&
disabled == other.disabled;
}
@override
int get hashCode {
return $jf($jc(
$jc($jc(0, comments.hashCode), nextpage.hashCode), disabled.hashCode));
}
@override
String toString() {
return (newBuiltValueToStringHelper('CommentsPage')
..add('comments', comments)
..add('nextpage', nextpage)
..add('disabled', disabled))
.toString();
}
}
class CommentsPageBuilder
implements Builder<CommentsPage, CommentsPageBuilder> {
_$CommentsPage? _$v;
ListBuilder<Comment>? _comments;
ListBuilder<Comment> get comments =>
_$this._comments ??= new ListBuilder<Comment>();
set comments(ListBuilder<Comment>? comments) => _$this._comments = comments;
String? _nextpage;
String? get nextpage => _$this._nextpage;
set nextpage(String? nextpage) => _$this._nextpage = nextpage;
bool? _disabled;
bool? get disabled => _$this._disabled;
set disabled(bool? disabled) => _$this._disabled = disabled;
CommentsPageBuilder() {
CommentsPage._defaults(this);
}
CommentsPageBuilder get _$this {
final $v = _$v;
if ($v != null) {
_comments = $v.comments?.toBuilder();
_nextpage = $v.nextpage;
_disabled = $v.disabled;
_$v = null;
}
return this;
}
@override
void replace(CommentsPage other) {
ArgumentError.checkNotNull(other, 'other');
_$v = other as _$CommentsPage;
}
@override
void update(void Function(CommentsPageBuilder)? updates) {
if (updates != null) updates(this);
}
@override
_$CommentsPage build() {
_$CommentsPage _$result;
try {
_$result = _$v ??
new _$CommentsPage._(
comments: _comments?.build(),
nextpage: nextpage,
disabled: disabled);
} catch (_) {
late String _$failedField;
try {
_$failedField = 'comments';
_comments?.build();
} catch (e) {
throw new BuiltValueNestedFieldError(
'CommentsPage', _$failedField, e.toString());
}
rethrow;
}
replace(_$result);
return _$result;
}
}
// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new

View file

@ -13,6 +13,8 @@ import 'package:piped_api/src/date_serializer.dart';
import 'package:piped_api/src/model/date.dart';
import 'package:piped_api/src/model/channel_info.dart';
import 'package:piped_api/src/model/comment.dart';
import 'package:piped_api/src/model/comments_page.dart';
import 'package:piped_api/src/model/exception_error.dart';
import 'package:piped_api/src/model/regions.dart';
import 'package:piped_api/src/model/stream.dart';
@ -25,6 +27,8 @@ part 'serializers.g.dart';
@SerializersFor([
ChannelInfo,
Comment,
CommentsPage,
ExceptionError,
Regions,
Stream,

View file

@ -8,6 +8,8 @@ part of 'serializers.dart';
Serializers _$serializers = (new Serializers().toBuilder()
..add(ChannelInfo.serializer)
..add(Comment.serializer)
..add(CommentsPage.serializer)
..add(ExceptionError.serializer)
..add(Regions.serializer)
..add(Stream.serializer)
@ -16,6 +18,9 @@ Serializers _$serializers = (new Serializers().toBuilder()
..add(StreamsPage.serializer)
..add(Subtitle.serializer)
..add(VideoInfo.serializer)
..addBuilderFactory(
const FullType(BuiltList, const [const FullType(Comment)]),
() => new ListBuilder<Comment>())
..addBuilderFactory(
const FullType(BuiltList, const [const FullType(Stream)]),
() => new ListBuilder<Stream>())

77
test/comment_test.dart Normal file
View file

@ -0,0 +1,77 @@
import 'package:test/test.dart';
import 'package:piped_api/piped_api.dart';
// tests for Comment
void main() {
final instance = CommentBuilder();
// TODO add properties to the builder and call build()
group(Comment, () {
// The name of the author of the comment.
// String author
test('to test the property `author`', () async {
// TODO
});
// The thumbnail/avatar of the author of the comment.
// String thumbnail
test('to test the property `thumbnail`', () async {
// TODO
});
// The ID of the comment.
// String commentId
test('to test the property `commentId`', () async {
// TODO
});
// The text of the comment.
// String commentText
test('to test the property `commentText`', () async {
// TODO
});
// The relative time the comment was made.
// String commentedTime
test('to test the property `commentedTime`', () async {
// TODO
});
// The relative URL of the author of the comment.
// String commentorUrl
test('to test the property `commentorUrl`', () async {
// TODO
});
// The parameter used as the nextpage to fetch replies for this comment.
// String repliesPage
test('to test the property `repliesPage`', () async {
// TODO
});
// The number of likes the comment has.
// int likeCount
test('to test the property `likeCount`', () async {
// TODO
});
// Whether the comment was hearted by the video's uploader.
// bool hearted
test('to test the property `hearted`', () async {
// TODO
});
// Whether the comment was pinned by the video's uploader.
// bool pinned
test('to test the property `pinned`', () async {
// TODO
});
// Whether the author of the comment is verified.
// bool verified
test('to test the property `verified`', () async {
// TODO
});
});
}

View file

@ -0,0 +1,28 @@
import 'package:test/test.dart';
import 'package:piped_api/piped_api.dart';
// tests for CommentsPage
void main() {
final instance = CommentsPageBuilder();
// TODO add properties to the builder and call build()
group(CommentsPage, () {
// BuiltList<Comment> comments
test('to test the property `comments`', () async {
// TODO
});
// The parameter used to get the next page of comments.
// String nextpage
test('to test the property `nextpage`', () async {
// TODO
});
// Whether or not comments are disabled on the video.
// bool disabled
test('to test the property `disabled`', () async {
// TODO
});
});
}