import { normalizeAppCeremonies, normalizeAppCeremony, normalizeAppCeremonyGift, normalizeAppCeremonyGifts, normalizeCeremonyGiftPayload, normalizeCeremonyInvitationResponsePayload, normalizeCeremonyInvitationRows, normalizeCeremonyInviteeOptions, normalizeCeremonyInviteePayload, normalizeCeremonyPayload } from './ceremony-contract.js' import { normalizeGenealogyPathId } from './genealogy-contract.js' import { normalizeResourcePathId } from './request-normalizers.js' import { requestStrict } from './request-client.js' export const ceremonyApi = { async createCeremony(genealogyId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) return requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies`, method: 'POST', data: normalizeCeremonyPayload(payload) }, { requestController: requestOptions.requestController ?? null }) }, async updateCeremony(genealogyId, ceremonyId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') return requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}`, method: 'PUT', data: normalizeCeremonyPayload(payload) }, { requestController: requestOptions.requestController ?? null }) }, async deleteCeremony(genealogyId, ceremonyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}`, method: 'DELETE' }, { requireData: false, requestController: requestOptions.requestController ?? null }) return null }, async createCeremonyGift(genealogyId, ceremonyId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') const gift = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/gifts`, method: 'POST', data: normalizeCeremonyGiftPayload(payload) }, { requestController: requestOptions.requestController ?? null }) return normalizeAppCeremonyGift(gift, normalizedGenealogyId, normalizedCeremonyId) }, async deleteCeremonyGift(genealogyId, ceremonyId, giftId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') const normalizedGiftId = normalizeResourcePathId(giftId, '献礼标识') await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/gifts/${normalizedGiftId}`, method: 'DELETE' }, { requireData: false, requestController: requestOptions.requestController ?? null }) return null }, async getCeremonies(genealogyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const ceremonies = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeAppCeremonies(ceremonies, normalizedGenealogyId) }, async replaceCeremonyInvitees(genealogyId, ceremonyId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') const invitees = normalizeCeremonyInviteePayload(payload) const invitations = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/invitees`, method: 'PUT', data: invitees }, { requestController: requestOptions.requestController ?? null }) return normalizeCeremonyInvitationRows(invitations, normalizedGenealogyId) }, async getCeremonyInviteeOptions(genealogyId, ceremonyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') const options = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/invitee-options`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeCeremonyInviteeOptions(options) }, async getCeremonyInvitations(genealogyId, ceremonyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') const invitations = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/invitations`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeCeremonyInvitationRows(invitations, normalizedGenealogyId) }, async respondToCeremonyInvitation(genealogyId, ceremonyId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') const response = normalizeCeremonyInvitationResponsePayload(payload) return requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/invitations/me`, method: 'PUT', data: response }, { requestController: requestOptions.requestController ?? null }) }, async getMyCeremonyInvitations(requestOptions = {}) { const invitations = await requestStrict({ url: '/genealogy/app/genealogies/ceremony-invitations/mine', method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeCeremonyInvitationRows(invitations) }, async getCeremonyDetail(genealogyId, ceremonyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') const ceremony = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeAppCeremony(ceremony, normalizedGenealogyId, normalizedCeremonyId) }, async getCeremonyGifts(genealogyId, ceremonyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识') const gifts = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/gifts`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeAppCeremonyGifts(gifts, normalizedGenealogyId, normalizedCeremonyId) } }