src/Service/Cryptonator.php
public function getExchangeRate(ExchangeRateQuery $exchangeQuery): ExchangeRateContract
    {
        $currencyPair = $exchangeQuery->getCurrencyPair();

        $response = $this->request(
            sprintf(
                self::LATEST_URL,
                strtolower($currencyPair->getBaseCurrency()),
                strtolower($currencyPair->getQuoteCurrency())
            )
        );

        $data = StringUtil::jsonToArray($response);

        if (!$data['success']) {
            $message = !empty($data['error']) ? $data['error'] : 'Unknown error';

            throw new Exception($message);
        }

        $date = (new \DateTime())->setTimestamp($data['timestamp']);

        return $this->createRate($currencyPair, (float) ($data['ticker']['price']), $date);
    }
public function getExchangeRate(ExchangeRateQuery $exchangeQuery): ExchangeRateContract
    {
        $currencyPair = $exchangeQuery->getCurrencyPair();

        $response = $this->request(
            sprintf(
                self::LATEST_URL,
                strtolower($currencyPair->getBaseCurrency()),
                strtolower($currencyPair->getQuoteCurrency())
            )
        );

        $data = StringUtil::jsonToArray($response);

        if (!$data['success']) {
            $message = !empty($data['error']) ? $data['error'] : 'Unknown error';

            throw new Exception($message);
        }

        $date = (new \DateTime())->setTimestamp($data['timestamp']);

        return $this->createRate($currencyPair, (float) ($data['ticker']['price']), $date);
    }
public function getExchangeRate ( ExchangeRateQuery $ exchangeQuery ) : ExchangeRateContract { $ currencyPair = $ exchangeQuery -> getCurrencyPair ( ) ; $ response = $ this -> request ( sprintf ( self :: LATEST_URL , strtolower ( $ currencyPair -> getBaseCurrency ( ) ) , strtolower ( $ currencyPair -> getQuoteCurrency ( ) ) ) ) ; $ data = StringUtil :: jsonToArray ( $ response ) ; if ( ! $ data [ 'success' ] ) { $ message = ! empty ( $ data [ 'error' ] ) ? $ data [ 'error' ] : 'Unknown error' ; throw new Exception ( $ message ) ; } $ date = ( new \ DateTime ( ) ) -> setTimestamp ( $ data [ 'timestamp' ] ) ; return $ this -> createRate ( $ currencyPair , ( float ) ( $ data [ 'ticker' ] [ 'price' ] ) , $ date ) ; }
Gets the exchange rate.

@param ExchangeRateQuery $exchangeQuery

@return ExchangeRateContract

@throws Exception
Gets the exchange rate .