import request from '@/utils/request'

// 创建
export async function createCurrencyRate({ sourceId, targetId, sourceAmount, targetAmount, countries, expiration, remarks, }) {
  return await request.post('/ecw/currency-rate/create', { sourceId, targetId, sourceAmount, targetAmount, countries, expiration, remarks, })
}

// 更新
export async function updateCurrencyRate(id, { sourceAmount, targetAmount, countries, expiration, remarks, }) {
  return await request.put('/ecw/currency-rate/update', { sourceAmount, targetAmount, countries, expiration, remarks, }, { params: { id, }, })
}

// 删除
export async function deleteCurrencyRate(id) {
  return await request.delete('/ecw/currency-rate/delete', { params: { id, }, })
}

// 获得
export async function getCurrencyRate({ sourceId, targetId, }) {
  return await request.get('/ecw/currency-rate/get', { params: { sourceId, targetId, }, })
}

// 获得分页
export async function getCurrencyRatePage({ sourceId, targetId, countries, expired, expiration, page, rows, }) {
  return await request.get('/ecw/currency-rate/page', { params: { sourceId, targetId, countries, expired, expirationAfter: expiration[0], expirationBefore: expiration[1], page, rows, }, })
}

// 获得日志分页
export async function getCurrencyRateLogs({ id, page, rows, }) {
  return await request.get('/ecw/currency-rate/logs', { params: { id, page, rows, }})
}
