15921: Avoids adding a trailing slash to every resourceType.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 10 Dec 2019 21:43:48 +0000 (18:43 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 10 Dec 2019 21:43:48 +0000 (18:43 -0300)
Updates API calls adding slashes where really needed.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/services/common-service/common-service.ts
src/services/common-service/trashable-resource-service.ts
src/services/groups-service/groups-service.ts
src/services/user-service/user-service.ts

index 212f2f4d0305fbf36a54bce6393a16506ff2d005..1c1e0a569d7e485080fa6c9f934177b188c4fc27 100644 (file)
@@ -38,7 +38,7 @@ export class CommonService<T> {
 
     constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions) {
         this.serverApi = serverApi;
-        this.resourceType = '/' + resourceType + '/';
+        this.resourceType = '/' + resourceType;
         this.actions = actions;
     }
 
@@ -93,7 +93,7 @@ export class CommonService<T> {
     delete(uuid: string): Promise<T> {
         return CommonService.defaultResponse(
             this.serverApi
-                .delete(this.resourceType + uuid),
+                .delete(this.resourceType + '/' + uuid),
             this.actions
         );
     }
@@ -101,7 +101,7 @@ export class CommonService<T> {
     get(uuid: string) {
         return CommonService.defaultResponse(
             this.serverApi
-                .get<T>(this.resourceType + uuid),
+                .get<T>(this.resourceType + '/' + uuid),
             this.actions
         );
     }
@@ -125,7 +125,7 @@ export class CommonService<T> {
     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
         );
     }
index 633b2fbd89cdf09041e4c93ee001916599763d62..5746bffb83136a6a80723d7da58b28ae0fe69301 100644 (file)
@@ -17,7 +17,7 @@ export class TrashableResourceService<T extends TrashableResource> extends Commo
     trash(uuid: string): Promise<T> {
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .post(this.resourceType + `${uuid}/trash`),
+                .post(this.resourceType + `/${uuid}/trash`),
             this.actions
         );
     }
@@ -28,7 +28,7 @@ export class TrashableResourceService<T extends TrashableResource> extends Commo
         };
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .post(this.resourceType + `${uuid}/untrash`, {
+                .post(this.resourceType + `/${uuid}/untrash`, {
                     params: CommonResourceService.mapKeys(_.snakeCase)(params)
                 }),
             this.actions
index 691ab8f7ccdb670affa90374cead8f4a783ca25a..281aa92152abaaa07f46b169b90ffef27308edaf 100644 (file)
@@ -46,8 +46,7 @@ export class GroupsService<T extends GroupResource = GroupResource> extends Tras
             filters: filters ? `[${filters}]` : undefined,
             order: order ? order : undefined
         };
-
-        const pathUrl = uuid ? `${uuid}/contents` : 'contents';
+        const pathUrl = uuid ? `/${uuid}/contents` : '/contents';
 
         const cfg: AxiosRequestConfig = { params: CommonResourceService.mapKeys(_.snakeCase)(params) };
         if (session) {
@@ -65,7 +64,7 @@ export class GroupsService<T extends GroupResource = GroupResource> extends Tras
     shared(params: SharedArguments = {}): Promise<ListResults<GroupContentsResource>> {
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .get(this.resourceType + 'shared', { params }),
+                .get(this.resourceType + '/shared', { params }),
             this.actions
         );
     }
index ddb9a3646b33e11717e89b0380e17d37711e9b04..d8c7fe3d94f24d6a9f276947dc58a56ef11c9c81 100644 (file)
@@ -15,7 +15,7 @@ export class UserService extends CommonResourceService<UserResource> {
     activate(uuid: string) {
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .post(this.resourceType + `${uuid}/activate`),
+                .post(this.resourceType + `/${uuid}/activate`),
             this.actions
         );
     }
@@ -23,7 +23,7 @@ export class UserService extends CommonResourceService<UserResource> {
     unsetup(uuid: string) {
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .post(this.resourceType + uuid + '/unsetup'),
+                .post(this.resourceType + `/${uuid}/unsetup`),
             this.actions
         );
     }