import { http } from '../../../server'
import {
    IsubscribePlanParams,
    IbindwxParams,
    IpaginationParams,
    IgetPayStatus,
    IinvoiceParams,
    InoLoginParams,
    IpayPowerPackageParam,
    IpurchaseApiPlanParams,
} from './type'
import { AxiosRequestHeaders } from 'axios'

// my plan
export const getMyPlan = (data: InoLoginParams) => {
    return http.get('/myPlan', {
        params: data,
        headers: {} as AxiosRequestHeaders,
    })
}

// subscribe plan
export const subscribePlan = (data: IsubscribePlanParams) => {
    return http.post('/subscribePlan', data)
}

export const purchaseApiPlan = (data: IpurchaseApiPlanParams) => {
    return http.post('purchaseApiPlan', data)
}

export const recurSubscribePlan = (data: IsubscribePlanParams) => {
    return http.post('/recurSubscribePlan', data)
}

// 关注订阅
export const bindwx = (data: IbindwxParams) => {
    return http.post('/bindwx', data)
}

// 订单记录
export const getOrderList = (data: IpaginationParams) => {
    return http.get('/orderList', {
        params: data,
        headers: {} as AxiosRequestHeaders,
    })
}

export const getPaymentOrderStatus = (data: IgetPayStatus) => {
    return http.get('/paymentOrderStatus', {
        params: data,
        headers: {} as AxiosRequestHeaders,
    })
}

export const getPlans = () => {
    return http.get('/plans')
}

export const getMixPlan = () => {
    return http.get('/mixPlan')
}

// 申请发票
export const getRequestInvoice = (data: IinvoiceParams) => {
    return http.post('/requestInvoice', data)
}

// 获取所有加油包
export const getPowerPackage = () => {
    return http.get('/powerPackages')
}

// 购买加油包
export const payPowerPackage = (data: IpayPowerPackageParam) => {
    return http.post('/purchasePowerPackage', data)
}

// 取消订阅计划
export const cancelSubscribePlan = () => {
    return http.post('/cancelSubscribePlan')
}

//  创建邀请码
export const newInvitationID = () => {
    return http.post('/newInvitationID')
}

// 获取钱包信息
export const getWalletInfo = () => {
    return http.get('/wallet')
}

// 获取邀请码列表
export const getListInvitation = () => {
    return http.get('/listInvitationID')
}

// 获取季度年度套餐
export const getSameLevelPlans = (data: { level: string }) => {
    return http.get('/sameLevelPlans', {
        params: data,
        headers: {} as AxiosRequestHeaders,
    })
}

export const getReferralDetail = () => {
    return http.get('referral/myDetail', {
        headers: {} as AxiosRequestHeaders,
    })
}

// 获取邀请列表信息
export const getReferralInvList = (data: IpaginationParams) => {
    return http.get('referral/invite/list', {
        params: data,
        headers: {} as AxiosRequestHeaders,
    })
}

// 发送邀请邮件
export const referralSendEmail = (data: { email: string }) => {
    return http.post('referral/sendEmail', data)
}

// 获取登录页面获取邀请人的信息
export const getReferralInviter = (data: { inviterId: string }) => {
    return http.get('referral/inviter', {
        params: data,
        headers: {} as AxiosRequestHeaders,
    })
}
