CEC-3672 Update manifest version on deploy (#277)

* CEC-3672 Add versions to CarUpdatesContext
Stub out getSoftwareVersions and updateManifestVersion

* CEC-3672 update version on deploy

* Validate version before updating
This commit is contained in:
John Wu
2023-02-09 11:51:23 -08:00
committed by GitHub
parent f863f37a9a
commit 9cf84fc426
10 changed files with 240 additions and 75 deletions

View File

@@ -26,6 +26,16 @@ const updatesAPI = {
cancelCarUpdate: async (id, token) => {
return { message: "OK" };
},
getSoftwareVersions: async (token) => {
return {
"data": ["2023.02.01.0.0.A", "2023.02.01.0.0.B"]
};
},
updateManifestVersion: async (_id, version) => {
return { version };
},
};
export default updatesAPI;

View File

@@ -1,5 +1,5 @@
import {
addQueryParams, errorHandler, fetchRespHandler, getAuthHeaderOptions
addQueryParams, errorHandler, fetchRespHandler, getAuthHeaderOptions
} from "../utils/http";
const API_ENDPOINT = process.env.REACT_APP_OTA_SERVICE_URL;
@@ -86,6 +86,31 @@ const updatesAPI = {
.then(fetchRespHandler)
.catch(errorHandler);
},
getSoftwareVersions: async (token) => {
return fetch(`${API_ENDPOINT}/manifest/versions`, {
method: "GET",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
})
.then(fetchRespHandler)
.catch(errorHandler);
},
updateManifestVersion: async (id, version, token) => {
return fetch(`${API_ENDPOINT}/manifests/${id}/version`, {
method: "PUT",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token),
),
body: JSON.stringify({ version }),
})
.then(fetchRespHandler)
.catch(errorHandler);
}
};
export default updatesAPI;