8
8
9
9
namespace OCA \Polls \Controller ;
10
10
11
- use OCA \Polls \ResponseDefinitions as ResponseDefinitions ;
12
11
use OCA \Polls \Service \CommentService ;
13
12
use OCA \Polls \Service \OptionService ;
14
13
use OCA \Polls \Service \PollService ;
24
23
25
24
/**
26
25
* @psalm-api
27
- * @psalm-import-type PollsPoll from ResponseDefinitions
26
+ * @psalm-import-type PollsPoll from \OCA\Polls\ ResponseDefinitions
28
27
* */
29
28
class PollApiController extends BaseApiV2Controller {
30
29
public function __construct (
@@ -46,7 +45,7 @@ public function __construct(
46
45
#[CORS ]
47
46
#[NoAdminRequired]
48
47
#[NoCSRFRequired]
49
- #[ApiRoute(verb: 'GET ' , url: '/api/{apiVersion} /polls ' , requirements: ['apiVersion ' => '(v2) ' ])]
48
+ #[ApiRoute(verb: 'GET ' , url: '/api/v1.0 /polls ' , requirements: ['apiVersion ' => '(v2) ' ])]
50
49
public function list (): DataResponse {
51
50
return $ this ->response (fn () => ['polls ' => $ this ->pollService ->list ()]);
52
51
}
@@ -58,7 +57,7 @@ public function list(): DataResponse {
58
57
#[CORS ]
59
58
#[NoAdminRequired]
60
59
#[NoCSRFRequired]
61
- #[ApiRoute(verb: 'GET ' , url: '/api/{apiVersion} /poll/{pollId} ' , requirements: ['apiVersion ' => '(v2) ' ])]
60
+ #[ApiRoute(verb: 'GET ' , url: '/api/v1.0 /poll/{pollId} ' , requirements: ['apiVersion ' => '(v2) ' ])]
62
61
public function get (int $ pollId ): DataResponse {
63
62
return $ this ->response (fn () => [
64
63
'poll ' => $ this ->pollService ->get ($ pollId ),
@@ -78,7 +77,7 @@ public function get(int $pollId): DataResponse {
78
77
#[CORS ]
79
78
#[NoAdminRequired]
80
79
#[NoCSRFRequired]
81
- #[ApiRoute(verb: 'POST ' , url: '/api/{apiVersion} /poll ' , requirements: ['apiVersion ' => '(v2) ' ])]
80
+ #[ApiRoute(verb: 'POST ' , url: '/api/v1.0 /poll ' , requirements: ['apiVersion ' => '(v2) ' ])]
82
81
public function add (string $ type , string $ title ): DataResponse {
83
82
return $ this ->responseCreate (fn () => ['poll ' => $ this ->pollService ->add ($ type , $ title )]);
84
83
}
@@ -91,7 +90,7 @@ public function add(string $type, string $title): DataResponse {
91
90
#[CORS ]
92
91
#[NoAdminRequired]
93
92
#[NoCSRFRequired]
94
- #[ApiRoute(verb: 'PUT ' , url: '/api/{apiVersion} /poll/{pollId} ' , requirements: ['apiVersion ' => '(v2) ' ])]
93
+ #[ApiRoute(verb: 'PUT ' , url: '/api/v1.0 /poll/{pollId} ' , requirements: ['apiVersion ' => '(v2) ' ])]
95
94
public function update (int $ pollId , array $ pollConfiguration ): DataResponse {
96
95
return $ this ->response (fn () => ['poll ' => $ this ->pollService ->update ($ pollId , $ pollConfiguration )]);
97
96
}
@@ -103,7 +102,7 @@ public function update(int $pollId, array $pollConfiguration): DataResponse {
103
102
#[CORS ]
104
103
#[NoAdminRequired]
105
104
#[NoCSRFRequired]
106
- #[ApiRoute(verb: 'PUT ' , url: '/api/{apiVersion} /poll/{pollId}/archive/toggle ' , requirements: ['apiVersion ' => '(v2) ' ])]
105
+ #[ApiRoute(verb: 'PUT ' , url: '/api/v1.0 /poll/{pollId}/archive/toggle ' , requirements: ['apiVersion ' => '(v2) ' ])]
107
106
public function toggleArchive (int $ pollId ): DataResponse {
108
107
return $ this ->response (fn () => ['poll ' => $ this ->pollService ->toggleArchive ($ pollId )]);
109
108
}
@@ -115,7 +114,7 @@ public function toggleArchive(int $pollId): DataResponse {
115
114
#[CORS ]
116
115
#[NoAdminRequired]
117
116
#[NoCSRFRequired]
118
- #[ApiRoute(verb: 'PUT ' , url: '/api/{apiVersion} /poll/{pollId}/close ' , requirements: ['apiVersion ' => '(v2) ' ])]
117
+ #[ApiRoute(verb: 'PUT ' , url: '/api/v1.0 /poll/{pollId}/close ' , requirements: ['apiVersion ' => '(v2) ' ])]
119
118
public function close (int $ pollId ): DataResponse {
120
119
return $ this ->response (fn () => ['poll ' => $ this ->pollService ->close ($ pollId )]);
121
120
}
@@ -127,7 +126,7 @@ public function close(int $pollId): DataResponse {
127
126
#[CORS ]
128
127
#[NoAdminRequired]
129
128
#[NoCSRFRequired]
130
- #[ApiRoute(verb: 'PUT ' , url: '/api/{apiVersion} /poll/{pollId}/reopen ' , requirements: ['apiVersion ' => '(v2) ' ])]
129
+ #[ApiRoute(verb: 'PUT ' , url: '/api/v1.0 /poll/{pollId}/reopen ' , requirements: ['apiVersion ' => '(v2) ' ])]
131
130
public function reopen (int $ pollId ): DataResponse {
132
131
return $ this ->response (fn () => ['poll ' => $ this ->pollService ->reopen ($ pollId )]);
133
132
}
@@ -139,7 +138,7 @@ public function reopen(int $pollId): DataResponse {
139
138
#[CORS ]
140
139
#[NoAdminRequired]
141
140
#[NoCSRFRequired]
142
- #[ApiRoute(verb: 'DELETE ' , url: '/api/{apiVersion} /poll/{pollId} ' , requirements: ['apiVersion ' => '(v2) ' ])]
141
+ #[ApiRoute(verb: 'DELETE ' , url: '/api/v1.0 /poll/{pollId} ' , requirements: ['apiVersion ' => '(v2) ' ])]
143
142
public function delete (int $ pollId ): DataResponse {
144
143
return $ this ->response (fn () => ['poll ' => $ this ->pollService ->delete ($ pollId )]);
145
144
}
@@ -151,7 +150,7 @@ public function delete(int $pollId): DataResponse {
151
150
#[CORS ]
152
151
#[NoAdminRequired]
153
152
#[NoCSRFRequired]
154
- #[ApiRoute(verb: 'POST ' , url: '/api/{apiVersion} /poll/{pollId}/clone ' , requirements: ['apiVersion ' => '(v2) ' ])]
153
+ #[ApiRoute(verb: 'POST ' , url: '/api/v1.0 /poll/{pollId}/clone ' , requirements: ['apiVersion ' => '(v2) ' ])]
155
154
public function clone (int $ pollId ): DataResponse {
156
155
return $ this ->responseCreate (fn () => ['poll ' => $ this ->pollService ->clone ($ pollId )]);
157
156
}
@@ -163,19 +162,19 @@ public function clone(int $pollId): DataResponse {
163
162
*/
164
163
#[CORS ]
165
164
#[NoCSRFRequired]
166
- #[ApiRoute(verb: 'PUT ' , url: '/api/{apiVersion} /poll/transfer/{sourceUser}/{targetUser} ' , requirements: ['apiVersion ' => '(v2) ' ])]
165
+ #[ApiRoute(verb: 'PUT ' , url: '/api/v1.0 /poll/transfer/{sourceUser}/{targetUser} ' , requirements: ['apiVersion ' => '(v2) ' ])]
167
166
public function transferPolls (string $ sourceUser , string $ targetUser ): DataResponse {
168
167
return $ this ->response (fn () => ['transferred ' => $ this ->pollService ->transferPolls ($ sourceUser , $ targetUser )]);
169
168
}
170
169
171
170
/**
172
- * Transfer singe poll to another user (change owner of poll)
171
+ * Transfer single poll to another user (change owner of poll)
173
172
* @param int $pollId Poll to transfer
174
173
* @param string $targetUser User to transfer the poll to
175
174
*/
176
175
#[CORS ]
177
176
#[NoCSRFRequired]
178
- #[ApiRoute(verb: 'PUT ' , url: '/api/{apiVersion} /poll/{pollId}/transfer/{targetUser} ' , requirements: ['apiVersion ' => '(v2) ' ])]
177
+ #[ApiRoute(verb: 'PUT ' , url: '/api/v1.0 /poll/{pollId}/transfer/{targetUser} ' , requirements: ['apiVersion ' => '(v2) ' ])]
179
178
public function transferPoll (int $ pollId , string $ targetUser ): DataResponse {
180
179
return $ this ->response (fn () => ['transferred ' => $ this ->pollService ->transferPoll ($ pollId , $ targetUser )]);
181
180
}
@@ -187,7 +186,7 @@ public function transferPoll(int $pollId, string $targetUser): DataResponse {
187
186
#[CORS ]
188
187
#[NoAdminRequired]
189
188
#[NoCSRFRequired]
190
- #[ApiRoute(verb: 'GET ' , url: '/api/{apiVersion} /poll/{pollId}/addresses ' , requirements: ['apiVersion ' => '(v2) ' ])]
189
+ #[ApiRoute(verb: 'GET ' , url: '/api/v1.0 /poll/{pollId}/addresses ' , requirements: ['apiVersion ' => '(v2) ' ])]
191
190
public function getParticipantsEmailAddresses (int $ pollId ): DataResponse {
192
191
return $ this ->response (fn () => ['addresses ' => $ this ->pollService ->getParticipantsEmailAddresses ($ pollId )]);
193
192
}
@@ -198,7 +197,7 @@ public function getParticipantsEmailAddresses(int $pollId): DataResponse {
198
197
#[CORS ]
199
198
#[NoAdminRequired]
200
199
#[NoCSRFRequired]
201
- #[ApiRoute(verb: 'GET ' , url: '/api/{apiVersion}/poll /enum ' , requirements: ['apiVersion ' => '(v2) ' ])]
200
+ #[ApiRoute(verb: 'GET ' , url: '/api/v1.0 /enum ' , requirements: ['apiVersion ' => '(v2) ' ])]
202
201
public function enum (): DataResponse {
203
202
return $ this ->response (fn () => ['enum ' => $ this ->pollService ->getValidEnum ()]);
204
203
}
0 commit comments