@@ -57,20 +57,19 @@ public function __construct(
5757 * @return DataResponse
5858 */
5959 #[NoAdminRequired]
60- #[FrontpageRoute(verb: 'GET ' , url: '/service- list ' )]
60+ #[FrontpageRoute(verb: 'GET ' , url: '/service/ list ' )]
6161 public function serviceList (): DataResponse {
6262
6363 // evaluate if user id is present
6464 if ($ this ->userId === null ) {
6565 return new DataResponse ([], Http::STATUS_BAD_REQUEST );
6666 }
6767 // retrieve services
68- $ rs = $ this ->ServicesService ->fetchByUserId ($ this ->userId );
69- // return response
70- if (isset ($ rs )) {
68+ try {
69+ $ rs = $ this ->ServicesService ->fetchByUserId ($ this ->userId );
7170 return new DataResponse ($ rs );
72- } else {
73- return new DataResponse ($ rs [ ' error ' ], 401 );
71+ } catch ( \ Throwable $ th ) {
72+ return new DataResponse ($ th -> getMessage (), Http:: STATUS_INTERNAL_SERVER_ERROR );
7473 }
7574
7675 }
@@ -83,7 +82,7 @@ public function serviceList(): DataResponse {
8382 * @return DataResponse
8483 */
8584 #[NoAdminRequired]
86- #[FrontpageRoute(verb: 'GET ' , url: '/connect ' )]
85+ #[FrontpageRoute(verb: 'POST ' , url: '/service /connect ' )]
8786 public function Connect (array $ service ): DataResponse {
8887
8988 // evaluate if user id is present
@@ -93,14 +92,13 @@ public function Connect(array $service): DataResponse {
9392 // assign options
9493 $ options = ['VALIDATE ' ];
9594 // execute command
96- $ rs = $ this ->CoreService ->connectAccount ($ this ->userId , $ service , $ options );
97- // return response
98- if (isset ($ rs )) {
95+ try {
96+ $ rs = $ this ->CoreService ->connectAccount ($ this ->userId , $ service , $ options );
9997 return new DataResponse ('success ' );
100- } else {
101- return new DataResponse ($ rs [ ' error ' ], 401 );
98+ } catch ( \ Throwable $ th ) {
99+ return new DataResponse ($ th -> getMessage (), Http:: STATUS_INTERNAL_SERVER_ERROR );
102100 }
103-
101+
104102 }
105103
106104 /**
@@ -111,17 +109,20 @@ public function Connect(array $service): DataResponse {
111109 * @return DataResponse
112110 */
113111 #[NoAdminRequired]
114- #[FrontpageRoute(verb: 'GET ' , url: '/disconnect ' )]
112+ #[FrontpageRoute(verb: 'POST ' , url: '/service /disconnect ' )]
115113 public function Disconnect (int $ sid ): DataResponse {
116114
117115 // evaluate if user id is present
118116 if ($ this ->userId === null ) {
119117 return new DataResponse ([], Http::STATUS_BAD_REQUEST );
120118 }
121119 // execute command
122- $ this ->CoreService ->disconnectAccount ($ this ->userId , $ sid );
123- // return response
124- return new DataResponse ('success ' );
120+ try {
121+ $ this ->CoreService ->disconnectAccount ($ this ->userId , $ sid );
122+ return new DataResponse ('success ' );
123+ } catch (\Throwable $ th ) {
124+ return new DataResponse ($ th ->getMessage (), Http::STATUS_INTERNAL_SERVER_ERROR );
125+ }
125126
126127 }
127128
@@ -133,17 +134,20 @@ public function Disconnect(int $sid): DataResponse {
133134 * @return DataResponse
134135 */
135136 #[NoAdminRequired]
136- #[FrontpageRoute(verb: 'GET ' , url: '/harmonize ' )]
137+ #[FrontpageRoute(verb: 'POST ' , url: '/service /harmonize ' )]
137138 public function Harmonize (int $ sid ): DataResponse {
138139
139140 // evaluate if user id is present
140141 if ($ this ->userId === null ) {
141142 return new DataResponse ([], Http::STATUS_BAD_REQUEST );
142143 }
143144 // execute command
144- $ this ->HarmonizationService ->performHarmonization ($ this ->userId , $ sid , 'M ' );
145- // return response
146- return new DataResponse ('success ' );
145+ try {
146+ $ this ->HarmonizationService ->performHarmonization ($ this ->userId , $ sid , 'M ' );
147+ return new DataResponse ('success ' );
148+ } catch (\Throwable $ th ) {
149+ return new DataResponse ($ th ->getMessage (), Http::STATUS_INTERNAL_SERVER_ERROR );
150+ }
147151
148152 }
149153
@@ -155,23 +159,20 @@ public function Harmonize(int $sid): DataResponse {
155159 * @return DataResponse
156160 */
157161 #[NoAdminRequired]
158- #[FrontpageRoute(verb: 'GET ' , url: '/remote- collections- fetch ' )]
162+ #[FrontpageRoute(verb: 'GET ' , url: '/remote/ collections/ fetch ' )]
159163 public function remoteCollectionsFetch (int $ sid ): DataResponse {
160164
161165 // evaluate if user id is present
162166 if ($ this ->userId === null ) {
163167 return new DataResponse ([], Http::STATUS_BAD_REQUEST );
164168 }
165169 // retrieve collections
166- $ rs = $ this ->CoreService ->remoteCollectionsFetch ($ this ->userId , $ sid );
167- // return response
168- if (isset ($ rs )) {
170+ try {
171+ $ rs = $ this ->CoreService ->remoteCollectionsFetch ($ this ->userId , $ sid );
169172 return new DataResponse ($ rs );
170- } else {
171-
172- return new DataResponse ($ rs ['error ' ], 401 );
173+ } catch (\Throwable $ th ) {
174+ return new DataResponse ($ th ->getMessage (), Http::STATUS_INTERNAL_SERVER_ERROR );
173175 }
174-
175176 }
176177
177178 /**
@@ -182,21 +183,19 @@ public function remoteCollectionsFetch(int $sid): DataResponse {
182183 * @return DataResponse
183184 */
184185 #[NoAdminRequired]
185- #[FrontpageRoute(verb: 'GET ' , url: '/local- collections- fetch ' )]
186+ #[FrontpageRoute(verb: 'GET ' , url: '/local/ collections/ fetch ' )]
186187 public function localCollectionsFetch (int $ sid ): DataResponse {
187188
188189 // evaluate if user id is present
189190 if ($ this ->userId === null ) {
190191 return new DataResponse ([], Http::STATUS_BAD_REQUEST );
191192 }
192193 // retrieve collections
193- $ rs = $ this ->CoreService ->localCollectionsFetch ($ this ->userId , $ sid );
194- // return response
195- if (isset ($ rs )) {
194+ try {
195+ $ rs = $ this ->CoreService ->localCollectionsFetch ($ this ->userId , $ sid );
196196 return new DataResponse ($ rs );
197- } else {
198-
199- return new DataResponse ($ rs ['error ' ], 401 );
197+ } catch (\Throwable $ th ) {
198+ return new DataResponse ($ th ->getMessage (), Http::STATUS_INTERNAL_SERVER_ERROR );
200199 }
201200
202201 }
@@ -209,17 +208,20 @@ public function localCollectionsFetch(int $sid): DataResponse {
209208 * @return DataResponse
210209 */
211210 #[NoAdminRequired]
212- #[FrontpageRoute(verb: 'PUT ' , url: '/local- collections- deposit ' )]
211+ #[FrontpageRoute(verb: 'POST ' , url: '/local/ collections/ deposit ' )]
213212 public function localCollectionsDeposit (int $ sid , array $ ContactCorrelations , array $ EventCorrelations , array $ TaskCorrelations ): DataResponse {
214213
215214 // evaluate if user id is present
216215 if ($ this ->userId === null ) {
217216 return new DataResponse ([], Http::STATUS_BAD_REQUEST );
218217 }
219218 // execute command
220- $ rs = $ this ->CoreService ->depositCorrelations ($ this ->userId , $ sid , $ ContactCorrelations , $ EventCorrelations , $ TaskCorrelations );
221- // return response
222- return $ this ->localCollectionsFetch ($ sid );
219+ try {
220+ $ rs = $ this ->CoreService ->localCollectionsDeposit ($ this ->userId , $ sid , $ ContactCorrelations , $ EventCorrelations , $ TaskCorrelations );
221+ return $ this ->localCollectionsFetch ($ sid );
222+ } catch (\Throwable $ th ) {
223+ return new DataResponse ($ th ->getMessage (), Http::STATUS_INTERNAL_SERVER_ERROR );
224+ }
223225
224226 }
225227
0 commit comments