refactor(server): rename api tags to follow plural nomenclature of endpoints (#9872)
* rename api tags to follow plural nomenclature of endpoints * chore: open api * fix mobile
This commit is contained in:
@@ -138,7 +138,7 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
|
||||
Future<bool> changePassword(String newPassword) async {
|
||||
try {
|
||||
await _apiService.userApi.updateMyUser(
|
||||
await _apiService.usersApi.updateMyUser(
|
||||
UserUpdateMeDto(
|
||||
password: newPassword,
|
||||
),
|
||||
@@ -179,8 +179,8 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
UserAdminResponseDto? userResponseDto;
|
||||
UserPreferencesResponseDto? userPreferences;
|
||||
try {
|
||||
userResponseDto = await _apiService.userApi.getMyUser();
|
||||
userPreferences = await _apiService.userApi.getMyPreferences();
|
||||
userResponseDto = await _apiService.usersApi.getMyUser();
|
||||
userPreferences = await _apiService.usersApi.getMyPreferences();
|
||||
} on ApiException catch (error, stackTrace) {
|
||||
_log.severe(
|
||||
"Error getting user information from the server [API EXCEPTION]",
|
||||
|
||||
@@ -20,8 +20,8 @@ class CurrentUserProvider extends StateNotifier<User?> {
|
||||
|
||||
refresh() async {
|
||||
try {
|
||||
final user = await _apiService.userApi.getMyUser();
|
||||
final userPreferences = await _apiService.userApi.getMyPreferences();
|
||||
final user = await _apiService.usersApi.getMyUser();
|
||||
final userPreferences = await _apiService.usersApi.getMyPreferences();
|
||||
if (user != null) {
|
||||
Store.put(
|
||||
StoreKey.currentUser,
|
||||
|
||||
@@ -57,9 +57,9 @@ class TabNavigationObserver extends AutoRouterObserver {
|
||||
// Update user info
|
||||
try {
|
||||
final userResponseDto =
|
||||
await ref.read(apiServiceProvider).userApi.getMyUser();
|
||||
await ref.read(apiServiceProvider).usersApi.getMyUser();
|
||||
final userPreferences =
|
||||
await ref.read(apiServiceProvider).userApi.getMyPreferences();
|
||||
await ref.read(apiServiceProvider).usersApi.getMyPreferences();
|
||||
|
||||
if (userResponseDto == null) {
|
||||
return;
|
||||
|
||||
@@ -19,7 +19,7 @@ class ActivityService with ErrorLoggerMixin {
|
||||
}) async {
|
||||
return logError(
|
||||
() async {
|
||||
final list = await _apiService.activityApi
|
||||
final list = await _apiService.activitiesApi
|
||||
.getActivities(albumId, assetId: assetId);
|
||||
return list != null ? list.map(Activity.fromDto).toList() : [];
|
||||
},
|
||||
@@ -31,7 +31,7 @@ class ActivityService with ErrorLoggerMixin {
|
||||
Future<int> getStatistics(String albumId, {String? assetId}) async {
|
||||
return logError(
|
||||
() async {
|
||||
final dto = await _apiService.activityApi
|
||||
final dto = await _apiService.activitiesApi
|
||||
.getActivityStatistics(albumId, assetId: assetId);
|
||||
return dto?.comments ?? 0;
|
||||
},
|
||||
@@ -43,7 +43,7 @@ class ActivityService with ErrorLoggerMixin {
|
||||
Future<bool> removeActivity(String id) async {
|
||||
return logError(
|
||||
() async {
|
||||
await _apiService.activityApi.deleteActivity(id);
|
||||
await _apiService.activitiesApi.deleteActivity(id);
|
||||
return true;
|
||||
},
|
||||
defaultValue: false,
|
||||
@@ -59,7 +59,7 @@ class ActivityService with ErrorLoggerMixin {
|
||||
}) async {
|
||||
return guardError(
|
||||
() async {
|
||||
final dto = await _apiService.activityApi.createActivity(
|
||||
final dto = await _apiService.activitiesApi.createActivity(
|
||||
ActivityCreateDto(
|
||||
albumId: albumId,
|
||||
type: type == ActivityType.comment
|
||||
|
||||
@@ -151,7 +151,7 @@ class AlbumService {
|
||||
bool changes = false;
|
||||
try {
|
||||
await _userService.refreshUsers();
|
||||
final List<AlbumResponseDto>? serverAlbums = await _apiService.albumApi
|
||||
final List<AlbumResponseDto>? serverAlbums = await _apiService.albumsApi
|
||||
.getAllAlbums(shared: isShared ? true : null);
|
||||
if (serverAlbums == null) {
|
||||
return false;
|
||||
@@ -161,7 +161,7 @@ class AlbumService {
|
||||
isShared: isShared,
|
||||
loadDetails: (dto) async => dto.assetCount == dto.assets.length
|
||||
? dto
|
||||
: (await _apiService.albumApi.getAlbumInfo(dto.id)) ?? dto,
|
||||
: (await _apiService.albumsApi.getAlbumInfo(dto.id)) ?? dto,
|
||||
);
|
||||
} finally {
|
||||
_remoteCompleter.complete(changes);
|
||||
@@ -176,7 +176,7 @@ class AlbumService {
|
||||
Iterable<User> sharedUsers = const [],
|
||||
]) async {
|
||||
try {
|
||||
AlbumResponseDto? remote = await _apiService.albumApi.createAlbum(
|
||||
AlbumResponseDto? remote = await _apiService.albumsApi.createAlbum(
|
||||
CreateAlbumDto(
|
||||
albumName: albumName,
|
||||
assetIds: assets.map((asset) => asset.remoteId!).toList(),
|
||||
@@ -231,7 +231,7 @@ class AlbumService {
|
||||
Album album,
|
||||
) async {
|
||||
try {
|
||||
var response = await _apiService.albumApi.addAssetsToAlbum(
|
||||
var response = await _apiService.albumsApi.addAssetsToAlbum(
|
||||
album.remoteId!,
|
||||
BulkIdsDto(ids: assets.map((asset) => asset.remoteId!).toList()),
|
||||
);
|
||||
@@ -290,7 +290,7 @@ class AlbumService {
|
||||
.map((userId) => AlbumUserAddDto(userId: userId))
|
||||
.toList();
|
||||
|
||||
final result = await _apiService.albumApi.addUsersToAlbum(
|
||||
final result = await _apiService.albumsApi.addUsersToAlbum(
|
||||
album.remoteId!,
|
||||
AddUsersDto(albumUsers: albumUsers),
|
||||
);
|
||||
@@ -312,7 +312,7 @@ class AlbumService {
|
||||
|
||||
Future<bool> setActivityEnabled(Album album, bool enabled) async {
|
||||
try {
|
||||
final result = await _apiService.albumApi.updateAlbumInfo(
|
||||
final result = await _apiService.albumsApi.updateAlbumInfo(
|
||||
album.remoteId!,
|
||||
UpdateAlbumDto(isActivityEnabled: enabled),
|
||||
);
|
||||
@@ -331,7 +331,7 @@ class AlbumService {
|
||||
try {
|
||||
final userId = Store.get(StoreKey.currentUser).isarId;
|
||||
if (album.owner.value?.isarId == userId) {
|
||||
await _apiService.albumApi.deleteAlbum(album.remoteId!);
|
||||
await _apiService.albumsApi.deleteAlbum(album.remoteId!);
|
||||
}
|
||||
if (album.shared) {
|
||||
final foreignAssets =
|
||||
@@ -362,7 +362,7 @@ class AlbumService {
|
||||
|
||||
Future<bool> leaveAlbum(Album album) async {
|
||||
try {
|
||||
await _apiService.albumApi.removeUserFromAlbum(album.remoteId!, "me");
|
||||
await _apiService.albumsApi.removeUserFromAlbum(album.remoteId!, "me");
|
||||
return true;
|
||||
} catch (e) {
|
||||
debugPrint("Error leaveAlbum ${e.toString()}");
|
||||
@@ -375,7 +375,7 @@ class AlbumService {
|
||||
Iterable<Asset> assets,
|
||||
) async {
|
||||
try {
|
||||
final response = await _apiService.albumApi.removeAssetFromAlbum(
|
||||
final response = await _apiService.albumsApi.removeAssetFromAlbum(
|
||||
album.remoteId!,
|
||||
BulkIdsDto(
|
||||
ids: assets.map((asset) => asset.remoteId!).toList(),
|
||||
@@ -401,7 +401,7 @@ class AlbumService {
|
||||
User user,
|
||||
) async {
|
||||
try {
|
||||
await _apiService.albumApi.removeUserFromAlbum(
|
||||
await _apiService.albumsApi.removeUserFromAlbum(
|
||||
album.remoteId!,
|
||||
user.id,
|
||||
);
|
||||
@@ -426,7 +426,7 @@ class AlbumService {
|
||||
String newAlbumTitle,
|
||||
) async {
|
||||
try {
|
||||
await _apiService.albumApi.updateAlbumInfo(
|
||||
await _apiService.albumsApi.updateAlbumInfo(
|
||||
album.remoteId!,
|
||||
UpdateAlbumDto(
|
||||
albumName: newAlbumTitle,
|
||||
|
||||
@@ -12,21 +12,21 @@ import 'package:http/http.dart';
|
||||
class ApiService {
|
||||
late ApiClient _apiClient;
|
||||
|
||||
late UserApi userApi;
|
||||
late UsersApi usersApi;
|
||||
late AuthenticationApi authenticationApi;
|
||||
late OAuthApi oAuthApi;
|
||||
late AlbumApi albumApi;
|
||||
late AssetApi assetApi;
|
||||
late AlbumsApi albumsApi;
|
||||
late AssetsApi assetsApi;
|
||||
late SearchApi searchApi;
|
||||
late ServerInfoApi serverInfoApi;
|
||||
late MapApi mapApi;
|
||||
late PartnerApi partnerApi;
|
||||
late PersonApi personApi;
|
||||
late PartnersApi partnersApi;
|
||||
late PeopleApi peopleApi;
|
||||
late AuditApi auditApi;
|
||||
late SharedLinkApi sharedLinkApi;
|
||||
late SharedLinksApi sharedLinksApi;
|
||||
late SyncApi syncApi;
|
||||
late SystemConfigApi systemConfigApi;
|
||||
late ActivityApi activityApi;
|
||||
late ActivitiesApi activitiesApi;
|
||||
late DownloadApi downloadApi;
|
||||
late TrashApi trashApi;
|
||||
|
||||
@@ -44,21 +44,21 @@ class ApiService {
|
||||
if (_accessToken != null) {
|
||||
setAccessToken(_accessToken!);
|
||||
}
|
||||
userApi = UserApi(_apiClient);
|
||||
usersApi = UsersApi(_apiClient);
|
||||
authenticationApi = AuthenticationApi(_apiClient);
|
||||
oAuthApi = OAuthApi(_apiClient);
|
||||
albumApi = AlbumApi(_apiClient);
|
||||
assetApi = AssetApi(_apiClient);
|
||||
albumsApi = AlbumsApi(_apiClient);
|
||||
assetsApi = AssetsApi(_apiClient);
|
||||
serverInfoApi = ServerInfoApi(_apiClient);
|
||||
searchApi = SearchApi(_apiClient);
|
||||
mapApi = MapApi(_apiClient);
|
||||
partnerApi = PartnerApi(_apiClient);
|
||||
personApi = PersonApi(_apiClient);
|
||||
partnersApi = PartnersApi(_apiClient);
|
||||
peopleApi = PeopleApi(_apiClient);
|
||||
auditApi = AuditApi(_apiClient);
|
||||
sharedLinkApi = SharedLinkApi(_apiClient);
|
||||
sharedLinksApi = SharedLinksApi(_apiClient);
|
||||
syncApi = SyncApi(_apiClient);
|
||||
systemConfigApi = SystemConfigApi(_apiClient);
|
||||
activityApi = ActivityApi(_apiClient);
|
||||
activitiesApi = ActivitiesApi(_apiClient);
|
||||
downloadApi = DownloadApi(_apiClient);
|
||||
trashApi = TrashApi(_apiClient);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class AssetService {
|
||||
) async {
|
||||
try {
|
||||
final AssetResponseDto? dto =
|
||||
await _apiService.assetApi.getAssetInfo(remoteId);
|
||||
await _apiService.assetsApi.getAssetInfo(remoteId);
|
||||
|
||||
return dto?.people;
|
||||
} catch (error, stack) {
|
||||
@@ -138,7 +138,7 @@ class AssetService {
|
||||
payload.add(asset.remoteId!);
|
||||
}
|
||||
|
||||
await _apiService.assetApi.deleteAssets(
|
||||
await _apiService.assetsApi.deleteAssets(
|
||||
AssetBulkDeleteDto(
|
||||
ids: payload,
|
||||
force: force,
|
||||
@@ -158,7 +158,7 @@ class AssetService {
|
||||
// fileSize is always filled on the server but not set on client
|
||||
if (a.exifInfo?.fileSize == null) {
|
||||
if (a.isRemote) {
|
||||
final dto = await _apiService.assetApi.getAssetInfo(a.remoteId!);
|
||||
final dto = await _apiService.assetsApi.getAssetInfo(a.remoteId!);
|
||||
if (dto != null && dto.exifInfo != null) {
|
||||
final newExif = Asset.remote(dto).exifInfo!.copyWith(id: a.id);
|
||||
if (newExif != a.exifInfo) {
|
||||
@@ -180,7 +180,7 @@ class AssetService {
|
||||
List<Asset> assets,
|
||||
UpdateAssetDto updateAssetDto,
|
||||
) async {
|
||||
return await _apiService.assetApi.updateAssets(
|
||||
return await _apiService.assetsApi.updateAssets(
|
||||
AssetBulkUpdateDto(
|
||||
ids: assets.map((e) => e.remoteId!).toList(),
|
||||
dateTimeOriginal: updateAssetDto.dateTimeOriginal,
|
||||
|
||||
@@ -17,7 +17,7 @@ class AssetDescriptionService {
|
||||
String remoteAssetId,
|
||||
int localExifId,
|
||||
) async {
|
||||
final result = await _api.assetApi.updateAsset(
|
||||
final result = await _api.assetsApi.updateAsset(
|
||||
remoteAssetId,
|
||||
UpdateAssetDto(description: description),
|
||||
);
|
||||
@@ -36,7 +36,7 @@ class AssetDescriptionService {
|
||||
|
||||
Future<String> readLatest(String assetRemoteId, int localExifId) async {
|
||||
final latestAssetFromServer =
|
||||
await _api.assetApi.getAssetInfo(assetRemoteId);
|
||||
await _api.assetsApi.getAssetInfo(assetRemoteId);
|
||||
final localExifInfo = await _db.exifInfos.get(localExifId);
|
||||
|
||||
if (latestAssetFromServer != null && localExifInfo != null) {
|
||||
|
||||
@@ -27,7 +27,7 @@ class AssetStackService {
|
||||
.map((e) => e.remoteId!)
|
||||
.toList();
|
||||
|
||||
await _api.assetApi.updateAssets(
|
||||
await _api.assetsApi.updateAssets(
|
||||
AssetBulkUpdateDto(ids: toAdd, stackParentId: parentAsset.remoteId),
|
||||
);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class AssetStackService {
|
||||
.where((e) => e.isRemote)
|
||||
.map((e) => e.remoteId!)
|
||||
.toList();
|
||||
await _api.assetApi.updateAssets(
|
||||
await _api.assetsApi.updateAssets(
|
||||
AssetBulkUpdateDto(ids: toRemove, removeParent: true),
|
||||
);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class AssetStackService {
|
||||
}
|
||||
|
||||
try {
|
||||
await _api.assetApi.updateStackParent(
|
||||
await _api.assetsApi.updateStackParent(
|
||||
UpdateStackParentDto(
|
||||
oldParentId: oldParent.remoteId!,
|
||||
newParentId: newParent.remoteId!,
|
||||
|
||||
@@ -44,7 +44,7 @@ class BackupService {
|
||||
final String deviceId = Store.get(StoreKey.deviceId);
|
||||
|
||||
try {
|
||||
return await _apiService.assetApi.getAllUserAssetsByDeviceId(deviceId);
|
||||
return await _apiService.assetsApi.getAllUserAssetsByDeviceId(deviceId);
|
||||
} catch (e) {
|
||||
debugPrint('Error [getDeviceBackupAsset] ${e.toString()}');
|
||||
return null;
|
||||
@@ -178,7 +178,7 @@ class BackupService {
|
||||
try {
|
||||
final String deviceId = Store.get(StoreKey.deviceId);
|
||||
final CheckExistingAssetsResponseDto? duplicates =
|
||||
await _apiService.assetApi.checkExistingAssets(
|
||||
await _apiService.assetsApi.checkExistingAssets(
|
||||
CheckExistingAssetsDto(
|
||||
deviceAssetIds: candidates.map((e) => e.id).toList(),
|
||||
deviceId: deviceId,
|
||||
|
||||
@@ -136,7 +136,7 @@ class BackupVerificationService {
|
||||
ExifInfo? exif = remote.exifInfo;
|
||||
if (exif != null && exif.lat != null) return false;
|
||||
if (exif == null || exif.fileSize == null) {
|
||||
final dto = await apiService.assetApi.getAssetInfo(remote.remoteId!);
|
||||
final dto = await apiService.assetsApi.getAssetInfo(remote.remoteId!);
|
||||
if (dto != null && dto.exifInfo != null) {
|
||||
exif = ExifInfo.fromDto(dto.exifInfo!);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class MemoryService {
|
||||
Future<List<Memory>?> getMemoryLane() async {
|
||||
try {
|
||||
final now = DateTime.now();
|
||||
final data = await _apiService.assetApi.getMemoryLane(
|
||||
final data = await _apiService.assetsApi.getMemoryLane(
|
||||
now.day,
|
||||
now.month,
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ class PartnerService {
|
||||
Future<List<User>?> getPartners(PartnerDirection direction) async {
|
||||
try {
|
||||
final userDtos =
|
||||
await _apiService.partnerApi.getPartners(direction._value);
|
||||
await _apiService.partnersApi.getPartners(direction._value);
|
||||
if (userDtos != null) {
|
||||
return userDtos.map((u) => User.fromPartnerDto(u)).toList();
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class PartnerService {
|
||||
|
||||
Future<bool> removePartner(User partner) async {
|
||||
try {
|
||||
await _apiService.partnerApi.removePartner(partner.id);
|
||||
await _apiService.partnersApi.removePartner(partner.id);
|
||||
partner.isPartnerSharedBy = false;
|
||||
await _db.writeTxn(() => _db.users.put(partner));
|
||||
} catch (e) {
|
||||
@@ -59,7 +59,7 @@ class PartnerService {
|
||||
|
||||
Future<bool> addPartner(User partner) async {
|
||||
try {
|
||||
final dto = await _apiService.partnerApi.createPartner(partner.id);
|
||||
final dto = await _apiService.partnersApi.createPartner(partner.id);
|
||||
if (dto != null) {
|
||||
partner.isPartnerSharedBy = true;
|
||||
await _db.writeTxn(() => _db.users.put(partner));
|
||||
@@ -73,7 +73,7 @@ class PartnerService {
|
||||
|
||||
Future<bool> updatePartner(User partner, {required bool inTimeline}) async {
|
||||
try {
|
||||
final dto = await _apiService.partnerApi
|
||||
final dto = await _apiService.partnersApi
|
||||
.updatePartner(partner.id, UpdatePartnerDto(inTimeline: inTimeline));
|
||||
if (dto != null) {
|
||||
partner.inTimeline = dto.inTimeline ?? partner.inTimeline;
|
||||
|
||||
@@ -22,7 +22,7 @@ class PersonService {
|
||||
|
||||
Future<List<PersonResponseDto>> getAllPeople() async {
|
||||
try {
|
||||
final peopleResponseDto = await _apiService.personApi.getAllPeople();
|
||||
final peopleResponseDto = await _apiService.peopleApi.getAllPeople();
|
||||
return peopleResponseDto?.people ?? [];
|
||||
} catch (error, stack) {
|
||||
_log.severe("Error while fetching curated people", error, stack);
|
||||
@@ -32,7 +32,7 @@ class PersonService {
|
||||
|
||||
Future<List<Asset>?> getPersonAssets(String id) async {
|
||||
try {
|
||||
final assets = await _apiService.personApi.getPersonAssets(id);
|
||||
final assets = await _apiService.peopleApi.getPersonAssets(id);
|
||||
if (assets == null) return null;
|
||||
return await _db.assets.getAllByRemoteId(assets.map((e) => e.id));
|
||||
} catch (error, stack) {
|
||||
@@ -43,7 +43,7 @@ class PersonService {
|
||||
|
||||
Future<PersonResponseDto?> updateName(String id, String name) async {
|
||||
try {
|
||||
return await _apiService.personApi.updatePerson(
|
||||
return await _apiService.peopleApi.updatePerson(
|
||||
id,
|
||||
PersonUpdateDto(
|
||||
name: name,
|
||||
|
||||
@@ -17,7 +17,7 @@ class SharedLinkService {
|
||||
|
||||
Future<AsyncValue<List<SharedLink>>> getAllSharedLinks() async {
|
||||
try {
|
||||
final list = await _apiService.sharedLinkApi.getAllSharedLinks();
|
||||
final list = await _apiService.sharedLinksApi.getAllSharedLinks();
|
||||
return list != null
|
||||
? AsyncData(list.map(SharedLink.fromDto).toList())
|
||||
: const AsyncData([]);
|
||||
@@ -29,7 +29,7 @@ class SharedLinkService {
|
||||
|
||||
Future<void> deleteSharedLink(String id) async {
|
||||
try {
|
||||
return await _apiService.sharedLinkApi.removeSharedLink(id);
|
||||
return await _apiService.sharedLinksApi.removeSharedLink(id);
|
||||
} catch (e) {
|
||||
_log.severe("Failed to delete shared link id - $id", e);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class SharedLinkService {
|
||||
|
||||
if (dto != null) {
|
||||
final responseDto =
|
||||
await _apiService.sharedLinkApi.createSharedLink(dto);
|
||||
await _apiService.sharedLinksApi.createSharedLink(dto);
|
||||
if (responseDto != null) {
|
||||
return SharedLink.fromDto(responseDto);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class SharedLinkService {
|
||||
DateTime? expiresAt,
|
||||
}) async {
|
||||
try {
|
||||
final responseDto = await _apiService.sharedLinkApi.updateSharedLink(
|
||||
final responseDto = await _apiService.sharedLinksApi.updateSharedLink(
|
||||
id,
|
||||
SharedLinkEditDto(
|
||||
showMetadata: showMeta,
|
||||
|
||||
@@ -39,7 +39,7 @@ class UserService {
|
||||
|
||||
Future<List<User>?> _getAllUsers() async {
|
||||
try {
|
||||
final dto = await _apiService.userApi.searchUsers();
|
||||
final dto = await _apiService.usersApi.searchUsers();
|
||||
return dto?.map(User.fromSimpleUserDto).toList();
|
||||
} catch (e) {
|
||||
_log.warning("Failed get all users", e);
|
||||
@@ -57,7 +57,7 @@ class UserService {
|
||||
|
||||
Future<CreateProfileImageResponseDto?> uploadProfileImage(XFile image) async {
|
||||
try {
|
||||
return await _apiService.userApi.createProfileImage(
|
||||
return await _apiService.usersApi.createProfileImage(
|
||||
MultipartFile.fromBytes(
|
||||
'file',
|
||||
await image.readAsBytes(),
|
||||
|
||||
Reference in New Issue
Block a user