You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-09 23:17:29 +02:00
refactor(server): partner search dto (#10902)
* refactor(server): partner search dto * fix: missed reference * mobile fix --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
1
mobile/openapi/lib/api.dart
generated
1
mobile/openapi/lib/api.dart
generated
@@ -166,6 +166,7 @@ part 'model/o_auth_authorize_response_dto.dart';
|
||||
part 'model/o_auth_callback_dto.dart';
|
||||
part 'model/o_auth_config_dto.dart';
|
||||
part 'model/on_this_day_dto.dart';
|
||||
part 'model/partner_direction.dart';
|
||||
part 'model/partner_response_dto.dart';
|
||||
part 'model/path_entity_type.dart';
|
||||
part 'model/path_type.dart';
|
||||
|
8
mobile/openapi/lib/api/partners_api.dart
generated
8
mobile/openapi/lib/api/partners_api.dart
generated
@@ -67,8 +67,8 @@ class PartnersApi {
|
||||
/// Performs an HTTP 'GET /partners' operation and returns the [Response].
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] direction (required):
|
||||
Future<Response> getPartnersWithHttpInfo(String direction,) async {
|
||||
/// * [PartnerDirection] direction (required):
|
||||
Future<Response> getPartnersWithHttpInfo(PartnerDirection direction,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/partners';
|
||||
|
||||
@@ -97,8 +97,8 @@ class PartnersApi {
|
||||
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] direction (required):
|
||||
Future<List<PartnerResponseDto>?> getPartners(String direction,) async {
|
||||
/// * [PartnerDirection] direction (required):
|
||||
Future<List<PartnerResponseDto>?> getPartners(PartnerDirection direction,) async {
|
||||
final response = await getPartnersWithHttpInfo(direction,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
|
2
mobile/openapi/lib/api_client.dart
generated
2
mobile/openapi/lib/api_client.dart
generated
@@ -390,6 +390,8 @@ class ApiClient {
|
||||
return OAuthConfigDto.fromJson(value);
|
||||
case 'OnThisDayDto':
|
||||
return OnThisDayDto.fromJson(value);
|
||||
case 'PartnerDirection':
|
||||
return PartnerDirectionTypeTransformer().decode(value);
|
||||
case 'PartnerResponseDto':
|
||||
return PartnerResponseDto.fromJson(value);
|
||||
case 'PathEntityType':
|
||||
|
3
mobile/openapi/lib/api_helper.dart
generated
3
mobile/openapi/lib/api_helper.dart
generated
@@ -103,6 +103,9 @@ String parameterToString(dynamic value) {
|
||||
if (value is MemoryType) {
|
||||
return MemoryTypeTypeTransformer().encode(value).toString();
|
||||
}
|
||||
if (value is PartnerDirection) {
|
||||
return PartnerDirectionTypeTransformer().encode(value).toString();
|
||||
}
|
||||
if (value is PathEntityType) {
|
||||
return PathEntityTypeTypeTransformer().encode(value).toString();
|
||||
}
|
||||
|
85
mobile/openapi/lib/model/partner_direction.dart
generated
Normal file
85
mobile/openapi/lib/model/partner_direction.dart
generated
Normal file
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.18
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class PartnerDirection {
|
||||
/// Instantiate a new enum with the provided [value].
|
||||
const PartnerDirection._(this.value);
|
||||
|
||||
/// The underlying value of this enum member.
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => value;
|
||||
|
||||
String toJson() => value;
|
||||
|
||||
static const by = PartnerDirection._(r'shared-by');
|
||||
static const with_ = PartnerDirection._(r'shared-with');
|
||||
|
||||
/// List of all possible values in this [enum][PartnerDirection].
|
||||
static const values = <PartnerDirection>[
|
||||
by,
|
||||
with_,
|
||||
];
|
||||
|
||||
static PartnerDirection? fromJson(dynamic value) => PartnerDirectionTypeTransformer().decode(value);
|
||||
|
||||
static List<PartnerDirection> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <PartnerDirection>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = PartnerDirection.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [PartnerDirection] to String,
|
||||
/// and [decode] dynamic data back to [PartnerDirection].
|
||||
class PartnerDirectionTypeTransformer {
|
||||
factory PartnerDirectionTypeTransformer() => _instance ??= const PartnerDirectionTypeTransformer._();
|
||||
|
||||
const PartnerDirectionTypeTransformer._();
|
||||
|
||||
String encode(PartnerDirection data) => data.value;
|
||||
|
||||
/// Decodes a [dynamic value][data] to a PartnerDirection.
|
||||
///
|
||||
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
|
||||
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
|
||||
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
PartnerDirection? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data) {
|
||||
case r'shared-by': return PartnerDirection.by;
|
||||
case r'shared-with': return PartnerDirection.with_;
|
||||
default:
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Singleton [PartnerDirectionTypeTransformer] instance.
|
||||
static PartnerDirectionTypeTransformer? _instance;
|
||||
}
|
||||
|
Reference in New Issue
Block a user