402 lines
13 KiB
Dart
402 lines
13 KiB
Dart
|
//
|
||
|
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||
|
//
|
||
|
|
||
|
import 'dart:async';
|
||
|
|
||
|
import 'package:built_value/serializer.dart';
|
||
|
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/exception_error.dart';
|
||
|
import 'package:piped_api/src/model/regions.dart';
|
||
|
import 'package:piped_api/src/model/stream_item.dart';
|
||
|
import 'package:piped_api/src/model/video_info.dart';
|
||
|
|
||
|
class UnauthenticatedApi {
|
||
|
|
||
|
final Dio _dio;
|
||
|
|
||
|
final Serializers _serializers;
|
||
|
|
||
|
const UnauthenticatedApi(this._dio, this._serializers);
|
||
|
|
||
|
/// Gets Channel Information
|
||
|
/// Gets all available Channel information about a channel.
|
||
|
///
|
||
|
/// Parameters:
|
||
|
/// * [channelId] - The channel ID of the YouTube channel you want to get information about.
|
||
|
/// * [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 [ChannelInfo] as data
|
||
|
/// Throws [DioError] if API call or serialization fails
|
||
|
Future<Response<ChannelInfo>> channelInfoId({
|
||
|
required String channelId,
|
||
|
CancelToken? cancelToken,
|
||
|
Map<String, dynamic>? headers,
|
||
|
Map<String, dynamic>? extra,
|
||
|
ValidateStatus? validateStatus,
|
||
|
ProgressCallback? onSendProgress,
|
||
|
ProgressCallback? onReceiveProgress,
|
||
|
}) async {
|
||
|
final _path = r'/channel/{channelId}'.replaceAll('{' r'channelId' '}', channelId.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,
|
||
|
);
|
||
|
|
||
|
ChannelInfo _responseData;
|
||
|
|
||
|
try {
|
||
|
const _responseType = FullType(ChannelInfo);
|
||
|
_responseData = _serializers.deserialize(
|
||
|
_response.data!,
|
||
|
specifiedType: _responseType,
|
||
|
) as ChannelInfo;
|
||
|
|
||
|
} catch (error, stackTrace) {
|
||
|
throw DioError(
|
||
|
requestOptions: _response.requestOptions,
|
||
|
response: _response,
|
||
|
type: DioErrorType.other,
|
||
|
error: error,
|
||
|
)..stackTrace = stackTrace;
|
||
|
}
|
||
|
|
||
|
return Response<ChannelInfo>(
|
||
|
data: _responseData,
|
||
|
headers: _response.headers,
|
||
|
isRedirect: _response.isRedirect,
|
||
|
requestOptions: _response.requestOptions,
|
||
|
redirects: _response.redirects,
|
||
|
statusCode: _response.statusCode,
|
||
|
statusMessage: _response.statusMessage,
|
||
|
extra: _response.extra,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/// Gets Channel Information
|
||
|
/// Gets all available Channel information about a channel.
|
||
|
///
|
||
|
/// Parameters:
|
||
|
/// * [name] - The name of the YouTube channel you want to get information about.
|
||
|
/// * [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 [ChannelInfo] as data
|
||
|
/// Throws [DioError] if API call or serialization fails
|
||
|
Future<Response<ChannelInfo>> channelInfoName({
|
||
|
required String name,
|
||
|
CancelToken? cancelToken,
|
||
|
Map<String, dynamic>? headers,
|
||
|
Map<String, dynamic>? extra,
|
||
|
ValidateStatus? validateStatus,
|
||
|
ProgressCallback? onSendProgress,
|
||
|
ProgressCallback? onReceiveProgress,
|
||
|
}) async {
|
||
|
final _path = r'/c/{name}'.replaceAll('{' r'name' '}', name.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,
|
||
|
);
|
||
|
|
||
|
ChannelInfo _responseData;
|
||
|
|
||
|
try {
|
||
|
const _responseType = FullType(ChannelInfo);
|
||
|
_responseData = _serializers.deserialize(
|
||
|
_response.data!,
|
||
|
specifiedType: _responseType,
|
||
|
) as ChannelInfo;
|
||
|
|
||
|
} catch (error, stackTrace) {
|
||
|
throw DioError(
|
||
|
requestOptions: _response.requestOptions,
|
||
|
response: _response,
|
||
|
type: DioErrorType.other,
|
||
|
error: error,
|
||
|
)..stackTrace = stackTrace;
|
||
|
}
|
||
|
|
||
|
return Response<ChannelInfo>(
|
||
|
data: _responseData,
|
||
|
headers: _response.headers,
|
||
|
isRedirect: _response.isRedirect,
|
||
|
requestOptions: _response.requestOptions,
|
||
|
redirects: _response.redirects,
|
||
|
statusCode: _response.statusCode,
|
||
|
statusMessage: _response.statusMessage,
|
||
|
extra: _response.extra,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/// Gets Channel Information
|
||
|
/// Gets all available Channel information about a channel.
|
||
|
///
|
||
|
/// Parameters:
|
||
|
/// * [username] - The username of the YouTube channel you want to get information about.
|
||
|
/// * [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 [ChannelInfo] as data
|
||
|
/// Throws [DioError] if API call or serialization fails
|
||
|
Future<Response<ChannelInfo>> channelInfoUsername({
|
||
|
required String username,
|
||
|
CancelToken? cancelToken,
|
||
|
Map<String, dynamic>? headers,
|
||
|
Map<String, dynamic>? extra,
|
||
|
ValidateStatus? validateStatus,
|
||
|
ProgressCallback? onSendProgress,
|
||
|
ProgressCallback? onReceiveProgress,
|
||
|
}) async {
|
||
|
final _path = r'/user/{username}'.replaceAll('{' r'username' '}', username.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,
|
||
|
);
|
||
|
|
||
|
ChannelInfo _responseData;
|
||
|
|
||
|
try {
|
||
|
const _responseType = FullType(ChannelInfo);
|
||
|
_responseData = _serializers.deserialize(
|
||
|
_response.data!,
|
||
|
specifiedType: _responseType,
|
||
|
) as ChannelInfo;
|
||
|
|
||
|
} catch (error, stackTrace) {
|
||
|
throw DioError(
|
||
|
requestOptions: _response.requestOptions,
|
||
|
response: _response,
|
||
|
type: DioErrorType.other,
|
||
|
error: error,
|
||
|
)..stackTrace = stackTrace;
|
||
|
}
|
||
|
|
||
|
return Response<ChannelInfo>(
|
||
|
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.
|
||
|
///
|
||
|
/// Parameters:
|
||
|
/// * [videoId] - The video ID of the YouTube video you want to get information about.
|
||
|
/// * [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 [VideoInfo] as data
|
||
|
/// Throws [DioError] if API call or serialization fails
|
||
|
Future<Response<VideoInfo>> streamInfo({
|
||
|
required String videoId,
|
||
|
CancelToken? cancelToken,
|
||
|
Map<String, dynamic>? headers,
|
||
|
Map<String, dynamic>? extra,
|
||
|
ValidateStatus? validateStatus,
|
||
|
ProgressCallback? onSendProgress,
|
||
|
ProgressCallback? onReceiveProgress,
|
||
|
}) async {
|
||
|
final _path = r'/streams/{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,
|
||
|
);
|
||
|
|
||
|
VideoInfo _responseData;
|
||
|
|
||
|
try {
|
||
|
const _responseType = FullType(VideoInfo);
|
||
|
_responseData = _serializers.deserialize(
|
||
|
_response.data!,
|
||
|
specifiedType: _responseType,
|
||
|
) as VideoInfo;
|
||
|
|
||
|
} catch (error, stackTrace) {
|
||
|
throw DioError(
|
||
|
requestOptions: _response.requestOptions,
|
||
|
response: _response,
|
||
|
type: DioErrorType.other,
|
||
|
error: error,
|
||
|
)..stackTrace = stackTrace;
|
||
|
}
|
||
|
|
||
|
return Response<VideoInfo>(
|
||
|
data: _responseData,
|
||
|
headers: _response.headers,
|
||
|
isRedirect: _response.isRedirect,
|
||
|
requestOptions: _response.requestOptions,
|
||
|
redirects: _response.redirects,
|
||
|
statusCode: _response.statusCode,
|
||
|
statusMessage: _response.statusMessage,
|
||
|
extra: _response.extra,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/// Gets all Trending Videos
|
||
|
/// Gets all Trending Videos in the requested country.
|
||
|
///
|
||
|
/// Parameters:
|
||
|
/// * [region] - The Region to get trending videos 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 [BuiltList<StreamItem>] as data
|
||
|
/// Throws [DioError] if API call or serialization fails
|
||
|
Future<Response<BuiltList<StreamItem>>> trending({
|
||
|
required Regions region,
|
||
|
CancelToken? cancelToken,
|
||
|
Map<String, dynamic>? headers,
|
||
|
Map<String, dynamic>? extra,
|
||
|
ValidateStatus? validateStatus,
|
||
|
ProgressCallback? onSendProgress,
|
||
|
ProgressCallback? onReceiveProgress,
|
||
|
}) async {
|
||
|
final _path = r'/trending';
|
||
|
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'region': encodeQueryParameter(_serializers, region, const FullType(Regions)),
|
||
|
};
|
||
|
|
||
|
final _response = await _dio.request<Object>(
|
||
|
_path,
|
||
|
options: _options,
|
||
|
queryParameters: _queryParameters,
|
||
|
cancelToken: cancelToken,
|
||
|
onSendProgress: onSendProgress,
|
||
|
onReceiveProgress: onReceiveProgress,
|
||
|
);
|
||
|
|
||
|
BuiltList<StreamItem> _responseData;
|
||
|
|
||
|
try {
|
||
|
const _responseType = FullType(BuiltList, [FullType(StreamItem)]);
|
||
|
_responseData = _serializers.deserialize(
|
||
|
_response.data!,
|
||
|
specifiedType: _responseType,
|
||
|
) as BuiltList<StreamItem>;
|
||
|
|
||
|
} catch (error, stackTrace) {
|
||
|
throw DioError(
|
||
|
requestOptions: _response.requestOptions,
|
||
|
response: _response,
|
||
|
type: DioErrorType.other,
|
||
|
error: error,
|
||
|
)..stackTrace = stackTrace;
|
||
|
}
|
||
|
|
||
|
return Response<BuiltList<StreamItem>>(
|
||
|
data: _responseData,
|
||
|
headers: _response.headers,
|
||
|
isRedirect: _response.isRedirect,
|
||
|
requestOptions: _response.requestOptions,
|
||
|
redirects: _response.redirects,
|
||
|
statusCode: _response.statusCode,
|
||
|
statusMessage: _response.statusMessage,
|
||
|
extra: _response.extra,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|