import { normalizeAlbumCreatePayload, normalizeAlbumPhotoCreatePayload, normalizeAppAlbum, normalizeAppAlbumPhotos, normalizeAppAlbums, normalizeAppVideo, normalizeAppVideos, normalizeVideoPayload } from './family-media-contract.js' import { normalizeGenealogyPathId } from './genealogy-contract.js' import { normalizeResourcePathId } from './request-normalizers.js' import { requestStrict } from './request-client.js' export const familyMediaApi = { async createAlbum(genealogyId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) return requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/albums`, method: 'POST', data: normalizeAlbumCreatePayload(payload) }, { requestController: requestOptions.requestController ?? null }) }, async updateAlbum(genealogyId, albumId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedAlbumId = normalizeResourcePathId(albumId, '相册标识') const album = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/albums/${normalizedAlbumId}`, method: 'PUT', data: normalizeAlbumCreatePayload(payload) }, { requestController: requestOptions.requestController ?? null }) return normalizeAppAlbum(album, normalizedGenealogyId) }, async deleteAlbum(genealogyId, albumId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedAlbumId = normalizeResourcePathId(albumId, '相册标识') await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/albums/${normalizedAlbumId}`, method: 'DELETE' }, { requireData: false, requestController: requestOptions.requestController ?? null }) return null }, async createAlbumPhoto(genealogyId, albumId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedAlbumId = normalizeResourcePathId(albumId, '相册标识') return requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/albums/${normalizedAlbumId}/photos`, method: 'POST', data: normalizeAlbumPhotoCreatePayload(payload) }, { requestController: requestOptions.requestController ?? null }) }, async deleteAlbumPhoto(genealogyId, albumId, photoId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedAlbumId = normalizeResourcePathId(albumId, '相册标识') const normalizedPhotoId = normalizeResourcePathId(photoId, '照片标识') await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/albums/${normalizedAlbumId}/photos/${normalizedPhotoId}`, method: 'DELETE' }, { requireData: false, requestController: requestOptions.requestController ?? null }) return null }, async getAlbums(genealogyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const albums = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/albums`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeAppAlbums(albums, normalizedGenealogyId) }, async getAlbumPhotos(genealogyId, albumId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedAlbumId = normalizeResourcePathId(albumId, '相册标识') const photos = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/albums/${normalizedAlbumId}/photos`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeAppAlbumPhotos(photos, normalizedGenealogyId, normalizedAlbumId) }, async getVideos(genealogyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const videos = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/videos`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeAppVideos(videos, normalizedGenealogyId) }, async getVideoDetail(genealogyId, videoId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedVideoId = normalizeResourcePathId(videoId, '视频标识') const video = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/videos/${normalizedVideoId}`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeAppVideo(video, normalizedGenealogyId, normalizedVideoId) }, async createVideo(genealogyId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const video = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/videos`, method: 'POST', data: normalizeVideoPayload(payload) }, { requestController: requestOptions.requestController ?? null }) return normalizeAppVideo(video, normalizedGenealogyId) }, async updateVideo(genealogyId, videoId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedVideoId = normalizeResourcePathId(videoId, '视频标识') const video = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/videos/${normalizedVideoId}`, method: 'PUT', data: normalizeVideoPayload(payload) }, { requestController: requestOptions.requestController ?? null }) return normalizeAppVideo(video, normalizedGenealogyId, normalizedVideoId) }, async deleteVideo(genealogyId, videoId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedVideoId = normalizeResourcePathId(videoId, '视频标识') await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/videos/${normalizedVideoId}`, method: 'DELETE' }, { requireData: false, requestController: requestOptions.requestController ?? null }) return null } }