public function createTransaction(TransactionRequest $transactionRequest) { try { $oAuth = $this->genereteAuthenticationOAuth(); $httpResponse = HttpServiceImpl::post(Config::transactionHost, $transactionRequest, $oAuth); if ($httpResponse->getCode() != self::$RESPONSE_OK) { throw new Exception($httpResponse->getResponse(), $httpResponse->getCode()); } $transactionResponse = json_decode($httpResponse->getResponse()); return $transactionResponse; } catch (HttpException $e) { throw new HttpException($e->getMessage()); } catch (Exception $e) { throw new TransactionException($e->getMessage(), $e->getCode()); } }
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()); } }