Skip to content

Commit a8dd253

Browse files
Merge branch 'listing-api-fix' into type-hints
2 parents fe06e75 + 4da2fe9 commit a8dd253

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
---
66
Connect Python SDK allows an easy and fast integration with Connect fulfillment API. Thanks to it you can automate the fulfillment of orders generated by your products.
77

8-
In order to use this library, please ensure that you have read first the documentation available on Connect knowledge base article located here, this one will provide you a great information on the rest api that this library implements.
8+
In order to use this library, please ensure that you have read first the documentation available on Connect knowledge base article located [here](http://help.vendor.connect.cloud.im/support/solutions/articles/43000030735-fulfillment-management-module), this one will provide you a great information on the rest api that this library implements.
99
### Class Features
1010
---
1111
This library may be consumed in your project in order to automate the fulfillment of requests, this class once imported into your project will allow you to:

connect/config.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ class Config(object):
1515
# Global instance
1616
_instance = None # type: Config
1717

18+
# noinspection PyShadowingBuiltins
1819
def __init__(
1920
self,
2021
api_url=None,
2122
api_key=None,
2223
products=None,
23-
filename=None
24+
file=None
2425
):
2526
# type: (str, str, Union[str, List[str]], str) -> None
2627

@@ -29,29 +30,29 @@ def __init__(
2930
:param api_url: Public api url
3031
:param api_key: Service user ApiKey
3132
:param products (optional): Id products
32-
:param filename: Config file path
33+
:param file: Config file path
3334
"""
3435
# Check arguments
35-
if not filename and not any([api_key, api_url]):
36+
if not file and not any([api_key, api_url]):
3637
raise ValueError('Filename or api_key and api_url are expected'
3738
'in Config initialization')
3839
if products and not isinstance(products, (str, list)):
3940
raise TypeError('Products can be string or string list. Found type '
4041
+ type(products).__name__)
4142

4243
# Load config from file name
43-
if filename:
44-
if not os.path.exists(filename):
45-
raise IOError('No filename `{}` on directory'.format(filename))
44+
if file:
45+
if not os.path.exists(file):
46+
raise IOError('No file `{}` on directory'.format(file))
4647

47-
with open(filename) as config_file:
48+
with open(file) as config_file:
4849
configs = config_file.read()
4950

5051
try:
5152
configs = json.loads(configs)
5253
except Exception as ex:
53-
raise TypeError('Invalid config filename `{}`\n'
54-
'ERROR: {}'.format(filename, str(ex)))
54+
raise TypeError('Invalid config file `{}`\n'
55+
'ERROR: {}'.format(file, str(ex)))
5556

5657
(api_url, api_key, products) = (configs.get('apiEndpoint', ''),
5758
configs.get('apiKey', ''),
@@ -77,7 +78,7 @@ def __init__(
7778
def get_instance(cls):
7879
# type: () -> Config
7980
if not cls._instance:
80-
cls._instance = Config(filename='config.json')
81+
cls._instance = Config(file='config.json')
8182
return cls._instance
8283

8384
@property

example/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
logger.setLevel("DEBUG")
1717

1818
# If we remove this line, it is done implicitly
19-
Config(filename='config.json')
19+
Config(file='config.json')
2020

2121

2222
class ExampleRequestProcessor(FulfillmentAutomation):

tests/test_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def test_global_config_immutable_properties():
4747

4848
def test_init_config_with_non_existing_file():
4949
with pytest.raises(IOError):
50-
Config(filename='non_existing_config.json')
50+
Config(file='non_existing_config.json')
5151

5252

5353
def test_init_config_with_file():
54-
_assert_config(Config(filename='config.json'))
54+
_assert_config(Config(file='config.json'))
5555

5656

5757
def test_init_config_with_arguments():
@@ -73,7 +73,7 @@ def test_init_config_with_invalid_arguments():
7373

7474
# noinspection PyPropertyAccess
7575
def test_config_immutable_properties():
76-
config = Config(filename='config.json')
76+
config = Config(file='config.json')
7777
with pytest.raises(AttributeError):
7878
config.api_key = conf_dict.get('apiKey')
7979
config.api_url = conf_dict.get('apiEndpoint')

0 commit comments

Comments
 (0)