Returns the exchanges rates based on the specified request

 @param rates_request [OandaRubyClient::RatesRequest] Request criteria
 @return [OpenStruct] An object structured similarly to the response from the Exchange Rate API
546916
def rates(rates_request)
      rates_uri = "#{oanda_endpoint}#{RATES_BASE_PATH}#{rates_request.base_currency}.json?#{rates_request.query_string}"
      rates_response = HTTParty.get(rates_uri, headers: oanda_headers)
      handle_response(rates_response.response)
      OpenStruct.new(rates_response.parsed_response)
    end
203772
private function doCreateRate(ExchangeRateQuery $exchangeQuery, DateTimeInterface $requestedDate = null): ExchangeRate
    {
        $currencyPair = $exchangeQuery->getCurrencyPair();
        $content = $this->request($this->buildUrl($requestedDate));

        $element = StringUtil::xmlToElement($content);

        $date = new \DateTime((string) $element->xpath('//Tarih_Date/@Date')[0]);
        $elements = $element->xpath('//Currency[@CurrencyCode="'.$currencyPair->getBaseCurrency().'"]/ForexSelling');

        if (!empty($elements) || !$date) {
            return $this->createRate($currencyPair, (float) ($elements[0]), $date);
        }

        throw new UnsupportedCurrencyPairException($currencyPair, $this);
    }
89085
def get_rate_from_db(currency: str) -> Decimal:
    
    from .models import ConversionRate
    try:
        rate = ConversionRate.objects.get_rate(currency)
    except ConversionRate.DoesNotExist:  # noqa
        raise ValueError('No conversion rate for %s' % (currency, ))
    return rate.rate
398197
def ask(currency_code, price, amount, limit = nil, counter_currency_code = "jpy")
            return trade(currency_code, price, amount, "ask", limit, counter_currency_code)
        end
396624
def get(req)
    target_uri = req.header.request_uri
    param = Util.hash_find_value(@challenge) { |uri, param|
      Util.uri_part_of(target_uri, uri)
    }
    return nil unless param
    user, passwd = Util.hash_find_value(@auth) { |uri, auth_data|
      Util.uri_part_of(target_uri, uri)
    }
    return nil unless user
    uri = req.header.request_uri
    calc_cred(req.header.request_method, uri, user, passwd, param)
  end
1032156
def get_url(request):
    
    protocol = request.headers.get('X-Forwarded-Proto') or request.headers.get('X-Forwarded-Protocol')
    if protocol is None and request.headers.get('X-Forwarded-Ssl') == 'on':
        protocol = 'https'
    if protocol is None:
        return request.url
    url = list(urlparse(request.url))
    url[0] = protocol
    return urlunparse(url)
1175694
def get_exchange(connection, name, create=False):
    
    exchange = Exchange(name, type="topic", passive=not create)

    # bind the exchange to our connection so operations can be performed on it
    bound_exchange = exchange(connection)

    # ensure the exchange exists.  Throw an error if it was created with
    # passive=True and it doesn't exist.
    bound_exchange.declare()

    return bound_exchange
1312673
def request(method:, url_path:, body: nil, params: {}, header_overrides: {})
      spec = body.nil? ? {} : {body_type: :json}
      endpoint_spec = Smartsheet::API::EndpointSpec.new(method, [url_path], **spec)
      request_spec = Smartsheet::API::RequestSpec.new(
          header_overrides: header_overrides,
          body: body,
          params: params
      )
      client.make_request(endpoint_spec, request_spec)
    end
335271
def rate(self, currency):
        """"""
        if not self._backend:
            raise ExchangeBackendNotInstalled()
        return self._backend.rate(currency)
1132549
protected function getHistoricalExchangeRate(HistoricalExchangeRateQuery $exchangeQuery): ExchangeRateContract
    {
        $historicalDateTime = $this->getAdoptedDateTime($exchangeQuery->getDate());

        if ($this->isEnterprise()) {
            $url = sprintf(
                self::ENTERPRISE_HISTORICAL_URL,
                $this->stringifyCurrencyPair($exchangeQuery->getCurrencyPair()),
                $historicalDateTime->format('Y-m-d'),
                $this->options['access_key']
            );
        } else {
            $url = sprintf(
                self::FREE_HISTORICAL_URL,
                $this->stringifyCurrencyPair($exchangeQuery->getCurrencyPair()),
                $historicalDateTime->format('Y-m-d'),
                $this->options['access_key']
            );
        }

        return $this->fetchOnlineRate($url, $exchangeQuery);
    }
547924
def rate(self, from_currency, to_currency, date):
        """"""
        return (1 / self.backend.get_rate(from_currency, date)) * self.backend.get_rate(
            to_currency, date
        )
1148707
def _parse_request_method(request: web.Request):
        
        method = request.headers.get(hdrs.ACCESS_CONTROL_REQUEST_METHOD)
        if method is None:
            raise web.HTTPForbidden(
                text="CORS preflight request failed: "
                     "'Access-Control-Request-Method' header is not specified")

        # FIXME: validate method string (ABNF: method = token), if parsing
        # fails, raise HTTPForbidden.

        return method
352054
def request(self, url, method="GET", params=None, headers=None, is_signed=True):
        
        params = params or {}
        headers = headers or {}
        
        if is_signed:
            params.update(self.get_signing_params())
        
        if method.upper() == "GET":
            url = '%s?%s' % (url, urllib.urlencode(params))
            return self.client().request(url, method=method, headers=headers)
        return self.client().request(url, method, body=urllib.urlencode(params), headers=headers)
355826
def get_previous_price_list(self, currency, start_date, end_date):
        
        start = start_date.strftime('%Y-%m-%d')
        end = end_date.strftime('%Y-%m-%d')
        url = (
            'https://api.coindesk.com/v1/bpi/historical/close.json'
            '?start={}&end={}&currency={}'.format(
                   start, end, currency
               )
        )
        response = requests.get(url)
        if response.status_code == 200:
            data = self._decode_rates(response)
            price_dict = data.get('bpi', {})
            return price_dict
        return {}
1330424
@Override
    public int compareTo(ExchangeRate o) {
        Objects.requireNonNull(o);
        int compare = this.getBaseCurrency().getCurrencyCode().compareTo(o.getBaseCurrency().getCurrencyCode());
        if (compare == 0) {
            compare = this.getCurrency().getCurrencyCode().compareTo(o.getCurrency().getCurrencyCode());
        }
        if (compare == 0) {
            compare = this.getContext().getProviderName().compareTo(o.getContext().getProviderName());
        }
        return compare;
    }
1074691
def get_previous_request(rid):
    
    request = None
    broker_req = relation_get(attribute='broker_req', rid=rid,
                              unit=local_unit())
    if broker_req:
        request_data = json.loads(broker_req)
        request = CephBrokerRq(api_version=request_data['api-version'],
                               request_id=request_data['request-id'])
        request.set_ops(request_data['ops'])

    return request
430121
private function doCreateRate(string $url, ExchangeRateQuery $exchangeQuery): ExchangeRate
    {
        $content = $this->request($url);
        $data = StringUtil::jsonToArray($content);

        if (isset($data['error'])) {
            throw new Exception($data['description']);
        }

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

        if ($data['base'] === $currencyPair->getBaseCurrency()
            && isset($data['rates'][$currencyPair->getQuoteCurrency()])
        ) {
            return $this->createRate($currencyPair, (float) ($data['rates'][$currencyPair->getQuoteCurrency()]), $date);
        }

        throw new UnsupportedCurrencyPairException($currencyPair, $this);
    }