services refactor
This commit is contained in:
@@ -2,6 +2,13 @@ import { BaseApiClient } from '../base/BaseApiClient';
|
||||
import type {
|
||||
RequestAvatarGenerationInputDto,
|
||||
RequestAvatarGenerationOutputDto,
|
||||
UploadMediaInputDto,
|
||||
UploadMediaOutputDto,
|
||||
GetMediaOutputDto,
|
||||
DeleteMediaOutputDto,
|
||||
GetAvatarOutputDto,
|
||||
UpdateAvatarInputDto,
|
||||
UpdateAvatarOutputDto,
|
||||
} from '../../dtos';
|
||||
|
||||
/**
|
||||
@@ -10,8 +17,39 @@ import type {
|
||||
* Handles all media-related API operations.
|
||||
*/
|
||||
export class MediaApiClient extends BaseApiClient {
|
||||
/** Upload media file */
|
||||
uploadMedia(input: UploadMediaInputDto): Promise<UploadMediaOutputDto> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', input.file);
|
||||
formData.append('type', input.type);
|
||||
if (input.category) {
|
||||
formData.append('category', input.category);
|
||||
}
|
||||
return this.post<UploadMediaOutputDto>('/media/upload', formData);
|
||||
}
|
||||
|
||||
/** Get media by ID */
|
||||
getMedia(mediaId: string): Promise<GetMediaOutputDto> {
|
||||
return this.get<GetMediaOutputDto>(`/media/${mediaId}`);
|
||||
}
|
||||
|
||||
/** Delete media by ID */
|
||||
deleteMedia(mediaId: string): Promise<DeleteMediaOutputDto> {
|
||||
return this.delete<DeleteMediaOutputDto>(`/media/${mediaId}`);
|
||||
}
|
||||
|
||||
/** Request avatar generation */
|
||||
requestAvatarGeneration(input: RequestAvatarGenerationInputDto): Promise<RequestAvatarGenerationOutputDto> {
|
||||
return this.post<RequestAvatarGenerationOutputDto>('/media/avatar/generate', input);
|
||||
}
|
||||
|
||||
/** Get avatar for driver */
|
||||
getAvatar(driverId: string): Promise<GetAvatarOutputDto> {
|
||||
return this.get<GetAvatarOutputDto>(`/media/avatar/${driverId}`);
|
||||
}
|
||||
|
||||
/** Update avatar for driver */
|
||||
updateAvatar(input: UpdateAvatarInputDto): Promise<UpdateAvatarOutputDto> {
|
||||
return this.put<UpdateAvatarOutputDto>(`/media/avatar/${input.driverId}`, { avatarUrl: input.avatarUrl });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user