Skip to content

Commit

Permalink
Merge pull request #57 from upwork/v2.1.0
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
mnovozhylov authored May 21, 2021
2 parents 05e0207 + e3b46b2 commit c7d2dc2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ cache:
pip: true
matrix:
include:
- python: "3.8"
env: NOXSESSION="tests-3.8"
- python: "3.8"
- python: "3.9"
env: NOXSESSION="tests-3.9"
- python: "3.9"
env: NOXSESSION="lint"
dist: xenial
install:
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

nox.options.sessions = ["tests", "lint", "build"]

python = ["3.8"]
python = ["3.9"]


lint_dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
packages=find_packages(),
setup_requires=[],
url="https://github.com/upwork/python-upwork",
version="2.0.1",
version="2.1.0",
zip_safe=False,
)
1 change: 1 addition & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def test_send_request(self, mocked_get, mocked_post, mocked_put, mocked_delete):
}
)
cl = client.Client(cfg)
cl.requests = requests
assert cl.get("/test/uri", {}) == {"a": "b"}
assert cl.post("/test/uri", {}) == {"a": "b"}
assert cl.put("/test/uri", {}) == {"a": "b"}
Expand Down
2 changes: 1 addition & 1 deletion upwork/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

__author__ = """Maksym Novozhylov"""
__email__ = "[email protected]"
__version__ = "2.0.1"
__version__ = "2.1.0"

__all__ = ("Config", "Client", "routers")
11 changes: 8 additions & 3 deletions upwork/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import requests
from . import upwork
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from requests_oauthlib import OAuth1 # type: ignore
from urllib.parse import parse_qsl, urlencode

Expand All @@ -36,6 +38,9 @@ class Client(object):
def __init__(self, config):
self.config = config

self.requests = requests.Session()
self.requests.mount('https://', HTTPAdapter(max_retries=Retry(total=0)))

def get_request_token(self):
"""Get request token"""
oauth = OAuth1(self.config.consumer_key, self.config.consumer_secret)
Expand Down Expand Up @@ -165,13 +170,13 @@ def send_request(self, uri, method="get", params={}):
url = full_url(get_uri_with_format(uri, self.epoint), self.epoint)

if method == "get":
r = requests.get(url, params=params, auth=oauth, verify=self.config.verify_ssl)
r = self.requests.get(url, params=params, auth=oauth, verify=self.config.verify_ssl)
elif method == "put":
headers = {"Content-type": "application/json"}
r = requests.put(url, json=params, headers=headers, auth=oauth, verify=self.config.verify_ssl)
r = self.requests.put(url, json=params, headers=headers, auth=oauth, verify=self.config.verify_ssl)
elif method in {"post", "delete"}:
headers = {"Content-type": "application/json"}
r = requests.post(url, json=params, headers=headers, auth=oauth, verify=self.config.verify_ssl)
r = self.requests.post(url, json=params, headers=headers, auth=oauth, verify=self.config.verify_ssl)
else:
raise ValueError(
'Do not know how to handle http method "{0}"'.format(method)
Expand Down

0 comments on commit c7d2dc2

Please sign in to comment.