Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Commit fd238d4

Browse files
authored
Release 2.20180712.3 (#72)
* Release 2.20180712.3
1 parent b203d70 commit fd238d4

26 files changed

+72
-167
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Change Log
2+
## Version 2.20180712.3 (2018-08-24)
3+
4+
Remove singleton constraint for configuration class. This is a minor breaking change to ```ApiClient```
5+
and ```RESTClientObject``` initialization.
26

37
## Version 2.20180712.2 (2018-08-21)
48

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from setuptools import setup, find_packages
55

66
NAME = "squareconnect"
7-
VERSION = "2.20180712.2"
7+
VERSION = "2.20180712.3"
88

99

1010

squareconnect/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,3 @@
219219
from .api_client import ApiClient
220220

221221
from .configuration import Configuration
222-
223-
configuration = Configuration()

squareconnect/api_client.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,17 @@ class ApiClient(object):
6565
:param header_name: a header to pass when making calls to the API.
6666
:param header_value: a header value to pass when making calls to the API.
6767
"""
68-
def __init__(self, host=None, header_name=None, header_value=None, cookie=None):
69-
70-
"""
71-
Constructor of the class.
72-
"""
73-
self.rest_client = RESTClientObject()
68+
def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None):
69+
if configuration is None:
70+
configuration = Configuration()
71+
self.configuration = configuration
72+
self.rest_client = RESTClientObject(configuration)
7473
self.default_headers = {}
7574
if header_name is not None:
7675
self.default_headers[header_name] = header_value
77-
if host is None:
78-
self.host = Configuration().host
79-
else:
80-
self.host = host
8176
self.cookie = cookie
8277
# Set default User-Agent.
83-
self.user_agent = 'Square-Connect-Python/2.20180712.2'
78+
self.user_agent = 'Square-Connect-Python/2.20180712.3'
8479

8580
@property
8681
def user_agent(self):
@@ -139,7 +134,7 @@ def __call_api(self, resource_path, method,
139134
body = self.sanitize_for_serialization(body)
140135

141136
# request url
142-
url = self.host + resource_path
137+
url = self.configuration.host + resource_path
143138

144139
# perform request and return response
145140
response_data = self.request(method, url,
@@ -448,13 +443,12 @@ def update_params_for_auth(self, headers, querys, auth_settings):
448443
:param querys: Query parameters dict to be updated.
449444
:param auth_settings: Authentication setting identifiers list.
450445
"""
451-
config = Configuration()
452446

453447
if not auth_settings:
454448
return
455449

456450
for auth in auth_settings:
457-
auth_setting = config.auth_settings().get(auth)
451+
auth_setting = self.configuration.auth_settings().get(auth)
458452
if auth_setting:
459453
if not auth_setting['value']:
460454
continue
@@ -475,9 +469,8 @@ def __deserialize_file(self, response):
475469
:param response: RESTResponse.
476470
:return: file path.
477471
"""
478-
config = Configuration()
479472

480-
fd, path = tempfile.mkstemp(dir=config.temp_folder_path)
473+
fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
481474
os.close(fd)
482475
os.remove(path)
483476

squareconnect/apis/apple_pay_api.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# python 2 and python 3 compatibility library
2727
from six import iteritems
2828

29-
from ..configuration import Configuration
3029
from ..api_client import ApiClient
3130

3231

@@ -38,13 +37,9 @@ class ApplePayApi(object):
3837
"""
3938

4039
def __init__(self, api_client=None):
41-
config = Configuration()
42-
if api_client:
43-
self.api_client = api_client
44-
else:
45-
if not config.api_client:
46-
config.api_client = ApiClient()
47-
self.api_client = config.api_client
40+
if api_client is None:
41+
api_client = ApiClient()
42+
self.api_client = api_client
4843

4944
def register_domain(self, body, **kwargs):
5045
"""

squareconnect/apis/catalog_api.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# python 2 and python 3 compatibility library
2727
from six import iteritems
2828

29-
from ..configuration import Configuration
3029
from ..api_client import ApiClient
3130

3231

@@ -38,13 +37,9 @@ class CatalogApi(object):
3837
"""
3938

4039
def __init__(self, api_client=None):
41-
config = Configuration()
42-
if api_client:
43-
self.api_client = api_client
44-
else:
45-
if not config.api_client:
46-
config.api_client = ApiClient()
47-
self.api_client = config.api_client
40+
if api_client is None:
41+
api_client = ApiClient()
42+
self.api_client = api_client
4843

4944
def batch_delete_catalog_objects(self, body, **kwargs):
5045
"""

squareconnect/apis/checkout_api.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# python 2 and python 3 compatibility library
2727
from six import iteritems
2828

29-
from ..configuration import Configuration
3029
from ..api_client import ApiClient
3130

3231

@@ -38,13 +37,9 @@ class CheckoutApi(object):
3837
"""
3938

4039
def __init__(self, api_client=None):
41-
config = Configuration()
42-
if api_client:
43-
self.api_client = api_client
44-
else:
45-
if not config.api_client:
46-
config.api_client = ApiClient()
47-
self.api_client = config.api_client
40+
if api_client is None:
41+
api_client = ApiClient()
42+
self.api_client = api_client
4843

4944
def create_checkout(self, location_id, body, **kwargs):
5045
"""

squareconnect/apis/customers_api.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# python 2 and python 3 compatibility library
2727
from six import iteritems
2828

29-
from ..configuration import Configuration
3029
from ..api_client import ApiClient
3130

3231

@@ -38,13 +37,9 @@ class CustomersApi(object):
3837
"""
3938

4039
def __init__(self, api_client=None):
41-
config = Configuration()
42-
if api_client:
43-
self.api_client = api_client
44-
else:
45-
if not config.api_client:
46-
config.api_client = ApiClient()
47-
self.api_client = config.api_client
40+
if api_client is None:
41+
api_client = ApiClient()
42+
self.api_client = api_client
4843

4944
def create_customer(self, body, **kwargs):
5045
"""

squareconnect/apis/locations_api.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# python 2 and python 3 compatibility library
2727
from six import iteritems
2828

29-
from ..configuration import Configuration
3029
from ..api_client import ApiClient
3130

3231

@@ -38,13 +37,9 @@ class LocationsApi(object):
3837
"""
3938

4039
def __init__(self, api_client=None):
41-
config = Configuration()
42-
if api_client:
43-
self.api_client = api_client
44-
else:
45-
if not config.api_client:
46-
config.api_client = ApiClient()
47-
self.api_client = config.api_client
40+
if api_client is None:
41+
api_client = ApiClient()
42+
self.api_client = api_client
4843

4944
def list_locations(self, **kwargs):
5045
"""

squareconnect/apis/mobile_authorization_api.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# python 2 and python 3 compatibility library
2727
from six import iteritems
2828

29-
from ..configuration import Configuration
3029
from ..api_client import ApiClient
3130

3231

@@ -38,13 +37,9 @@ class MobileAuthorizationApi(object):
3837
"""
3938

4039
def __init__(self, api_client=None):
41-
config = Configuration()
42-
if api_client:
43-
self.api_client = api_client
44-
else:
45-
if not config.api_client:
46-
config.api_client = ApiClient()
47-
self.api_client = config.api_client
40+
if api_client is None:
41+
api_client = ApiClient()
42+
self.api_client = api_client
4843

4944
def create_mobile_authorization_code(self, body, **kwargs):
5045
"""

0 commit comments

Comments
 (0)