diff --git a/src/api/family.ts b/src/api/family.ts new file mode 100644 index 0000000..db8f975 --- /dev/null +++ b/src/api/family.ts @@ -0,0 +1,38 @@ +import {kyInstance} from './ky'; +import {familyApis} from './routes'; + +import {createUrl} from '@/utils/url'; + +type ParamGetFamilyCode = { + familyId: string; +}; + +type ResponseGetFamilyCode = { + code: string; +}; + +async function getFamilyCode(param: ParamGetFamilyCode) { + const apiUrl = createUrl(familyApis.getFamilyCode, {param}); + return await kyInstance.get(apiUrl).json(); +} + +type ParamRefreshFamilyCode = { + familyId: string; +}; + +type ResponseRefreshFamilyCode = { + code: string; +}; + +async function postSurvey(param: ParamRefreshFamilyCode) { + const apiUrl = createUrl(familyApis.refreshFamilyCode, {param}); + return await kyInstance.post(apiUrl).json(); +} + +export {getFamilyCode, postSurvey}; +export type { + ParamGetFamilyCode, + ResponseGetFamilyCode, + ParamRefreshFamilyCode, + ResponseRefreshFamilyCode, +};