コード例 #1
0
class Ohlc:
    def __init__(self, requestor=None):
        self._requestor = requestor
        if requestor is None:
            self._requestor = Requestor()

    def get(
        self,
        start_time,
        period,
        base=None,
        pretty_print=False,
        symbols=None,
    ):
        params = {
            "prettyprint": pretty_print,
            "period": period,
            "start_time": start_time,
        }

        if base is not None:
            params["base"] = base

        if symbols is not None:
            params["symbols"] = symbols

        return self._requestor.get("ohlc.json", params)
コード例 #2
0
    def test_skip_app_id(self, http_client, mock_response):
        data = {"base": "USD"}
        mock_response(200, data)
        requestor = Requestor(None, client=http_client, skip_app_id=True)
        result = requestor.get("usage", {})

        assert result.code == 200
        assert result.body == data
コード例 #3
0
class Usage:
    def __init__(self, requestor=None):
        self._requestor = requestor
        if requestor is None:
            self._requestor = Requestor()

    def get(self, pretty_print=False):
        params = {"prettyprint": pretty_print}
        return self._requestor.get("usage.json", params)
コード例 #4
0
class Convert:
    def __init__(self, requestor=None):
        self._requestor = requestor
        if requestor is None:
            self._requestor = Requestor()

    def get(self, amount, from_currency, to_currency, pretty_print=False):
        path = "convert/%s/%s/%s" % (amount, from_currency, to_currency)
        params = {"prettyprint": pretty_print}
        return self._requestor.get(path, params)
コード例 #5
0
class Currency:
    def __init__(self, requestor=None):
        self._requestor = requestor
        if requestor is None:
            self._requestor = Requestor(skip_app_id=True)

    def get(
        self,
        pretty_print=False,
        show_alternative=False,
        show_inactive=False,
    ):
        params = {
            "prettyprint": pretty_print,
            "show_alternative": show_alternative,
            "show_inactive": show_inactive,
        }
        return self._requestor.get("currencies.json", params)
コード例 #6
0
class Latest:
    def __init__(self, requestor=None):
        self._requestor = requestor
        if requestor is None:
            self._requestor = Requestor()

    def get(self,
            base=None,
            pretty_print=False,
            symbols=None,
            show_alternative=False):
        params = {
            "prettyprint": pretty_print,
            "show_alternative": show_alternative
        }

        if base is not None:
            params["base"] = base

        if symbols is not None:
            params["symbols"] = symbols

        return self._requestor.get("latest.json", params)