diff --git a/src/downloader.ts b/src/downloader.ts index 97ea851..586a1f7 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -6,6 +6,7 @@ const fs = require("fs").promises; import * as config from "./config"; const ObjectsApi = new ForgeSDK.ObjectsApi(); +const ItemsApi = new ForgeSDK.ItemsApi(); /** * Kevin Pan | pan261@purdue.edu | Last Modified: 12/2/2021 @@ -34,27 +35,13 @@ exports.download = async (projectID: string, itemID: string, fileName: string, d }; const getStorageLocation = (projectID: string, itemID: string, credentials: ForgeSDK.AuthToken) => { - return axios.default({ - method: "GET", - url: `https://developer.api.autodesk.com/data/v1/projects/${projectID}/items/${itemID}`, - headers: { - Authorization: `Bearer ${credentials.access_token}`, - }, - }) - .then((res: axios.AxiosResponse) => { - let data = res.data.included[0]; + return ItemsApi.getItem(projectID, itemID, config.authClient, credentials) + .then((res: ForgeSDK.ApiResponse) => { + let data = res.body.included[0]; let storageID = data.relationships.storage.data.id; storageID = storageID.substring(storageID.indexOf("/") + 1); return storageID; - }) - .catch((err: axios.AxiosError) => { - if (err.response) { - console.log( - "unable to get storage location for " + - itemID + - ": " + - err.response.status - ); - } + }).catch((err: ForgeSDK.ApiError) => { + console.log("unable to get storage location for " + itemID + ": " + err.statusCode); }); };