Skip to content

Commit

Permalink
Merge pull request browniebroke#79 from browniebroke/client-explicit-…
Browse files Browse the repository at this point in the history
…kwargs
  • Loading branch information
browniebroke authored Apr 27, 2020
2 parents 4b9d0d4 + 1a6a2a8 commit 72f58c1
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions deezer/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ class Client:
>>> import deezer
>>> client = deezer.Client(headers={'Accept-Language': 'fr'})
"""
use_ssl = True
host = "api.deezer.com"
:param app_id: appliication ID.
:param app_secret: application secret.
:param access_token: user access token.
:param host: override the default hostname.
:param use_ssl: connect using HTTP is set to `False`.
:param headers: a dictionary of headers to be used.
"""

objects_types = {
"album": Album,
Expand All @@ -58,28 +62,34 @@ class Client:
"chart": Chart,
}

def __init__(self, **kwargs):
super().__init__()

self.use_ssl = kwargs.get("use_ssl", self.use_ssl)
self.host = kwargs.get("host", self.host)
def __init__(
self,
app_id=None,
app_secret=None,
access_token=None,
host="api.deezer.com",
use_ssl=True,
headers=None,
**kwargs
):
self.app_id = app_id
self.app_secret = app_secret
self.access_token = access_token
self.use_ssl = use_ssl
self.host = host
self.session = requests.Session()

# Do not compress the response: to be readable in tests (cassettes)
if kwargs.get("do_not_compress_reponse"):
self.session.headers.update({"Accept-Encoding": "identity"})

# Headers
if kwargs.get("headers"):
self.session.headers.update(kwargs.get("headers"))
if headers:
self.session.headers.update(headers)

self.options = kwargs
self._authorize_url = None

self.app_id = kwargs.get("app_id")
self.app_secret = kwargs.get("app_secret")
self.access_token = kwargs.get("access_token")

def _process_json(self, item, parent=None):
"""
Recursively convert dictionary
Expand Down

0 comments on commit 72f58c1

Please sign in to comment.