/** * @param Http\Response $response * @return bool */ protected function isCacheable(Http\Response $response) { /** @todo Do it properly. Vary:, Pragma:, TTL... */ if (!$response->isCode(200)) { return FALSE; } elseif (preg_match('#max-age=0|must-revalidate#i', $response->getHeader('Cache-Control', ''))) { return FALSE; } return $response->hasHeader('ETag') || $response->hasHeader('Last-Modified'); }
/** * @param Response $response * @return Transaction[] * @throws FioFailureException */ private function getTransactionsFromResponse(Response $response) { try { $json = Json::decode($response->getBody()); if (!$json->accountStatement->transactionList) { return []; } $transactions = []; foreach ($json->accountStatement->transactionList->transaction as $row) { $transactions[] = $this->createTransaction($row); } return $transactions; } catch (JsonException $e) { throw new FioFailureException('Invalid JSON from FIO API', NULL, $e); } }
/** * @param Response $response */ public function onResponse(Response $response) { $http = 'HTTP/1.1 ' . $response->getCode(); $content = $this->getFormattedMessage($http, $response); $this->writer->write($response, $content); }
/** * @param Http\Response $response * @return string */ public function decode(Http\Response $response) { return $response->getBody(); }