public function testExceptionFactory() { $response = new GuzzleResponse(202, ['Retry-After' => '5']); $exception = BoxException\NotAvailableException::create($response, new \DateTime()); $this->assertInstanceOf('BoxView\\Exception\\NotAvailableException', $exception); $this->assertNotEmpty($exception->getMessage()); $this->assertSame(202, $exception->getCode()); }
/** * @param ResponseInterface $response * @return Entity\Document * @throws \BoxView\Exception\NotAvailableException */ public function getSession(ResponseInterface $response) { $statusCode = $response->getStatusCode(); if ($statusCode != '201' && $statusCode != '202') { $this->handleUnexpectedResponse($response); } if ($statusCode == '202') { throw NotAvailableException::create($response, new \DateTime()); } return new Entity\Session(\GuzzleHttp\json_decode($response->getBody(), true)); }