<reponame>Apperio/django-exchange
from __future__ import absolute_import

import logging
from pyoxr import OXRClient

from django.conf import settings

from exchange.adapters import BaseAdapter

logger = logging.getLogger(__name__)


class OpenExchangeRatesAdapter(BaseAdapter):
    """This adapter uses openexchangerates.org service to populate currency and
    exchange rate models.

    """

    API_KEY_SETTINGS_KEY = 'OPENEXCHANGERATES_API_KEY'

    def __init__(self):
        self.client = OXRClient(app_id=getattr(settings, self.API_KEY_SETTINGS_KEY))

    def get_currencies(self):
        return OXRClient.get_currencies(api=self.client).items()

    def get_exchangerates(self, base):
        return OXRClient.get_latest(base, api=self.client)['rates'].items()

from __future__ import absolute_import

import logging
from pyoxr import OXRClient

from django.conf import settings

from exchange.adapters import BaseAdapter

logger = logging.getLogger(__name__)


class OpenExchangeRatesAdapter(BaseAdapter):
    """This adapter uses openexchangerates.org service to populate currency and
    exchange rate models.

    """

    API_KEY_SETTINGS_KEY = 'OPENEXCHANGERATES_API_KEY'

    def __init__(self):
        self.client = OXRClient(app_id=getattr(settings, self.API_KEY_SETTINGS_KEY))

    def get_currencies(self):
        return OXRClient.get_currencies(api=self.client).items()

    def get_exchangerates(self, base):
        return OXRClient.get_latest(base, api=self.client)['rates'].items()
This adapter uses openexchangerates.org service to populate currency and     exchange rate models.