Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make country and language mandatory for thinq2_get #2

Open
wants to merge 1 commit into
base: api2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions wideq/core_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def get_list(obj, key):
return [val]


def thinq2_headers(extra_headers={}, access_token=None, user_number=None, country="US", language="en-US"):
def thinq2_headers(country, language, extra_headers={}, access_token=None, user_number=None):

headers = {
'Accept': 'application/json',
'Content-type': 'application/json;charset=UTF-8',
Expand All @@ -91,14 +91,14 @@ def thinq2_headers(extra_headers={}, access_token=None, user_number=None, countr

if access_token:
headers['x-emp-token'] = access_token

if user_number:
headers['x-user-no'] = user_number

return { **headers, **extra_headers }

def thinq2_get(url, access_token=None, user_number=None, headers={}, country="US", language="en-US"):
def thinq2_get(url, country, language, access_token=None, user_number=None, headers={}):

res = requests.get(url, headers=thinq2_headers(
access_token=access_token, user_number=user_number, extra_headers=headers, country=country, language=language))

Expand Down Expand Up @@ -282,7 +282,8 @@ def post2(self, path, data=None):

def get2(self, path):
url = urljoin(self.auth.gateway.api_root + '/', path)
return thinq2_get(url, self.auth.access_token, self.auth.user_number, country=self.auth.gateway.country, language=self.auth.gateway.language)
return thinq2_get(url, country=self.auth.gateway.country, language=self.auth.gateway.language,
access_token=self.auth.access_token, user_number=self.auth.user_number)

def get_devices(self):
"""Get a list of devices associated with the user's account.
Expand Down