import {scandApiRequest} from '@helpers/apiHelpers.js'
import {Adapter} from '1-toolkits-helpers'

const {convertList} = Adapter

const machinesConfig = {
  zav_nomer: 'zavNomer',
  type: 'type',
  railway_name: 'railwayName',
  org_name: 'orgName',
  nomer_zn8: 'nomerZn8',
  machine_type: 'machineType',
  machine_id: 'machineId',
  imei: 'imei',
  device_number: 'deviceNumber',
  device_id: 'deviceId' 
}

class AdapterOfMachines {

  /**
   *
   * @param {String} url
   */
  constructor(url) {
    this.url = url
  }

  async getModalMachines() {
    let result = await scandApiRequest('ScandApi.LiveMonitor.Machines', 'select_machines', [])
    result = convertList(result, {
      config: machinesConfig
    })
    return result
  }
}

export default AdapterOfMachines