-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7357758
commit 1034917
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {kyInstance} from './ky'; | ||
import {myApis} from './routes'; | ||
|
||
import {UserInfo} from '@/types'; | ||
import {createUrl} from '@/utils/url'; | ||
|
||
type ParamGetMy = {userId: string}; | ||
|
||
type ResponseGetMy = { | ||
family: UserInfo[]; | ||
familyCode: string; | ||
} & UserInfo; | ||
|
||
async function getMy({userId}: ParamGetMy) { | ||
const apiUrl = createUrl(myApis.getMy, {param: {userId}}); | ||
return await kyInstance.get(apiUrl).json<ResponseGetMy>(); | ||
} | ||
|
||
type ParamPatchMy = {userId: string}; | ||
|
||
async function patchMy({userId}: ParamPatchMy) { | ||
const apiUrl = createUrl(myApis.patchMy, {param: {userId}}); | ||
return await kyInstance.patch(apiUrl).json<ResponseGetMy>(); | ||
} | ||
|
||
type ParamWithdraw = {userId: string}; | ||
|
||
async function withdraw({userId}: ParamWithdraw) { | ||
const apiUrl = createUrl(myApis.withdraw, {param: {userId}}); | ||
return await kyInstance.delete(apiUrl).json<ResponseGetMy>(); | ||
} | ||
|
||
export {getMy, patchMy, withdraw}; | ||
export type {ParamGetMy, ParamPatchMy, ParamWithdraw, ResponseGetMy}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters