Merge development (#86)
This commit is contained in:
50
src/services/updatesAPI.js
Normal file
50
src/services/updatesAPI.js
Normal file
@@ -0,0 +1,50 @@
|
||||
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),
|
||||
|
||||
getCarUpdateLog: async (query, token) => {
|
||||
const u = addQueryParams(`${API_ENDPOINT}/carupdateslog`, query);
|
||||
return fetch(u, {
|
||||
method: "GET",
|
||||
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
|
||||
})
|
||||
.then(fetchRespHandler);
|
||||
},
|
||||
|
||||
getCarUpdateProgress: async (carupdateids, token) => {
|
||||
const u = `${API_ENDPOINT}/carupdatesstatuses?carupdateids=${carupdateids}`;
|
||||
return fetch(u, {
|
||||
method: "GET",
|
||||
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
|
||||
})
|
||||
.then(fetchRespHandler);
|
||||
},
|
||||
|
||||
getCarUpdates: async (search, token) => {
|
||||
const u = addQueryParams(`${API_ENDPOINT}/carupdates`, search);
|
||||
return fetch(u, {
|
||||
method: "GET",
|
||||
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
|
||||
})
|
||||
.then(fetchRespHandler);
|
||||
},
|
||||
|
||||
getVINUpdates: async (vin, token) => {
|
||||
const u = addQueryParams(`${API_ENDPOINT}/carupdates`, { vin });
|
||||
return fetch(u, {
|
||||
method: "GET",
|
||||
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
|
||||
})
|
||||
.then(fetchRespHandler);
|
||||
},
|
||||
};
|
||||
|
||||
export default updatesAPI;
|
||||
Reference in New Issue
Block a user