Пример #1
0
 /**
  * @test
  */
 public function should_send_to_url()
 {
     $url = __DIR__ . '/fixtures/food_safety.xml';
     $callback_url = 'https://totalrecalls.dev:443/callbacks/feed_callback';
     $callback_type = 'url';
     $request_uuid = 'foo-bar-foo-bar';
     $dto = new ParseFeedDTO(compact('url', 'callback_url', 'callback_type', 'request_uuid'));
     $parseFeed = new ParseFeed();
     $parseFeed->fire($dto);
     $this->assertNotNull($parseFeed->getDto()->process_results);
 }
Пример #2
0
 public function fire(ParseFeed $parseFeed)
 {
     $this->parse_feed = $parseFeed;
     try {
         //Guzzle\Http\Message\EntityEnclosingRequest
         $this->callback_response = $this->getCallbackClient()->post($uri = $this->parse_feed->getDto()->callback_url, $headers = [], $postBody = json_encode($this->parse_feed->getDto(), true), $options = ['verify' => false])->send();
         $message = sprintf("Results from post %s", $this->callback_response);
         $this->parse_feed->getDto()->process_results[] = $message;
         $this->parse_feed->getDto()->callback_status = 'OK';
     } catch (BadResponseException $e) {
         $response = $e->getResponse();
         if ($response === null) {
             $message = "Null response from provider";
             $this->parse_feed->getDto()->process_results[] = $message;
         }
         $message = sprintf("Error from provider %s", $e->getResponse()->getStatusCode());
         throw new \Exception($message);
     }
     return $this->parse_feed->getDto();
 }