Skip to content

Commit

Permalink
feat: add family API and types
Browse files Browse the repository at this point in the history
  • Loading branch information
timepresent95 committed Aug 20, 2024
1 parent e932547 commit f587e53
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/api/family.ts
Original file line number Diff line number Diff line change
@@ -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<ResponseGetFamilyCode>();
}

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<ResponseRefreshFamilyCode>();
}

export {getFamilyCode, postSurvey};
export type {
ParamGetFamilyCode,
ResponseGetFamilyCode,
ParamRefreshFamilyCode,
ResponseRefreshFamilyCode,
};

0 comments on commit f587e53

Please sign in to comment.