2424use CURLFile ;
2525use OCA \Files_External_Ethswarm \Auth \AccessKey ;
2626use OCA \Files_External_Ethswarm \Backend \BeeSwarm ;
27+ use OCA \Files_External_Ethswarm \Contract \Enum \ApiEndpoints ;
2728use OCA \Files_External_Ethswarm \Dto \LinkDto ;
2829use OCA \Files_External_Ethswarm \Exception \CurlException ;
2930use OCA \Files_External_Ethswarm \Exception \HejBitException ;
@@ -80,8 +81,8 @@ private function validateParams(array &$params): void {
8081 /**
8182 * @throws CurlException|HejBitException
8283 */
83- private function getLink (string $ endpoint ): LinkDto {
84- $ endpoint = $ this ->api_url .$ endpoint ;
84+ private function getLink (ApiEndpoints $ endpoint ): LinkDto {
85+ $ endpoint = $ this ->api_url .$ endpoint-> value ;
8586 $ request = new Curl ($ endpoint , headers: [
8687 'accept: application/json ' ,
8788 ], authorization: $ this ->access_key );
@@ -102,7 +103,7 @@ private function uploadSwarm(string $path, string $tempFile, string $mimetype):
102103 return $ this ->uploadSwarmV1 ($ path , $ tempFile , $ mimetype );
103104 }
104105
105- $ link = $ this ->getLink (' /api/upload ' );
106+ $ link = $ this ->getLink (ApiEndpoints:: UPLOAD );
106107 $ request = new Curl ($ link ->url , authorization: $ link ->token );
107108 $ response = $ request ->post ([
108109 'file ' => new CURLFile ($ tempFile , $ mimetype , basename ($ path )),
@@ -126,7 +127,7 @@ private function downloadSwarm(string $reference) {
126127 return $ this ->downloadSwarmV1 ($ reference );
127128 }
128129
129- $ link = $ this ->getLink (' /api/download ' );
130+ $ link = $ this ->getLink (ApiEndpoints:: DOWNLOAD );
130131 $ request = new Curl ($ link ->url ."/ {$ reference }" , authorization: $ link ->token );
131132 $ response = $ request ->get ();
132133
@@ -151,7 +152,7 @@ private function checkConnection(): bool {
151152 return $ this ->checkConnectionV1 ();
152153 }
153154
154- $ endpoint = $ this ->api_url .' /api/readiness ' ;
155+ $ endpoint = $ this ->api_url .ApiEndpoints:: READINESS -> value ;
155156
156157 $ request = new Curl ($ endpoint , authorization: $ this ->access_key );
157158 $ request ->get ();
0 commit comments