Skip to content

Commit 4da2fe9

Browse files
Merge branch 'suppress-warnings' into listing-api-fix
2 parents 305a77c + f05134a commit 4da2fe9

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

README.md

Lines changed: 6 additions & 2 deletions
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:
@@ -46,7 +46,11 @@ from connect.models.exception import FulfillmentFail, FulfillmentInquire, Skip
4646
class ExampleRequestProcessor(FulfillmentAutomation):
4747
def process_request(self, request):
4848

49-
logger.info('Processing request {}'.format(request.id))
49+
logger.info('Processing request {} for contract {}, product {}, marketplace {}'
50+
.format(request.id,
51+
request.contract.id,
52+
request.asset.product.name,
53+
request.marketplace.name))
5054

5155
# Custom logic
5256
if request.type == 'purchase':

connect/config.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,42 @@
1212
class Config(object):
1313
_instance = None # Global instance
1414

15+
# noinspection PyShadowingBuiltins
1516
def __init__(
1617
self,
1718
api_url=None,
1819
api_key=None,
1920
products=None,
20-
filename=None
21+
file=None
2122
):
2223
"""
2324
initialization config for public api
2425
:param api_url: Public api url
2526
:param api_key: Service user ApiKey
2627
:param products (optional): Id products
27-
:param filename: Config file path
28+
:param file: Config file path
2829
"""
2930
# Check arguments
30-
if not filename and not any([api_key, api_url]):
31+
if not file and not any([api_key, api_url]):
3132
raise ValueError('Filename or api_key and api_url are expected'
3233
'in Config initialization')
3334
if products and not isinstance(products, (str, list)):
3435
raise TypeError('Products can be string or string list. Found type '
3536
+ type(products).__name__)
3637

3738
# Load config from file name
38-
if filename:
39-
if not os.path.exists(filename):
40-
raise IOError('No filename `{}` on directory'.format(filename))
39+
if file:
40+
if not os.path.exists(file):
41+
raise IOError('No file `{}` on directory'.format(file))
4142

42-
with open(filename) as config_file:
43+
with open(file) as config_file:
4344
configs = config_file.read()
4445

4546
try:
4647
configs = json.loads(configs)
4748
except Exception as ex:
48-
raise TypeError('Invalid config filename `{}`\n'
49-
'ERROR: {}'.format(filename, str(ex)))
49+
raise TypeError('Invalid config file `{}`\n'
50+
'ERROR: {}'.format(file, str(ex)))
5051

5152
(api_url, api_key, products) = (configs.get('apiEndpoint', ''),
5253
configs.get('apiKey', ''),
@@ -71,7 +72,7 @@ def __init__(
7172
@classmethod
7273
def get_instance(cls):
7374
if not cls._instance:
74-
cls._instance = Config(filename='config.json')
75+
cls._instance = Config(file='config.json')
7576
return cls._instance
7677

7778
@property

example/example.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
logger.setLevel("DEBUG")
1616

1717
# If we remove this line, it is done implicitly
18-
Config(filename='config.json')
18+
Config(file='config.json')
1919

2020

2121
class ExampleRequestProcessor(FulfillmentAutomation):
2222
def process_request(self, request):
2323

24-
logger.info('Processing request {}'.format(request.id))
24+
logger.info('Processing request {} for contract {}, product {}, marketplace {}'
25+
.format(request.id,
26+
request.contract.id,
27+
request.asset.product.name,
28+
request.marketplace.name))
2529

2630
# Custom logic
2731
if request.type == 'purchase':

tests/test_config.py

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

4747
def test_init_config_with_non_existing_file():
4848
with pytest.raises(IOError):
49-
Config(filename='non_existing_config.json')
49+
Config(file='non_existing_config.json')
5050

5151

5252
def test_init_config_with_file():
53-
_assert_config(Config(filename='config.json'))
53+
_assert_config(Config(file='config.json'))
5454

5555

5656
def test_init_config_with_arguments():
@@ -72,7 +72,7 @@ def test_init_config_with_invalid_arguments():
7272

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

0 commit comments

Comments
 (0)