<script>
import { ref } from 'vue'
import axios from 'axios'
import {API_URL} from "@/main.js";

export const getScans = () => {
  const token = localStorage.getItem('token');
  if (!token) {
    return null;
  }
  return axios.get(API_URL + '/numberplatescans', {
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
};

export const getScansDepartmentPagination = (department_id, page, limit) => {
  const token = localStorage.getItem('token');
  if (!token) {
    return null;
  }
  return axios.post(API_URL + '/numberplatescans/department', {
    department_id,
    page,
    limit
  }, {
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
};

export const createScan = (scanner_api_key, numberplate) => {
  if (!scanner_api_key) {
    return null;
  }
  return axios.post(API_URL + '/numberplatescans', {
    plate: numberplate
  }
  , {
    headers: {
      Authorization: `Bearer ${scanner_api_key}`
    }
  });
};
</script>