From 7de811a9f42f8c65a9234ba2c9f15381c3af843a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=98=88=EC=A7=84?= Date: Sun, 11 Aug 2024 20:06:32 +0900 Subject: [PATCH] feat: use custom-instance --- src/types.ts | 335 +++++++++++++++++++++++++++------------------------ 1 file changed, 176 insertions(+), 159 deletions(-) diff --git a/src/types.ts b/src/types.ts index 36cd3dd..0e41bee 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,11 +5,7 @@ * GOOGOO API Documentation * OpenAPI spec version: 0.0.1 */ -import axios from 'axios' -import type { - AxiosRequestConfig, - AxiosResponse -} from 'axios' +import { customInstance } from './shared/lib/custom_instance'; export type LoginKakaoParams = { code: string; }; @@ -881,160 +877,181 @@ export interface UpdateLinkOpenRequest { - - export const updateLinkOpen = >( - updateLinkOpenRequest: UpdateLinkOpenRequest, options?: AxiosRequestConfig - ): Promise => { - return axios.put( - `/api/v1/link/link-open`, - updateLinkOpenRequest,options - ); - } - -export const regenerateLinkKey = >( - options?: AxiosRequestConfig - ): Promise => { - return axios.put( - `/api/v1/link/key`,undefined,options - ); - } - -export const updateInfo = >( - detailedInfoDto: DetailedInfoDto, options?: AxiosRequestConfig - ): Promise => { - return axios.put( - `/api/v1/info`, - detailedInfoDto,options - ); - } - -export const saveInfo = >( +type SecondParameter any> = Parameters[1]; + + + export const updateLinkOpen = ( + updateLinkOpenRequest: UpdateLinkOpenRequest, + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/link/link-open`, method: 'PUT', + headers: {'Content-Type': 'application/json', }, + data: updateLinkOpenRequest + }, + options); + } + +export const regenerateLinkKey = ( + + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/link/key`, method: 'PUT' + }, + options); + } + +export const updateInfo = ( + detailedInfoDto: DetailedInfoDto, + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/info`, method: 'PUT', + headers: {'Content-Type': 'application/json', }, + data: detailedInfoDto + }, + options); + } + +export const saveInfo = ( saveInfoRequest: SaveInfoRequest, - params: SaveInfoParams, options?: AxiosRequestConfig - ): Promise => { - return axios.post( - `/api/v1/info`, - saveInfoRequest,{ - ...options, - params: {...params, ...options?.params},} - ); - } - -export const createLink = >( - options?: AxiosRequestConfig - ): Promise => { - return axios.post( - `/api/v1/link`,undefined,options - ); - } - -export const uploadImage = >( - uploadImageBody: UploadImageBody, options?: AxiosRequestConfig - ): Promise => {const formData = new FormData(); + params: SaveInfoParams, + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/info`, method: 'POST', + headers: {'Content-Type': 'application/json', }, + data: saveInfoRequest, + params + }, + options); + } + +export const createLink = ( + + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/link`, method: 'POST' + }, + options); + } + +export const uploadImage = ( + uploadImageBody: UploadImageBody, + options?: SecondParameter,) => {const formData = new FormData(); formData.append('image', uploadImageBody.image) - return axios.post( - `/api/v1/image/upload`, - formData,options - ); - } - -export const refreshToken = >( - refreshTokenRequest: RefreshTokenRequest, options?: AxiosRequestConfig - ): Promise => { - return axios.post( - `/api/v1/auth/refresh-token`, - refreshTokenRequest,options - ); - } - -export const logout = >( - options?: AxiosRequestConfig - ): Promise => { - return axios.post( - `/api/v1/auth/logout`,undefined,options - ); - } - -export const validateLink = >( - linkKey: string, options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/api/v1/link/valid/${linkKey}`,options - ); - } - -export const getLinkByMatchMakerId = >( - options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/api/v1/link/status`,options - ); - } - -export const getInfo = >( - id: string, options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/api/v1/info/detail/${id}`,options - ); - } - -export const getAllInfo = >( - options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/api/v1/info/all`,options - ); - } - -export const getAddress = >( - options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/api/v1/info/address`,options - ); - } - -export const loginKakao = >( - params: LoginKakaoParams, options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/api/v1/auth/kakao/login`,{ - ...options, - params: {...params, ...options?.params},} - ); - } - -export const info = >( - options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/api/v1/auth/info`,options - ); - } - -export const deleteInfo = >( - id: string, options?: AxiosRequestConfig - ): Promise => { - return axios.delete( - `/api/v1/info/${id}`,options - ); - } - -export type UpdateLinkOpenResult = AxiosResponse -export type RegenerateLinkKeyResult = AxiosResponse -export type UpdateInfoResult = AxiosResponse -export type SaveInfoResult = AxiosResponse -export type CreateLinkResult = AxiosResponse -export type UploadImageResult = AxiosResponse -export type RefreshTokenResult = AxiosResponse -export type LogoutResult = AxiosResponse -export type ValidateLinkResult = AxiosResponse -export type GetLinkByMatchMakerIdResult = AxiosResponse -export type GetInfoResult = AxiosResponse -export type GetAllInfoResult = AxiosResponse -export type GetAddressResult = AxiosResponse -export type LoginKakaoResult = AxiosResponse -export type InfoResult = AxiosResponse -export type DeleteInfoResult = AxiosResponse + return customInstance( + {url: `/api/v1/image/upload`, method: 'POST', + headers: {'Content-Type': 'multipart/form-data', }, + data: formData + }, + options); + } + +export const refreshToken = ( + refreshTokenRequest: RefreshTokenRequest, + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/auth/refresh-token`, method: 'POST', + headers: {'Content-Type': 'application/json', }, + data: refreshTokenRequest + }, + options); + } + +export const logout = ( + + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/auth/logout`, method: 'POST' + }, + options); + } + +export const validateLink = ( + linkKey: string, + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/link/valid/${linkKey}`, method: 'GET' + }, + options); + } + +export const getLinkByMatchMakerId = ( + + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/link/status`, method: 'GET' + }, + options); + } + +export const getInfo = ( + id: string, + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/info/detail/${id}`, method: 'GET' + }, + options); + } + +export const getAllInfo = ( + + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/info/all`, method: 'GET' + }, + options); + } + +export const getAddress = ( + + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/info/address`, method: 'GET' + }, + options); + } + +export const loginKakao = ( + params: LoginKakaoParams, + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/auth/kakao/login`, method: 'GET', + params + }, + options); + } + +export const info = ( + + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/auth/info`, method: 'GET' + }, + options); + } + +export const deleteInfo = ( + id: string, + options?: SecondParameter,) => { + return customInstance( + {url: `/api/v1/info/${id}`, method: 'DELETE' + }, + options); + } + +export type UpdateLinkOpenResult = NonNullable>> +export type RegenerateLinkKeyResult = NonNullable>> +export type UpdateInfoResult = NonNullable>> +export type SaveInfoResult = NonNullable>> +export type CreateLinkResult = NonNullable>> +export type UploadImageResult = NonNullable>> +export type RefreshTokenResult = NonNullable>> +export type LogoutResult = NonNullable>> +export type ValidateLinkResult = NonNullable>> +export type GetLinkByMatchMakerIdResult = NonNullable>> +export type GetInfoResult = NonNullable>> +export type GetAllInfoResult = NonNullable>> +export type GetAddressResult = NonNullable>> +export type LoginKakaoResult = NonNullable>> +export type InfoResult = NonNullable>> +export type DeleteInfoResult = NonNullable>>