change readonly boolean to role enum

This commit is contained in:
mgabor
2024-04-17 09:31:56 +02:00
parent 9126bf2520
commit 87bc244b68
30 changed files with 297 additions and 141 deletions

View File

@@ -17,6 +17,7 @@ doc/AlbumApi.md
doc/AlbumCountResponseDto.md
doc/AlbumResponseDto.md
doc/AlbumUserResponseDto.md
doc/AlbumUserRole.md
doc/AllJobStatusResponseDto.md
doc/AssetApi.md
doc/AssetBulkDeleteDto.md
@@ -240,6 +241,7 @@ lib/model/add_users_dto.dart
lib/model/album_count_response_dto.dart
lib/model/album_response_dto.dart
lib/model/album_user_response_dto.dart
lib/model/album_user_role.dart
lib/model/all_job_status_response_dto.dart
lib/model/api_key_create_dto.dart
lib/model/api_key_create_response_dto.dart
@@ -419,6 +421,7 @@ test/album_api_test.dart
test/album_count_response_dto_test.dart
test/album_response_dto_test.dart
test/album_user_response_dto_test.dart
test/album_user_role_test.dart
test/all_job_status_response_dto_test.dart
test/api_key_api_test.dart
test/api_key_create_dto_test.dart

View File

@@ -235,6 +235,7 @@ Class | Method | HTTP request | Description
- [AlbumCountResponseDto](doc//AlbumCountResponseDto.md)
- [AlbumResponseDto](doc//AlbumResponseDto.md)
- [AlbumUserResponseDto](doc//AlbumUserResponseDto.md)
- [AlbumUserRole](doc//AlbumUserRole.md)
- [AllJobStatusResponseDto](doc//AllJobStatusResponseDto.md)
- [AssetBulkDeleteDto](doc//AssetBulkDeleteDto.md)
- [AssetBulkUpdateDto](doc//AssetBulkUpdateDto.md)

View File

@@ -23,7 +23,7 @@ Name | Type | Description | Notes
**owner** | [**UserResponseDto**](UserResponseDto.md) | |
**ownerId** | **String** | |
**shared** | **bool** | |
**sharedUsers** | [**List<UserResponseDto>**](UserResponseDto.md) | Deprecated in favor of users | [default to const []]
**sharedUsers** | [**List<UserResponseDto>**](UserResponseDto.md) | Deprecated in favor of sharedUsersV2 | [default to const []]
**sharedUsersV2** | [**List<AlbumUserResponseDto>**](AlbumUserResponseDto.md) | | [default to const []]
**startDate** | [**DateTime**](DateTime.md) | | [optional]
**updatedAt** | [**DateTime**](DateTime.md) | |

View File

@@ -8,7 +8,7 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**readonly** | **bool** | |
**role** | [**AlbumUserRole**](AlbumUserRole.md) | |
**user** | [**UserResponseDto**](UserResponseDto.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

14
mobile/openapi/doc/AlbumUserRole.md generated Normal file
View File

@@ -0,0 +1,14 @@
# openapi.model.AlbumUserRole
## Load the model package
```dart
import 'package:openapi/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
[[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

@@ -8,7 +8,7 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**readonly** | **bool** | |
**role** | [**AlbumUserRole**](AlbumUserRole.md) | |
[[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

@@ -63,6 +63,7 @@ part 'model/add_users_dto.dart';
part 'model/album_count_response_dto.dart';
part 'model/album_response_dto.dart';
part 'model/album_user_response_dto.dart';
part 'model/album_user_role.dart';
part 'model/all_job_status_response_dto.dart';
part 'model/asset_bulk_delete_dto.dart';
part 'model/asset_bulk_update_dto.dart';

View File

@@ -204,6 +204,8 @@ class ApiClient {
return AlbumResponseDto.fromJson(value);
case 'AlbumUserResponseDto':
return AlbumUserResponseDto.fromJson(value);
case 'AlbumUserRole':
return AlbumUserRoleTypeTransformer().decode(value);
case 'AllJobStatusResponseDto':
return AllJobStatusResponseDto.fromJson(value);
case 'AssetBulkDeleteDto':

View File

@@ -55,6 +55,9 @@ String parameterToString(dynamic value) {
if (value is DateTime) {
return value.toUtc().toIso8601String();
}
if (value is AlbumUserRole) {
return AlbumUserRoleTypeTransformer().encode(value).toString();
}
if (value is AssetJobName) {
return AssetJobNameTypeTransformer().encode(value).toString();
}

View File

@@ -82,7 +82,7 @@ class AlbumResponseDto {
bool shared;
/// Deprecated in favor of users
/// Deprecated in favor of sharedUsersV2
List<UserResponseDto> sharedUsers;
List<AlbumUserResponseDto> sharedUsersV2;

View File

@@ -13,31 +13,31 @@ part of openapi.api;
class AlbumUserResponseDto {
/// Returns a new [AlbumUserResponseDto] instance.
AlbumUserResponseDto({
required this.readonly,
required this.role,
required this.user,
});
bool readonly;
AlbumUserRole role;
UserResponseDto user;
@override
bool operator ==(Object other) => identical(this, other) || other is AlbumUserResponseDto &&
other.readonly == readonly &&
other.role == role &&
other.user == user;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(readonly.hashCode) +
(role.hashCode) +
(user.hashCode);
@override
String toString() => 'AlbumUserResponseDto[readonly=$readonly, user=$user]';
String toString() => 'AlbumUserResponseDto[role=$role, user=$user]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'readonly'] = this.readonly;
json[r'role'] = this.role;
json[r'user'] = this.user;
return json;
}
@@ -50,7 +50,7 @@ class AlbumUserResponseDto {
final json = value.cast<String, dynamic>();
return AlbumUserResponseDto(
readonly: mapValueOfType<bool>(json, r'readonly')!,
role: AlbumUserRole.fromJson(json[r'role'])!,
user: UserResponseDto.fromJson(json[r'user'])!,
);
}
@@ -99,7 +99,7 @@ class AlbumUserResponseDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'readonly',
'role',
'user',
};
}

View File

@@ -0,0 +1,85 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// 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 AlbumUserRole {
/// Instantiate a new enum with the provided [value].
const AlbumUserRole._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const editor = AlbumUserRole._(r'editor');
static const viewer = AlbumUserRole._(r'viewer');
/// List of all possible values in this [enum][AlbumUserRole].
static const values = <AlbumUserRole>[
editor,
viewer,
];
static AlbumUserRole? fromJson(dynamic value) => AlbumUserRoleTypeTransformer().decode(value);
static List<AlbumUserRole> listFromJson(dynamic json, {bool growable = false,}) {
final result = <AlbumUserRole>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = AlbumUserRole.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [AlbumUserRole] to String,
/// and [decode] dynamic data back to [AlbumUserRole].
class AlbumUserRoleTypeTransformer {
factory AlbumUserRoleTypeTransformer() => _instance ??= const AlbumUserRoleTypeTransformer._();
const AlbumUserRoleTypeTransformer._();
String encode(AlbumUserRole data) => data.value;
/// Decodes a [dynamic value][data] to a AlbumUserRole.
///
/// 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.
AlbumUserRole? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'editor': return AlbumUserRole.editor;
case r'viewer': return AlbumUserRole.viewer;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [AlbumUserRoleTypeTransformer] instance.
static AlbumUserRoleTypeTransformer? _instance;
}

View File

@@ -13,26 +13,26 @@ part of openapi.api;
class UpdateAlbumUserDto {
/// Returns a new [UpdateAlbumUserDto] instance.
UpdateAlbumUserDto({
required this.readonly,
required this.role,
});
bool readonly;
AlbumUserRole role;
@override
bool operator ==(Object other) => identical(this, other) || other is UpdateAlbumUserDto &&
other.readonly == readonly;
other.role == role;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(readonly.hashCode);
(role.hashCode);
@override
String toString() => 'UpdateAlbumUserDto[readonly=$readonly]';
String toString() => 'UpdateAlbumUserDto[role=$role]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'readonly'] = this.readonly;
json[r'role'] = this.role;
return json;
}
@@ -44,7 +44,7 @@ class UpdateAlbumUserDto {
final json = value.cast<String, dynamic>();
return UpdateAlbumUserDto(
readonly: mapValueOfType<bool>(json, r'readonly')!,
role: AlbumUserRole.fromJson(json[r'role'])!,
);
}
return null;
@@ -92,7 +92,7 @@ class UpdateAlbumUserDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'readonly',
'role',
};
}

View File

@@ -91,7 +91,7 @@ void main() {
// TODO
});
// Deprecated in favor of users
// Deprecated in favor of sharedUsersV2
// List<UserResponseDto> sharedUsers (default value: const [])
test('to test the property `sharedUsers`', () async {
// TODO

View File

@@ -16,8 +16,8 @@ void main() {
// final instance = AlbumUserResponseDto();
group('test AlbumUserResponseDto', () {
// bool readonly
test('to test the property `readonly`', () async {
// AlbumUserRole role
test('to test the property `role`', () async {
// TODO
});

View File

@@ -0,0 +1,21 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// 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
import 'package:openapi/api.dart';
import 'package:test/test.dart';
// tests for AlbumUserRole
void main() {
group('test AlbumUserRole', () {
});
}

View File

@@ -16,8 +16,8 @@ void main() {
// final instance = UpdateAlbumUserDto();
group('test UpdateAlbumUserDto', () {
// bool readonly
test('to test the property `readonly`', () async {
// AlbumUserRole role
test('to test the property `role`', () async {
// TODO
});