8000 Updated standards and fixed problems with python 3.8 by Evert-Arends · Pull Request #57 · woocommerce/wc-api-python · GitHub
[go: up one dir, main page]

Skip to content

Updated standards and fixed problems with python 3.8 #57

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

Merged
merged 1 commit into from
Mar 13, 2021
Merged
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
8000
Diff view
Diff view
14 changes: 7 additions & 7 deletions woocommerce/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
"""

__title__ = "woocommerce-api"
__version__ = "2.1.1"
__version__ = "2.1.2"
__author__ = "Claudio Sanches @ Automattic"
__license__ = "MIT"

from requests import request
from json import dumps as jsonencode
from time import time
from woocommerce.oauth import OAuth
from requests.auth import HTTPBasicAuth

try:
from urllib.parse import urlencode
Expand Down Expand Up @@ -44,12 +45,12 @@ def __get_url(self, endpoint):
api = "wc-api"

if url.endswith("/") is False:
url = "%s/" % url
url = f"{url}/"

if self.wp_api:
api = "wp-json"

return "%s%s/%s/%s" % (url, api, self.version, endpoint)
return f"{url}{api}/{self.version}/{endpoint}"

def __get_oauth_url(self, url, method, **kwargs):
""" Generate oAuth1.0a URL """
Expand All @@ -71,20 +72,20 @@ def __request(self, method, endpoint, data, params=None, **kwargs):
url = self.__get_url(endpoint)
auth = None
headers = {
"user-agent": "WooCommerce API Client-Python/%s" % __version__,
"user-agent": f'WooCommerce API {__version__}',
"accept": "application/json"
}

if self.is_ssl is True and self.query_string_auth is False:
auth = (self.consumer_key, self.consumer_secret)
auth = HTTPBasicAuth(self.consumer_key, self.consumer_secret)
elif self.is_ssl is True and self.query_string_auth is True:
params.update({
"consumer_key": self.consumer_key,
"consumer_secret": self.consumer_secret
})
else:
encoded_params = urlencode(params)
url = "%s?%s" % (url 5BDA , encoded_params)
url = f"{url}?{encoded_params}"
url = self.__get_oauth_url(url, method, **kwargs)

if data is not None:
Expand Down Expand Up @@ -122,4 +123,3 @@ def delete(self, endpoint, **kwargs):
def options(self, endpoint, **kwargs):
""" OPTIONS requests """
return self.__request("OPTIONS", endpoint, None, **kwargs)

0