const data = [
  { can_id: "123", interval: 1000 },
  { can_id: "456", interval: 0 },
  { can_id: "789-1000", interval: 5 }
];

const canFiltersAPI = {
  addFilter: async (vin, filter, token) => {
    data.push(filter);
    return filter;
  },
  getFilters: async (vin, search, token) => {
    return { data };
  },
  updateFilter: async (vin, canID, filter, token) => {
    const index = data.findIndex(element => element.can_id === canID);
    if (index >= 0) data[index] = filter;
    return filter;
  },
  deleteFilter: async (vin, canID, token) => {
    const index = data.findIndex(element => element.can_id === canID);
    if (index >= 0) data.splice(index, 1);
    return canID;
  },
};

export default canFiltersAPI;
