Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
use a requests.session object
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDotCom committed Apr 10, 2021
1 parent 3170bc4 commit efdc392
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion growstocks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,20 @@ def __init__(self, client, secret, default_scopes=Scopes(), default_redirects=No
}
self.client = client
self.secret = secret
self._session = requests.session()
self.default_scopes = default_scopes
self.default_redirects = default_redirects
self.api_url = 'https://api.growstocks.xyz/v1/'
self.auth = auth(self)
self.pay = pay(self)

@property
def session(self):
"""
:meta private:
"""
return self._session


class auth:
"""
Expand Down Expand Up @@ -363,7 +371,7 @@ def fetch_user(self, token, scopes=None):
if scopes is None:
del payload['scopes']

with requests.post('{0}/user'.format(self.api_url), data=payload) as resp:
with self.client.session.post('{0}/user'.format(self.api_url), data=payload) as resp:
rtrn_json = resp.json()

return User.from_dict(rtrn_json['user'])
Expand Down

0 comments on commit efdc392

Please sign in to comment.