}
export interface ListResults<T> {
+ clusterId?: string;
kind: string;
offset: number;
limit: number;
constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions) {
this.serverApi = serverApi;
- this.resourceType = '/' + resourceType + '/';
+ this.resourceType = '/' + resourceType;
this.actions = actions;
}
.map(key => [key, mapFn(key)])
.reduce((newValue, [key, newKey]) => ({
...newValue,
- [newKey]: CommonService.mapKeys(mapFn)(value[key])
+ [newKey]: (key === 'items') ? CommonService.mapKeys(mapFn)(value[key]) : value[key]
}), {});
case _.isArray(value):
return value.map(CommonService.mapKeys(mapFn));
delete(uuid: string): Promise<T> {
return CommonService.defaultResponse(
this.serverApi
- .delete(this.resourceType + uuid),
+ .delete(this.resourceType + '/' + uuid),
this.actions
);
}
get(uuid: string) {
return CommonService.defaultResponse(
this.serverApi
- .get<T>(this.resourceType + uuid),
+ .get<T>(this.resourceType + '/' + uuid),
this.actions
);
}
update(uuid: string, data: Partial<T>) {
return CommonService.defaultResponse(
this.serverApi
- .put<T>(this.resourceType + uuid, data && CommonService.mapKeys(_.snakeCase)(data)),
+ .put<T>(this.resourceType + '/' + uuid, data && CommonService.mapKeys(_.snakeCase)(data)),
this.actions
);
}
-}
\ No newline at end of file
+}