54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import type {
|
|
DeleteMediaOutputDTO,
|
|
GetMediaOutputDTO,
|
|
RequestAvatarGenerationInputDTO,
|
|
RequestAvatarGenerationOutputDTO,
|
|
UpdateAvatarInputDTO,
|
|
UpdateAvatarOutputDTO,
|
|
UploadMediaOutputDTO,
|
|
} from '../generated';
|
|
import type { GetAvatarOutputDTO } from '../generated';
|
|
import { BaseApiClient } from '../base/BaseApiClient';
|
|
|
|
/**
|
|
* Media API Client
|
|
*
|
|
* Handles all media-related API operations.
|
|
*/
|
|
export class MediaApiClient extends BaseApiClient {
|
|
/** Upload media file */
|
|
uploadMedia(input: { file: File; type: string; category?: string }): 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 });
|
|
}
|
|
} |