import { getAuthHeaderOptions, fetchRespHandler, addQueryParams } from "../utils/http"; const API_ENDPOINT = process.env.REACT_APP_UPLOAD_SERVICE_URL || "https://gw-dev.fiskerdps.com/ota_update"; const updatesAPI = { createCarUpdates: async (data, token) => fetch(`${API_ENDPOINT}/carupdate`, { method: "POST", headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)), body: JSON.stringify(data), }) .then(fetchRespHandler), getPackages: async (search, token) => { var u = addQueryParams(`${API_ENDPOINT}/updates`, search); return fetch(u, { method: "GET", headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)), }) .then(fetchRespHandler); }, updatePackage: async (update, token) => fetch(`${API_ENDPOINT}/update`, { method: "PUT", headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)), body: JSON.stringify(update), }) .then(fetchRespHandler), getCarUpdates: async (search, token) => { var u = addQueryParams(`${API_ENDPOINT}/carupdates`, search); return fetch(u, { method: "GET", headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)), }) .then(fetchRespHandler); }, }; export default updatesAPI;