/**
  * @param \Psr\Http\Message\ResponseInterface $response
  * @param \Psr\Http\Message\RequestInterface $request
  *
  * @throws \Spryker\Shared\ZedRequest\Client\Exception\InvalidZedResponseException
  *
  * @return \Spryker\Shared\ZedRequest\Client\ResponseInterface
  */
 protected function getTransferFromResponse(MessageResponseInterface $response, MessageRequestInterface $request)
 {
     $data = json_decode(trim($response->getBody()), true);
     if (!$data || !is_array($data)) {
         throw new InvalidZedResponseException('Invalid JSON', $response, $request->getUri());
     }
     $responseTransfer = new SprykerResponse();
     $responseTransfer->fromArray($data);
     return $responseTransfer;
 }
Exemple #2
0
 /**
  * @return void
  */
 public function testHasMethods()
 {
     $response = new Response();
     $response->addErrorMessage(new Message(['message' => 'error']));
     $response->addInfoMessage(new Message(['message' => 'test']));
     $this->assertEquals(true, $response->hasErrorMessage('error'));
     $this->assertEquals(false, $response->hasErrorMessage('test'));
     $this->assertEquals(false, $response->hasInfoMessage('error'));
     $this->assertEquals(true, $response->hasInfoMessage('test'));
 }