Skip to content

Commit

Permalink
refactor(server): rename api tags to follow plural nomenclature of en…
Browse files Browse the repository at this point in the history
…dpoints (immich-app#9872)

* rename api tags to follow plural nomenclature of endpoints

* chore: open api

* fix mobile
  • Loading branch information
danieldietzler authored May 29, 2024
1 parent 77d1b9a commit 4376104
Show file tree
Hide file tree
Showing 54 changed files with 1,183 additions and 1,164 deletions.
6 changes: 3 additions & 3 deletions mobile/lib/providers/authentication.provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -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]",
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/providers/user.provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/routing/tab_navigation_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions mobile/lib/services/activity.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() : [];
},
Expand All @@ -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;
},
Expand All @@ -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,
Expand All @@ -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
Expand Down
22 changes: 11 additions & 11 deletions mobile/lib/services/album.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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(),
Expand Down Expand Up @@ -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()),
);
Expand Down Expand Up @@ -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),
);
Expand All @@ -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),
);
Expand All @@ -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 =
Expand Down Expand Up @@ -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()}");
Expand All @@ -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(),
Expand All @@ -401,7 +401,7 @@ class AlbumService {
User user,
) async {
try {
await _apiService.albumApi.removeUserFromAlbum(
await _apiService.albumsApi.removeUserFromAlbum(
album.remoteId!,
user.id,
);
Expand All @@ -426,7 +426,7 @@ class AlbumService {
String newAlbumTitle,
) async {
try {
await _apiService.albumApi.updateAlbumInfo(
await _apiService.albumsApi.updateAlbumInfo(
album.remoteId!,
UpdateAlbumDto(
albumName: newAlbumTitle,
Expand Down
28 changes: 14 additions & 14 deletions mobile/lib/services/api.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions mobile/lib/services/asset.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -138,7 +138,7 @@ class AssetService {
payload.add(asset.remoteId!);
}

await _apiService.assetApi.deleteAssets(
await _apiService.assetsApi.deleteAssets(
AssetBulkDeleteDto(
ids: payload,
force: force,
Expand All @@ -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) {
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/services/asset_description.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions mobile/lib/services/asset_stack.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}
Expand All @@ -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),
);
}
Expand All @@ -53,7 +53,7 @@ class AssetStackService {
}

try {
await _api.assetApi.updateStackParent(
await _api.assetsApi.updateStackParent(
UpdateStackParentDto(
oldParentId: oldParent.remoteId!,
newParentId: newParent.remoteId!,
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/services/backup.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/services/backup_verification.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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!);
}
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/services/memory.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
8 changes: 4 additions & 4 deletions mobile/lib/services/partner.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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) {
Expand All @@ -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));
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 4376104

Please sign in to comment.