public function searchAccounts($cpf) { try { $searchRequest = new SearchRequest(); $searchRequest->setCpf($cpf); $httpResponse = $this->getHttpHelper()->post(Config::accountHost, $searchRequest, $this->getAuthenticationHelper()->generateAuthenticationBasic()); if (!$httpResponse->isResponseOK()) { if ($httpResponse->isBadRequest()) { throw new AccountException("Parametros fornecidos sao invalidos: " . $httpResponse->getResponse()); } throw new AccountException("Falha ao criar conta: " . $httpResponse->getResponse()); } return $this->parse($httpResponse->getResponse()); } catch (ServiceHttpException $e) { throw new AccountException("Falha HTTP ao criar conta", $e); } }
public function searchAccounts($cpf) { try { $auth = $this->genereteAuthenticationBasic(); $searchRequest = new SearchRequest(); $searchRequest->setCpf($cpf); $httpResponse = HttpServiceImpl::post(Config::accountHost, $searchRequest, $auth); if ($httpResponse->getCode() != self::$RESPONSE_OK) { throw new Exception($httpResponse->getResponse(), $httpResponse->getCode()); } $searchResponse = json_decode($httpResponse->getResponse()); return $searchResponse; } catch (HttpException $e) { throw new HttpException($e->getMessage()); } catch (Exception $e) { throw new AccountException($e->getMessage(), $e->getCode()); } }