summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
306f9c9)
Feature #13702
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>
export default class CommonResourceService<T extends Resource> {
export default class CommonResourceService<T extends Resource> {
- serverApi: AxiosInstance;
- resourceType: string;
-
static mapResponseKeys = (response: any): Promise<any> =>
CommonResourceService.mapKeys(_.camelCase)(response.data)
static mapResponseKeys = (response: any): Promise<any> =>
CommonResourceService.mapKeys(_.camelCase)(response.data)
+ protected serverApi: AxiosInstance;
+ protected resourceType: string;
+
constructor(serverApi: AxiosInstance, resourceType: string) {
this.serverApi = serverApi;
constructor(serverApi: AxiosInstance, resourceType: string) {
this.serverApi = serverApi;
- this.resourceType = "/" + resourceType;
+ this.resourceType = '/' + resourceType + '/';
delete(uuid: string): Promise<T> {
return this.serverApi
delete(uuid: string): Promise<T> {
return this.serverApi
- .delete(this.resourceType + "/" + uuid)
+ .delete(this.resourceType + uuid)
.then(CommonResourceService.mapResponseKeys);
}
get(uuid: string) {
return this.serverApi
.then(CommonResourceService.mapResponseKeys);
}
get(uuid: string) {
return this.serverApi
- .get<T>(this.resourceType + "/" + uuid)
+ .get<T>(this.resourceType + uuid)
.then(CommonResourceService.mapResponseKeys);
}
.then(CommonResourceService.mapResponseKeys);
}
order: order ? order.get() : undefined
};
return this.serverApi
order: order ? order.get() : undefined
};
return this.serverApi
- .get(this.resourceType + `/${uuid}/contents`, {
+ .get(this.resourceType + `${uuid}/contents/`, {
params: CommonResourceService.mapKeys(_.snakeCase)(params)
})
.then(CommonResourceService.mapResponseKeys);
params: CommonResourceService.mapKeys(_.snakeCase)(params)
})
.then(CommonResourceService.mapResponseKeys);