import { del, post } from '@/lib/http/client'
import type {
  BindEmailRequest,
  BindPhoneRequest,
  SensitiveActionVerification,
  SendEmailBindCodeRequest,
  SendPhoneBindCodeRequest,
  SendPhoneBindCodeResponse,
} from '@/types'

export function sendEmailBindCode(payload: SendEmailBindCodeRequest): Promise<void> {
  return post<void>('/users/me/bind-email/code', payload)
}

export function bindEmail(payload: BindEmailRequest): Promise<void> {
  return post<void>('/users/me/bind-email', payload)
}

export function unbindEmail(payload?: SensitiveActionVerification): Promise<void> {
  return del<void>('/users/me/bind-email', { body: payload })
}

export function sendPhoneBindCode(
  payload: SendPhoneBindCodeRequest,
): Promise<SendPhoneBindCodeResponse> {
  return post<SendPhoneBindCodeResponse>('/users/me/bind-phone/code', payload)
}

export function bindPhone(payload: BindPhoneRequest): Promise<void> {
  return post<void>('/users/me/bind-phone', payload)
}

export function unbindPhone(payload?: SensitiveActionVerification): Promise<void> {
  return del<void>('/users/me/bind-phone', { body: payload })
}
