mirror of
https://github.com/immich-app/immich.git
synced 2025-12-25 22:37:36 -05:00
460 lines
14 KiB
Dart
460 lines
14 KiB
Dart
//
|
|
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
|
//
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:built_value/serializer.dart';
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:openapi/src/model/login_response_dto.dart';
|
|
import 'package:openapi/src/model/o_auth_authorize_response_dto.dart';
|
|
import 'package:openapi/src/model/o_auth_callback_dto.dart';
|
|
import 'package:openapi/src/model/o_auth_config_dto.dart';
|
|
import 'package:openapi/src/model/user_response_dto.dart';
|
|
|
|
class OAuthApi {
|
|
|
|
final Dio _dio;
|
|
|
|
final Serializers _serializers;
|
|
|
|
const OAuthApi(this._dio, this._serializers);
|
|
|
|
/// finishOAuth
|
|
///
|
|
///
|
|
/// Parameters:
|
|
/// * [oAuthCallbackDto]
|
|
/// * [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 [LoginResponseDto] as data
|
|
/// Throws [DioException] if API call or serialization fails
|
|
Future<Response<LoginResponseDto>> finishOAuth({
|
|
required OAuthCallbackDto oAuthCallbackDto,
|
|
CancelToken? cancelToken,
|
|
Map<String, dynamic>? headers,
|
|
Map<String, dynamic>? extra,
|
|
ValidateStatus? validateStatus,
|
|
ProgressCallback? onSendProgress,
|
|
ProgressCallback? onReceiveProgress,
|
|
}) async {
|
|
final _path = r'/oauth/callback';
|
|
final _options = Options(
|
|
method: r'POST',
|
|
headers: <String, dynamic>{
|
|
...?headers,
|
|
},
|
|
extra: <String, dynamic>{
|
|
'secure': <Map<String, String>>[],
|
|
...?extra,
|
|
},
|
|
contentType: 'application/json',
|
|
validateStatus: validateStatus,
|
|
);
|
|
|
|
dynamic _bodyData;
|
|
|
|
try {
|
|
const _type = FullType(OAuthCallbackDto);
|
|
_bodyData = _serializers.serialize(oAuthCallbackDto, specifiedType: _type);
|
|
|
|
} catch(error, stackTrace) {
|
|
throw DioException(
|
|
requestOptions: _options.compose(
|
|
_dio.options,
|
|
_path,
|
|
),
|
|
type: DioExceptionType.unknown,
|
|
error: error,
|
|
stackTrace: stackTrace,
|
|
);
|
|
}
|
|
|
|
final _response = await _dio.request<Object>(
|
|
_path,
|
|
data: _bodyData,
|
|
options: _options,
|
|
cancelToken: cancelToken,
|
|
onSendProgress: onSendProgress,
|
|
onReceiveProgress: onReceiveProgress,
|
|
);
|
|
|
|
LoginResponseDto? _responseData;
|
|
|
|
try {
|
|
final rawResponse = _response.data;
|
|
_responseData = rawResponse == null ? null : _serializers.deserialize(
|
|
rawResponse,
|
|
specifiedType: const FullType(LoginResponseDto),
|
|
) as LoginResponseDto;
|
|
|
|
} catch (error, stackTrace) {
|
|
throw DioException(
|
|
requestOptions: _response.requestOptions,
|
|
response: _response,
|
|
type: DioExceptionType.unknown,
|
|
error: error,
|
|
stackTrace: stackTrace,
|
|
);
|
|
}
|
|
|
|
return Response<LoginResponseDto>(
|
|
data: _responseData,
|
|
headers: _response.headers,
|
|
isRedirect: _response.isRedirect,
|
|
requestOptions: _response.requestOptions,
|
|
redirects: _response.redirects,
|
|
statusCode: _response.statusCode,
|
|
statusMessage: _response.statusMessage,
|
|
extra: _response.extra,
|
|
);
|
|
}
|
|
|
|
/// linkOAuthAccount
|
|
///
|
|
///
|
|
/// Parameters:
|
|
/// * [oAuthCallbackDto]
|
|
/// * [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 [UserResponseDto] as data
|
|
/// Throws [DioException] if API call or serialization fails
|
|
Future<Response<UserResponseDto>> linkOAuthAccount({
|
|
required OAuthCallbackDto oAuthCallbackDto,
|
|
CancelToken? cancelToken,
|
|
Map<String, dynamic>? headers,
|
|
Map<String, dynamic>? extra,
|
|
ValidateStatus? validateStatus,
|
|
ProgressCallback? onSendProgress,
|
|
ProgressCallback? onReceiveProgress,
|
|
}) async {
|
|
final _path = r'/oauth/link';
|
|
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,
|
|
);
|
|
|
|
dynamic _bodyData;
|
|
|
|
try {
|
|
const _type = FullType(OAuthCallbackDto);
|
|
_bodyData = _serializers.serialize(oAuthCallbackDto, specifiedType: _type);
|
|
|
|
} catch(error, stackTrace) {
|
|
throw DioException(
|
|
requestOptions: _options.compose(
|
|
_dio.options,
|
|
_path,
|
|
),
|
|
type: DioExceptionType.unknown,
|
|
error: error,
|
|
stackTrace: stackTrace,
|
|
);
|
|
}
|
|
|
|
final _response = await _dio.request<Object>(
|
|
_path,
|
|
data: _bodyData,
|
|
options: _options,
|
|
cancelToken: cancelToken,
|
|
onSendProgress: onSendProgress,
|
|
onReceiveProgress: onReceiveProgress,
|
|
);
|
|
|
|
UserResponseDto? _responseData;
|
|
|
|
try {
|
|
final rawResponse = _response.data;
|
|
_responseData = rawResponse == null ? null : _serializers.deserialize(
|
|
rawResponse,
|
|
specifiedType: const FullType(UserResponseDto),
|
|
) as UserResponseDto;
|
|
|
|
} catch (error, stackTrace) {
|
|
throw DioException(
|
|
requestOptions: _response.requestOptions,
|
|
response: _response,
|
|
type: DioExceptionType.unknown,
|
|
error: error,
|
|
stackTrace: stackTrace,
|
|
);
|
|
}
|
|
|
|
return Response<UserResponseDto>(
|
|
data: _responseData,
|
|
headers: _response.headers,
|
|
isRedirect: _response.isRedirect,
|
|
requestOptions: _response.requestOptions,
|
|
redirects: _response.redirects,
|
|
statusCode: _response.statusCode,
|
|
statusMessage: _response.statusMessage,
|
|
extra: _response.extra,
|
|
);
|
|
}
|
|
|
|
/// redirectOAuthToMobile
|
|
///
|
|
///
|
|
/// Parameters:
|
|
/// * [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]
|
|
/// Throws [DioException] if API call or serialization fails
|
|
Future<Response<void>> redirectOAuthToMobile({
|
|
CancelToken? cancelToken,
|
|
Map<String, dynamic>? headers,
|
|
Map<String, dynamic>? extra,
|
|
ValidateStatus? validateStatus,
|
|
ProgressCallback? onSendProgress,
|
|
ProgressCallback? onReceiveProgress,
|
|
}) async {
|
|
final _path = r'/oauth/mobile-redirect';
|
|
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,
|
|
);
|
|
|
|
return _response;
|
|
}
|
|
|
|
/// startOAuth
|
|
///
|
|
///
|
|
/// Parameters:
|
|
/// * [oAuthConfigDto]
|
|
/// * [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 [OAuthAuthorizeResponseDto] as data
|
|
/// Throws [DioException] if API call or serialization fails
|
|
Future<Response<OAuthAuthorizeResponseDto>> startOAuth({
|
|
required OAuthConfigDto oAuthConfigDto,
|
|
CancelToken? cancelToken,
|
|
Map<String, dynamic>? headers,
|
|
Map<String, dynamic>? extra,
|
|
ValidateStatus? validateStatus,
|
|
ProgressCallback? onSendProgress,
|
|
ProgressCallback? onReceiveProgress,
|
|
}) async {
|
|
final _path = r'/oauth/authorize';
|
|
final _options = Options(
|
|
method: r'POST',
|
|
headers: <String, dynamic>{
|
|
...?headers,
|
|
},
|
|
extra: <String, dynamic>{
|
|
'secure': <Map<String, String>>[],
|
|
...?extra,
|
|
},
|
|
contentType: 'application/json',
|
|
validateStatus: validateStatus,
|
|
);
|
|
|
|
dynamic _bodyData;
|
|
|
|
try {
|
|
const _type = FullType(OAuthConfigDto);
|
|
_bodyData = _serializers.serialize(oAuthConfigDto, specifiedType: _type);
|
|
|
|
} catch(error, stackTrace) {
|
|
throw DioException(
|
|
requestOptions: _options.compose(
|
|
_dio.options,
|
|
_path,
|
|
),
|
|
type: DioExceptionType.unknown,
|
|
error: error,
|
|
stackTrace: stackTrace,
|
|
);
|
|
}
|
|
|
|
final _response = await _dio.request<Object>(
|
|
_path,
|
|
data: _bodyData,
|
|
options: _options,
|
|
cancelToken: cancelToken,
|
|
onSendProgress: onSendProgress,
|
|
onReceiveProgress: onReceiveProgress,
|
|
);
|
|
|
|
OAuthAuthorizeResponseDto? _responseData;
|
|
|
|
try {
|
|
final rawResponse = _response.data;
|
|
_responseData = rawResponse == null ? null : _serializers.deserialize(
|
|
rawResponse,
|
|
specifiedType: const FullType(OAuthAuthorizeResponseDto),
|
|
) as OAuthAuthorizeResponseDto;
|
|
|
|
} catch (error, stackTrace) {
|
|
throw DioException(
|
|
requestOptions: _response.requestOptions,
|
|
response: _response,
|
|
type: DioExceptionType.unknown,
|
|
error: error,
|
|
stackTrace: stackTrace,
|
|
);
|
|
}
|
|
|
|
return Response<OAuthAuthorizeResponseDto>(
|
|
data: _responseData,
|
|
headers: _response.headers,
|
|
isRedirect: _response.isRedirect,
|
|
requestOptions: _response.requestOptions,
|
|
redirects: _response.redirects,
|
|
statusCode: _response.statusCode,
|
|
statusMessage: _response.statusMessage,
|
|
extra: _response.extra,
|
|
);
|
|
}
|
|
|
|
/// unlinkOAuthAccount
|
|
///
|
|
///
|
|
/// Parameters:
|
|
/// * [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 [UserResponseDto] as data
|
|
/// Throws [DioException] if API call or serialization fails
|
|
Future<Response<UserResponseDto>> unlinkOAuthAccount({
|
|
CancelToken? cancelToken,
|
|
Map<String, dynamic>? headers,
|
|
Map<String, dynamic>? extra,
|
|
ValidateStatus? validateStatus,
|
|
ProgressCallback? onSendProgress,
|
|
ProgressCallback? onReceiveProgress,
|
|
}) async {
|
|
final _path = r'/oauth/unlink';
|
|
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,
|
|
},
|
|
validateStatus: validateStatus,
|
|
);
|
|
|
|
final _response = await _dio.request<Object>(
|
|
_path,
|
|
options: _options,
|
|
cancelToken: cancelToken,
|
|
onSendProgress: onSendProgress,
|
|
onReceiveProgress: onReceiveProgress,
|
|
);
|
|
|
|
UserResponseDto? _responseData;
|
|
|
|
try {
|
|
final rawResponse = _response.data;
|
|
_responseData = rawResponse == null ? null : _serializers.deserialize(
|
|
rawResponse,
|
|
specifiedType: const FullType(UserResponseDto),
|
|
) as UserResponseDto;
|
|
|
|
} catch (error, stackTrace) {
|
|
throw DioException(
|
|
requestOptions: _response.requestOptions,
|
|
response: _response,
|
|
type: DioExceptionType.unknown,
|
|
error: error,
|
|
stackTrace: stackTrace,
|
|
);
|
|
}
|
|
|
|
return Response<UserResponseDto>(
|
|
data: _responseData,
|
|
headers: _response.headers,
|
|
isRedirect: _response.isRedirect,
|
|
requestOptions: _response.requestOptions,
|
|
redirects: _response.redirects,
|
|
statusCode: _response.statusCode,
|
|
statusMessage: _response.statusMessage,
|
|
extra: _response.extra,
|
|
);
|
|
}
|
|
|
|
}
|