Skip to content

Commit 1b26abd

Browse files
Merge branch 'master' of https://github.com/ingrammicro/connect-python-sdk into master
2 parents 1837c1d + 48d3c73 commit 1b26abd

40 files changed

+534
-332
lines changed

.travis.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
11
language: python
2-
32
matrix:
43
include:
5-
- os: linux
6-
python: 2.7
7-
- os: linux
8-
python: 3.5
9-
- os: linux
10-
python: 3.6
4+
- os: linux
5+
python: 2.7
6+
env: BUILD=PYPI
7+
- os: linux
8+
python: 3.4
9+
- os: linux
10+
python: 3.5
11+
- os: linux
12+
python: 3.6
13+
- os: linux
14+
python: 3.7
15+
dist: xenial
16+
sudo: true
1117

1218
install:
13-
- pip install -r test-requirements.txt
19+
- pip install -r requirements/test.txt
20+
- pip install -r requirements/sdk.txt
21+
- pip install pytest-cov
1422

1523
script:
16-
- flake8 connectsdk
24+
- flake8 connect
25+
- pytest --cov-report=xml --cov=./connect
26+
27+
after_success:
28+
- bash <(curl -s https://codecov.io/bash)
29+
30+
deploy:
31+
provider: pypi
32+
user: apslite
33+
password:
34+
secure: nzWd7Fqgi/K5YKqrAPkIBkgRImWQyQgD2/qP3fYksyJnIFWNcea5T4EKqQKXIPZHh1K0cRhT7mSjIfIrQ6H3XKM/eMTAlz6pbisG2cuu4ueUBjbxHCVCkwzBPgF7+DuCJUXJ/SHyoqMnTdAQo8fb8g69/UCmnUp37YoDO1YHXIMjFVkNc6PFS7nQElXnWkvWd1SpQgA1ZdWdwBzEnIiq+L6IFeTa83PH0Schkem/vR9Ql9CmuliovNt3yHfFaeIqLUgOmsfrwOtDVs0/SkcF+Gg5tNds7DHH2TR4fHco5s8F+n4FVgv2DUPlvBbOVvUH1RiRB8hdATetUxe1cU8fT1nPdJASLWS5E4b4knGLH53+bGxqPVezHxghbVYZHPXp7yI1zWX/Wtn9MBiAo9S3f+Tf8zTk5PIjAJLG/Sdn0RX8mLn89fsslku3enH/FknwPtG+xVYSzUlrd+yzHKnqYkKJzMjsBq/F5+shmYSDlnGdGv+Ga3xZSjIoXlphO5qpxR7vrGnLMxEPJC06+mPgPZp1qfDMyrei/IAPRP8qYPC+Vnj8yclH/UyBKT66z2UEP1z5Op99fUXi3W59x2zdVaLHYniNf16UqtrE5kc7gdLvVcH+NtbO716SAbvO5ql/JsYYTmDSoWEC9KWZS+4E7p7n45c8DEieg8Q5HThWF9Y=
35+
on:
36+
tags: true
37+
all_branches: true
38+
distributions: sdist
39+
condition: "$BUILD = PYPI"

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include requirements/sdk.txt
2+
include connect/logger/config.json
3+
include VERSION

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Connect Python SDK
22

3+
![pyversions](https://img.shields.io/pypi/pyversions/connect-sdk.svg) [![PyPi Status](https://img.shields.io/pypi/v/connect-sdk.svg)](https://pypi.org/project/connect-sdk/) [![codecov](https://codecov.io/gh/ingrammicro/connect-python-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/ingrammicro/connect-python-sdk) [![Build Status](https://travis-ci.org/ingrammicro/connect-python-sdk.svg?branch=master)](https://travis-ci.org/ingrammicro/connect-python-sdk) [![PyPI status](https://img.shields.io/pypi/status/connect-sdk.svg)](https://pypi.python.org/pypi/connect-sdk/)
34
### Getting Started
45
---
6+
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.
7+
8+
In order to use this library, please ensure that you have read first the documentation available on Connect knowladge base article located here, this one will provide you a great information on the rest api that this library implements.
59
### Class Features
610
---
711
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:
@@ -25,13 +29,19 @@ Your code may use any scheduler to execute, from a simple cron to a cloud schedu
2529
```sh
2630
$ pip install connect-sdk
2731
```
32+
33+
### Requirements
34+
* Python 2.7+ or Python 3.4+
35+
* Requests (https://pypi.org/project/requests/)
36+
* Marshmallow (https://pypi.org/project/marshmallow/)
37+
2838
### Example
2939
```python
30-
from connectsdk.config import Config
31-
from connectsdk.logger import logger
32-
from connectsdk.models import ActivationTemplateResponse, ActivationTileResponse
33-
from connectsdk.models.exception import FulfillmentFail, FulfillmentInquire, Skip
34-
from connectsdk.resource import FulfillmentAutomation
40+
from connect import FulfillmentAutomation
41+
from connect.config import Config
42+
from connect.logger import logger
43+
from connect.models import ActivationTemplateResponse, ActivationTileResponse
44+
from connect.models.exception import FulfillmentFail, FulfillmentInquire, Skip
3545

3646
Config(file='config.json')
3747

@@ -76,6 +86,5 @@ class ExampleRequestProcessor(FulfillmentAutomation):
7686
if __name__ == '__main__':
7787
request = ExampleRequestProcessor()
7888
request.process()
79-
8089
```
8190

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

connect/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from .resource import FulfillmentAutomation
2+
3+
name = 'connect'
4+
5+
__all__ = [
6+
'config',
7+
'resource',
8+
'models',
9+
'logger',
10+
'FulfillmentAutomation'
11+
]
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
# -*- coding: utf-8 -*-
2+
13
import json
24
import os
35

4-
from six import string_types
5-
66

77
class Config(object):
88
api_url = None
@@ -46,7 +46,7 @@ def _set_attr(api_url, api_key, products=None):
4646
Config.api_url = api_url
4747
if products:
4848
Config.products = [products] if isinstance(
49-
products, string_types) else products
49+
products, str) else products
5050

5151
@staticmethod
5252
def check_credentials(api_url, api_key, products):
@@ -60,7 +60,7 @@ def check_credentials(api_url, api_key, products):
6060
raise ValueError('Please provide your credentials.'
6161
'Not set value for `api_key` or `api_url`')
6262

63-
if products and not isinstance(products, (string_types, list)):
63+
if products and not isinstance(products, (str, list)):
6464
raise TypeError('Products can be string or string list. Found type '
6565
+ type(products).__name__)
6666

@@ -89,9 +89,13 @@ def load_from_file(self, file):
8989
raise TypeError('Invalid config file `{}`\n'
9090
'ERROR: {}'.format(file, str(ex)))
9191

92-
(api_url, api_key, products) = (configs.get('apiEndpoint'),
93-
configs.get('apiKey'),
94-
configs.get('products'))
92+
(api_url, api_key, products) = (configs.get('apiEndpoint', ''),
93+
configs.get('apiKey', ''),
94+
configs.get('products', ''))
95+
96+
products = products.encode('utf-8') if not isinstance(products, (str, list)) else products
97+
api_url = api_url.encode('utf-8') if not isinstance(api_url, str) else api_url
98+
api_key = api_key.encode('utf-8') if not isinstance(api_key, str) else api_key
9599

96100
self.check_credentials(api_url, api_key, products)
97101
self._set_attr(api_url, api_key, products)
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
# -*- coding: utf-8 -*-
2+
13
import json
24
import logging
35
import os
46
from logging.config import dictConfig
57

6-
with open(os.path.join(os.path.dirname(__file__), 'config.json'), encoding="utf-8") as config_file:
8+
with open(os.path.join(os.path.dirname(__file__), 'config.json')) as config_file:
79
config = json.load(config_file)
810

911
dictConfig(config['logging'])
@@ -20,4 +22,5 @@ def decorator(self, *args, **kwargs):
2022
logger.debug(
2123
'Function `{}.{}` return: {}'.format(self.__class__.__name__, func.__name__, result))
2224
return result
25+
2326
return decorator
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from .activation_response import ActivationTemplateResponse, ActivationTileResponse
2-
from .schema import BaseScheme, FulfillmentScheme, Param, ParamScheme, ServerErrorScheme
2+
from .base import BaseScheme
3+
from .fulfillment import FulfillmentScheme
4+
from .parameters import Param, ParamScheme
5+
from .server_error import ServerErrorScheme
36

47
__all__ = [
58
'ActivationTemplateResponse',

0 commit comments

Comments
 (0)