import { request } from '@/api/_service'

const BASE = 'production_configuration/technology_model/optional_params/'

function apiParams (method, data = {}) {
  return {
    method: `production_configuration_technology_model_optional_params_${method}`,
    platform: 'background',
    ...data
  }
}

export function getOptionalParamsALL (data) {
  return request({
    url: BASE + 'all',
    method: 'get',
    params: apiParams('all', data)
  })
}

export function getOptionalParamsList (data) {
  return request({
    url: BASE + 'list',
    method: 'get',
    params: apiParams('list', data)
  })
}

export function createOptionalParams (data) {
  return request({
    url: BASE + 'create',
    method: 'post',
    data: apiParams('create', data)
  })
}

export function editOptionalParams (data) {
  return request({
    url: BASE + 'edit',
    method: 'put',
    data: apiParams('edit', data)
  })
}

export function deleteOptionalParams (data) {
  return request({
    url: BASE + 'delete',
    method: 'delete',
    data: apiParams('delete', data)
  })
}

export function getImportTemplate (data) {
  return request({
    url: BASE + 'get_import_template',
    method: 'post',
    responseType: 'blob',
    data: apiParams('get_import_template', data)
  })
}

export function importDataCreate (data) {
  return request({
    url: BASE + 'import_data_create',
    method: 'post',
    data: {
      method: 'production_configuration_technology_model_optional_params_import_data_create',
      platform: 'background',
      ...data
    }
  })
}
