mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 10:47:00 +00:00 
			
		
		
		
	Use Guzzle, not Requests library.
This commit is contained in:
		| @@ -29,6 +29,6 @@ namespace FireflyIII\Services\Github\Request; | ||||
|  */ | ||||
| interface GithubRequest | ||||
| { | ||||
|     public function call(); | ||||
|     public function call(): void; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -26,7 +26,9 @@ namespace FireflyIII\Services\Github\Request; | ||||
| use Exception; | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\Services\Github\Object\Release; | ||||
| use Requests; | ||||
| use GuzzleHttp\Client; | ||||
| use GuzzleHttp\Exception\GuzzleException; | ||||
| use Log; | ||||
| use SimpleXMLElement; | ||||
|  | ||||
| /** | ||||
| @@ -41,30 +43,34 @@ class UpdateRequest implements GithubRequest | ||||
|      * | ||||
|      * @throws FireflyException | ||||
|      */ | ||||
|     public function call() | ||||
|     public function call(): void | ||||
|     { | ||||
|         $uri = 'https://github.com/firefly-iii/firefly-iii/releases.atom'; | ||||
|         Log::debug(sprintf('Going to call %s', $uri)); | ||||
|         try { | ||||
|             $response = Requests::get($uri); | ||||
|         } catch (Exception $e) { | ||||
|             $client = new Client(); | ||||
|             $res    = $client->request('GET', $uri); | ||||
|         } catch (GuzzleException|Exception $e) { | ||||
|             throw new FireflyException(sprintf('Response error from Github: %s', $e->getMessage())); | ||||
|         } | ||||
|  | ||||
|         if ($response->status_code !== 200) { | ||||
|             throw new FireflyException(sprintf('Returned code %d, error: %s', $response->status_code, $response->body)); | ||||
|         if ($res->getStatusCode() !== 200) { | ||||
|             throw new FireflyException(sprintf('Returned code %d, error: %s', $res->getStatusCode(), $res->getBody()->getContents())); | ||||
|         } | ||||
|  | ||||
|         $releaseXml = new SimpleXMLElement($response->body, LIBXML_NOCDATA); | ||||
|         $releaseXml = new SimpleXMLElement($res->getBody()->getContents(), LIBXML_NOCDATA); | ||||
|  | ||||
|         //fetch the products for each category | ||||
|         if (isset($releaseXml->entry)) { | ||||
|             Log::debug(sprintf('Count of entries is: %d', \count($releaseXml->entry))); | ||||
|             foreach ($releaseXml->entry as $entry) { | ||||
|                 $array            = [ | ||||
|                 $array = [ | ||||
|                     'id'      => (string)$entry->id, | ||||
|                     'updated' => (string)$entry->updated, | ||||
|                     'title'   => (string)$entry->title, | ||||
|                     'content' => (string)$entry->content, | ||||
|                 ]; | ||||
|                 Log::debug(sprintf('Found version %s', $entry->title)); | ||||
|                 $this->releases[] = new Release($array); | ||||
|             } | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user