Files
immich/mobile-v2/openapi/lib/src/api/download_api.dart
shenlong-tanwen 11cef4ec9a 🚀
2025-02-26 08:58:18 +05:30

357 lines
11 KiB
Dart

//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'dart:async';
import 'package:built_value/serializer.dart';
import 'package:dio/dio.dart';
import 'dart:typed_data';
import 'package:openapi/src/api_util.dart';
import 'package:openapi/src/model/asset_ids_dto.dart';
import 'package:openapi/src/model/download_info_dto.dart';
import 'package:openapi/src/model/download_response_dto.dart';
class DownloadApi {
final Dio _dio;
final Serializers _serializers;
const DownloadApi(this._dio, this._serializers);
/// downloadArchive
///
///
/// Parameters:
/// * [assetIdsDto]
/// * [key]
/// * [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 [Uint8List] as data
/// Throws [DioException] if API call or serialization fails
Future<Response<Uint8List>> downloadArchive({
required AssetIdsDto assetIdsDto,
String? key,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/download/archive';
final _options = Options(
method: r'POST',
responseType: ResponseType.bytes,
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[
{
'type': 'apiKey',
'name': 'cookie',
'keyName': 'immich_access_token',
'where': '',
},{
'type': 'apiKey',
'name': 'api_key',
'keyName': 'x-api-key',
'where': 'header',
},{
'type': 'http',
'scheme': 'Bearer',
'name': 'bearer',
},
],
...?extra,
},
contentType: 'application/json',
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
if (key != null) r'key': encodeQueryParameter(_serializers, key, const FullType(String)),
};
dynamic _bodyData;
try {
const _type = FullType(AssetIdsDto);
_bodyData = _serializers.serialize(assetIdsDto, specifiedType: _type);
} catch(error, stackTrace) {
throw DioException(
requestOptions: _options.compose(
_dio.options,
_path,
queryParameters: _queryParameters,
),
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
final _response = await _dio.request<Object>(
_path,
data: _bodyData,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
Uint8List? _responseData;
try {
final rawResponse = _response.data;
_responseData = rawResponse == null ? null : rawResponse as Uint8List;
} catch (error, stackTrace) {
throw DioException(
requestOptions: _response.requestOptions,
response: _response,
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
return Response<Uint8List>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
/// downloadFile
///
///
/// Parameters:
/// * [id]
/// * [key]
/// * [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 [Uint8List] as data
/// Throws [DioException] if API call or serialization fails
Future<Response<Uint8List>> downloadFile({
required String id,
String? key,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/download/asset/{id}'.replaceAll('{' r'id' '}', encodeQueryParameter(_serializers, id, const FullType(String)).toString());
final _options = Options(
method: r'POST',
responseType: ResponseType.bytes,
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[
{
'type': 'apiKey',
'name': 'cookie',
'keyName': 'immich_access_token',
'where': '',
},{
'type': 'apiKey',
'name': 'api_key',
'keyName': 'x-api-key',
'where': 'header',
},{
'type': 'http',
'scheme': 'Bearer',
'name': 'bearer',
},
],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
if (key != null) r'key': encodeQueryParameter(_serializers, key, const FullType(String)),
};
final _response = await _dio.request<Object>(
_path,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
Uint8List? _responseData;
try {
final rawResponse = _response.data;
_responseData = rawResponse == null ? null : rawResponse as Uint8List;
} catch (error, stackTrace) {
throw DioException(
requestOptions: _response.requestOptions,
response: _response,
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
return Response<Uint8List>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
/// getDownloadInfo
///
///
/// Parameters:
/// * [downloadInfoDto]
/// * [key]
/// * [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 [DownloadResponseDto] as data
/// Throws [DioException] if API call or serialization fails
Future<Response<DownloadResponseDto>> getDownloadInfo({
required DownloadInfoDto downloadInfoDto,
String? key,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/download/info';
final _options = Options(
method: r'POST',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[
{
'type': 'apiKey',
'name': 'cookie',
'keyName': 'immich_access_token',
'where': '',
},{
'type': 'apiKey',
'name': 'api_key',
'keyName': 'x-api-key',
'where': 'header',
},{
'type': 'http',
'scheme': 'Bearer',
'name': 'bearer',
},
],
...?extra,
},
contentType: 'application/json',
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
if (key != null) r'key': encodeQueryParameter(_serializers, key, const FullType(String)),
};
dynamic _bodyData;
try {
const _type = FullType(DownloadInfoDto);
_bodyData = _serializers.serialize(downloadInfoDto, specifiedType: _type);
} catch(error, stackTrace) {
throw DioException(
requestOptions: _options.compose(
_dio.options,
_path,
queryParameters: _queryParameters,
),
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
final _response = await _dio.request<Object>(
_path,
data: _bodyData,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
DownloadResponseDto? _responseData;
try {
final rawResponse = _response.data;
_responseData = rawResponse == null ? null : _serializers.deserialize(
rawResponse,
specifiedType: const FullType(DownloadResponseDto),
) as DownloadResponseDto;
} catch (error, stackTrace) {
throw DioException(
requestOptions: _response.requestOptions,
response: _response,
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
return Response<DownloadResponseDto>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
}