import {scandApiRequest} from '@helpers/apiHelpers.js'

class ApiOfPacks {

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

  /**
   * 
   * @param {String} imei
   * @param {String} dtStart
   * @param {String} dtFinish
   * @returns {Promise<Array>}
   */
  async fetchLastPacks(imei, dtStart, dtFinish) {
    let result = await scandApiRequest(this.url, 'ScandApi.LiveMonitor.Packs', 'get_last_pacs_info', [imei, dtStart, dtFinish])
    return result
  }

  /**
   * 
   * @param {Array} packs
   * @param {String} imei
   * @param {String} dtStart
   * @param {String} dtFinish
   * @param {Object} pagination
   * @param {Object} settings
   * @returns {Promise<Object>}
   */
  async fetchFreePacks({packs, imei, dt_start, dt_finish, pagination, settings}) {
    let result = await scandApiRequest(this.url, 'ScandApi.LiveMonitor.Packs', 'get_raw_data_122', [{packs, imei, dt_start, dt_finish}, {pagination, settings}])
    return result
  }

}

export default ApiOfPacks