import { config, networkUtils } from '../../utils';

const { request } = networkUtils;
const { api } = config;
const { item } = api;
const { items} = item;

export async function query(params) {
  return request({
    url: `${items}/view`,
    method: 'get',
    data: params,
  });
}

export async function getSingle(id) {
  return request({
    url: `${items}/${id}`,
    method: 'get',
  });
}

export async function create(params) {
  return request({
    url: items,
    method: 'post',
    data: params,
  });
}

export async function remove(id) {
  return request({
    url: `${items}/del/${id}`,
    method: 'post',
  });
}

export async function update(params) {
  return request({
    url: items,
    method: 'put',
    data: params,
  });
}

export async function updateStatus(params) {
  const { id, itemStatus } = params
  return request({
    url: `${items}/${id}/status_update/${itemStatus}`,
    method: 'post',
  });
}

export async function isEnabled(id) {
  return request({
    url: `${items}/semi/${id}`,
    method: 'get',
  });
}

export async function isTrial(id) {
  return request({
    url: `${items}/isTrial/${id}`,
    method: 'get',
  });
}


export async function isInitialTrial(id) {
  return request({
    url: `${items}/isInitialTrial/${id}`,
    method: 'get',
  });
}