Skip to content

Commit 8d83030

Browse files
author
pierre-pg
authored
Merge pull request #9 from payplug/ghactions-ci
Refresh lib: add api version and fix tests
2 parents 42dec9d + f377dbd commit 8d83030

20 files changed

+146
-80
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: CI
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
11+
pull_request:
12+
branches:
13+
- master
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-18.04
18+
19+
strategy:
20+
matrix:
21+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3]
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v1
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -r requirements.txt
35+
36+
- name: Test with tox
37+
run: |
38+
pip install "pytest" "tox>=1.9" "tox-gh-actions"
39+
tox

.python-version

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
3.8.2
2+
3.7.7
13
3.5.1
24
2.7.11
35
3.4.3

.travis.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
1.2.2
2+
-----
3+
- Add API version setting
4+
- Fix tests
5+
- Move CI to Github Actions
6+
17
1.2.1
28
-----
39
- Require pyOpenSSL>=0.15 to prevent random failures.

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Python library for the PayPlug API
22
==================================
33

4-
.. image:: https://travis-ci.org/payplug/payplug-python.svg?branch=master
5-
:target: https://travis-ci.org/payplug/payplug-python
4+
.. image:: https://github.com/payplug/payplug-python/workflows/CI/badge.svg
5+
:target: https://github.com/payplug/payplug-python/actions
66
:alt: CI Status
77

88
.. image:: https://img.shields.io/pypi/v/payplug.svg?maxAge=2592000
@@ -61,7 +61,7 @@ To get started, add the following piece of code to the header of your Python pro
6161

6262
import payplug
6363

64-
If everything run without error, congratulations. You installed PayPlug python library! You're ready to create your
64+
If everything runs without errors, congratulations. You installed PayPlug python library! You're ready to create your
6565
first payment.
6666

6767
Usage

payplug/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
from datetime import datetime
23
from six import string_types
34
from payplug import config, exceptions, network, notifications, resources, routes
45
from payplug.network import HttpClient, UrllibRequest
@@ -28,6 +29,24 @@ def set_secret_key(token):
2829

2930
config.secret_key = token
3031

32+
def set_api_version(version):
33+
"""
34+
Specify the PayPlug API version to use.
35+
36+
:Example
37+
38+
>>> import payplug
39+
>>> payplug.set_api_version("2019-08-06")
40+
41+
:param version: the desired version, as an ISO-8601 date
42+
:type version: string
43+
"""
44+
45+
if not isinstance(version, string_types) and version is not None:
46+
raise exceptions.ConfigurationError('Expected string value for API version.')
47+
48+
config.api_version = version
49+
3150

3251
class Payment(object):
3352
"""

payplug/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = '1.2.1'
2+
__version__ = '1.2.2'

payplug/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
CACERT_PATH = os.path.join(os.path.dirname(__file__), 'certs', 'cacert.pem')
1717

1818
secret_key = None
19+
api_version = None

payplug/network.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class HttpClient(object):
158158
"""
159159
HTTP Client that relies on HttpRequest to perform requests.
160160
"""
161-
def __init__(self, token=None, request_handler=None):
161+
def __init__(self, token=None, request_handler=None, api_version=None):
162162
"""
163163
:param token: the secret key that will be used to authenticate API requests
164164
:type token: string
@@ -173,6 +173,7 @@ def __init__(self, token=None, request_handler=None):
173173
raise exceptions.SecretKeyNotSet('You must set your secret key using payplug.set_secret_key() function.')
174174

175175
self._secret_key = token or config.secret_key
176+
self._api_version = api_version or config.api_version
176177
self._request_handler = request_handler or available_clients[0]
177178

178179
def post(self, url, data=None):
@@ -280,6 +281,9 @@ def _request(self, http_verb, url, data=None, authenticated=True):
280281
if authenticated:
281282
headers['Authorization'] = 'Bearer ' + self._secret_key
282283

284+
if self._api_version:
285+
headers['PayPlug-Version'] = self._api_version
286+
283287
requestor = self._request_handler()
284288
response, status, _ = requestor.do_request(http_verb, url, headers, data)
285289

payplug/test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
class TestBase:
66
def setup_method(self, method):
77
payplug.secret_key = None
8+
payplug.api_version = None

0 commit comments

Comments
 (0)