import { get, type ApiResponse } from '../utils/request'

export type UserConfig = {
  token?: string
  [key: string]: unknown
}

export type ServiceConfig = {
  corpid?: string
  'kf.address'?: string
  [key: string]: unknown
}

export type PackageInfo = {
  link?: string
  [key: string]: unknown
}

export function getConfig() {
  return get<ApiResponse<UserConfig>>('/api/user/config', undefined, { tokenType: 'permanent' })
}

export function getService(tokenType: 'permanent' | 'temporary') {
  return get<ApiResponse<ServiceConfig>>('/api/weixin/service', undefined, { tokenType })
}

export function getPackage() {
  return get<ApiResponse<PackageInfo>>('/api/package', undefined, { tokenType: 'temporary' })
}
