Skip to content

Commit b83ebdf

Browse files
committed
🌱 Remove APIClient, update affected rest functions
Changes: - Remove `APIClient` - Update the affected functions in `rest.ts` to use axios directly - Double check the return types of the effected functions - Updated a few API model types based on current hub handler function responses Resolves: #1821 Part-of: #1411 Signed-off-by: Scott J Dickerson <[email protected]>
1 parent d929226 commit b83ebdf

File tree

5 files changed

+28
-90
lines changed

5 files changed

+28
-90
lines changed

client/src/app/api/models.ts

+10-11
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ export interface ApplicationDependency {
158158
export interface ApplicationAdoptionPlan {
159159
applicationId: number;
160160
applicationName: string;
161-
positionX: number;
162-
positionY: number;
163-
effort: number;
164161
decision: ProposedAction;
165162
effortEstimate: string;
163+
effort: number;
164+
positionX: number;
165+
positionY: number;
166166
}
167167

168168
export interface ApplicationImportSummary {
@@ -190,18 +190,17 @@ export type IdentityKind =
190190

191191
export interface Identity {
192192
id: number;
193+
createUser?: string;
194+
updateUser?: string;
195+
createTime?: string;
196+
197+
kind: IdentityKind;
193198
name: string;
194199
description?: string;
195-
kind?: IdentityKind;
196-
createUser?: string;
197-
encrypted?: string;
198-
key?: string;
199-
keyFilename?: string;
200-
password?: string;
201200
user?: string;
202-
updateUser?: string;
201+
password?: string;
202+
key?: string;
203203
settings?: string;
204-
settingsFilename?: string;
205204
}
206205

207206
export interface Proxy {

client/src/app/api/rest.ts

+17-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import axios, { AxiosPromise } from "axios";
2-
import { APIClient } from "@app/axios-config";
32

43
import {
54
AnalysisDependency,
@@ -136,7 +135,7 @@ export const getApplicationDependencies = (
136135
return axios
137136
.get(`${APPLICATION_DEPENDENCY}`, {
138137
params,
139-
headers: jsonHeaders,
138+
headers: jsonHeaders.headers,
140139
})
141140
.then((response) => response.data);
142141
};
@@ -179,21 +178,17 @@ export const deleteReview = (id: number): Promise<Review> => {
179178
return axios.delete(`${REVIEWS}/${id}`);
180179
};
181180

182-
export const getApplicationAdoptionPlan = (
183-
applicationIds: number[]
184-
): AxiosPromise<ApplicationAdoptionPlan[]> => {
185-
return APIClient.post(
181+
export const getApplicationAdoptionPlan = (applicationIds: number[]) => {
182+
return axios.post<ApplicationAdoptionPlan[]>(
186183
`${REPORT}/adoptionplan`,
187-
applicationIds.map((f) => ({
188-
applicationId: f,
189-
}))
184+
applicationIds.map((f) => ({ applicationId: f }))
190185
);
191186
};
192187

193-
export const getApplicationSummaryCSV = (id: string): AxiosPromise => {
194-
return APIClient.get(`${APP_IMPORT_CSV}?importSummaryId=${id}`, {
188+
export const getApplicationSummaryCSV = (id: string) => {
189+
return axios.get<ArrayBuffer>(`${APP_IMPORT_CSV}?importSummary.id=${id}`, {
195190
responseType: "arraybuffer",
196-
headers: { Accept: "text/csv", responseType: "blob" },
191+
headers: { Accept: "text/csv" },
197192
});
198193
};
199194

@@ -241,28 +236,26 @@ export const getAssessmentById = (id: number | string): Promise<Assessment> => {
241236
return axios.get(`${ASSESSMENTS}/${id}`).then((response) => response.data);
242237
};
243238

244-
export const deleteAssessment = (id: number): AxiosPromise => {
245-
return APIClient.delete(`${ASSESSMENTS}/${id}`);
239+
export const deleteAssessment = (id: number) => {
240+
return axios.delete<void>(`${ASSESSMENTS}/${id}`);
246241
};
247242

248-
export const getIdentities = (): AxiosPromise<Array<Identity>> => {
249-
return APIClient.get(`${IDENTITIES}`, jsonHeaders);
243+
export const getIdentities = () => {
244+
return axios.get<Identity[]>(`${IDENTITIES}`, jsonHeaders);
250245
};
251246

252-
export const createIdentity = (obj: New<Identity>): AxiosPromise<Identity> => {
253-
return APIClient.post(`${IDENTITIES}`, obj);
247+
export const createIdentity = (obj: New<Identity>) => {
248+
return axios.post<Identity>(`${IDENTITIES}`, obj);
254249
};
255250

256-
export const updateIdentity = (obj: Identity): AxiosPromise<Identity> => {
257-
return APIClient.put(`${IDENTITIES}/${obj.id}`, obj);
251+
export const updateIdentity = (obj: Identity) => {
252+
return axios.put<void>(`${IDENTITIES}/${obj.id}`, obj);
258253
};
259254

260-
export const deleteIdentity = (identity: Identity): AxiosPromise => {
261-
return APIClient.delete(`${IDENTITIES}/${identity.id}`);
255+
export const deleteIdentity = (identity: Identity) => {
256+
return axios.delete<void>(`${IDENTITIES}/${identity.id}`);
262257
};
263258

264-
// Axios direct
265-
266259
// success with code 201 and created entity as response data
267260
export const createApplication = (application: New<Application>) =>
268261
axios

client/src/app/axios-config/apiClient.tsx

-53
This file was deleted.

client/src/app/axios-config/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export { APIClient } from "./apiClient";
21
export { initInterceptors } from "./apiInit";

client/src/app/pages/identities/components/identity-form/identity-form.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type UserCredentials = "userpass" | "source";
4040
interface IdentityFormValues {
4141
name: string;
4242
description: string;
43-
kind?: IdentityKind;
43+
kind: IdentityKind;
4444
settings: string;
4545
settingsFilename: string;
4646
userCredentials?: UserCredentials;

0 commit comments

Comments
 (0)