@@ -27,33 +27,29 @@ class CollectionService {
27
27
28
28
constructor ( ) {
29
29
this . http = axios
30
- this . baseUrl = generateOcsUrl ( 'collaboration/resources' , 2 )
31
30
}
32
31
33
32
listCollection ( collectionId ) {
34
- return this . http . get ( ` ${ this . baseUrl } collections/$ {collectionId } ` )
33
+ return this . http . get ( generateOcsUrl ( 'collaboration/resources/ collections/{collectionId}' , { collectionId } ) )
35
34
}
36
35
37
36
renameCollection ( collectionId , collectionName ) {
38
- const resourceBase = generateOcsUrl ( 'collaboration/resources/collections' , 2 )
39
- return this . http . put ( `${ resourceBase } ${ collectionId } ?format=json` , {
37
+ return this . http . put ( generateOcsUrl ( 'collaboration/resources/collections/{collectionId}' , { collectionId } ) , {
40
38
collectionName
41
39
} ) . then ( result => {
42
40
return result . data . ocs . data
43
41
} )
44
42
}
45
43
46
44
getCollectionsByResource ( resourceType , resourceId ) {
47
- const resourceBase = generateOcsUrl ( `collaboration/resources/${ resourceType } ` , 2 )
48
- return this . http . get ( `${ resourceBase } ${ resourceId } ?format=json` )
45
+ return this . http . get ( generateOcsUrl ( 'collaboration/resources/{resourceType}/{resourceId}' , { resourceType, resourceId } ) )
49
46
. then ( result => {
50
47
return result . data . ocs . data
51
48
} )
52
49
}
53
50
54
51
createCollection ( resourceType , resourceId , name ) {
55
- const resourceBase = generateOcsUrl ( `collaboration/resources/${ resourceType } ` , 2 )
56
- return this . http . post ( `${ resourceBase } ${ resourceId } ?format=json` , {
52
+ return this . http . post ( generateOcsUrl ( 'collaboration/resources/{resourceType}/{resourceId}' , { resourceType, resourceId } ) , {
57
53
name : name
58
54
} )
59
55
. then ( ( response ) => {
@@ -63,8 +59,7 @@ class CollectionService {
63
59
64
60
addResource ( collectionId , resourceType , resourceId ) {
65
61
resourceId = '' + resourceId
66
- const resourceBase = generateOcsUrl ( 'collaboration/resources/collections' , 2 )
67
- return this . http . post ( `${ resourceBase } ${ collectionId } ?format=json` , {
62
+ return this . http . post ( generateOcsUrl ( 'collaboration/resources/collections/{collectionId}' , { collectionId } ) , {
68
63
resourceType,
69
64
resourceId
70
65
} ) . then ( ( response ) => {
@@ -73,16 +68,14 @@ class CollectionService {
73
68
}
74
69
75
70
removeResource ( collectionId , resourceType , resourceId ) {
76
- return this . http . delete ( ` ${ this . baseUrl } collections/$ {collectionId } ` , { params : { resourceType, resourceId } } )
71
+ return this . http . delete ( generateOcsUrl ( 'collaboration/resources/ collections/{collectionId}' , { collectionId } ) , { params : { resourceType, resourceId } } )
77
72
. then ( ( response ) => {
78
73
return response . data . ocs . data
79
74
} )
80
75
}
81
76
82
77
search ( query ) {
83
- query = encodeURI ( query )
84
- const searchBase = generateOcsUrl ( 'collaboration/resources/collections/search' , 2 )
85
- return this . http . get ( `${ searchBase } ${ query } ?format=json` )
78
+ return this . http . get ( generateOcsUrl ( 'collaboration/resources/collections/search/{query}' , { query } ) )
86
79
. then ( ( response ) => {
87
80
return response . data . ocs . data
88
81
} )
0 commit comments