Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Bailey committed Nov 8, 2016
1 parent f173508 commit 0e65150
Show file tree
Hide file tree
Showing 186 changed files with 9,937 additions and 6,389 deletions.
71 changes: 43 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,46 +1,61 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*.pyc
*.pypirc

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
lib
lib64
MANIFEST
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.tox
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# PyBuilder
target/

#PyCharm
.idea
.DS_Store

# VS
*.suo
TestResults
mangopay2-python-sdk.pyproj.user
_ReSharper.mangopay2-python-sdk
tests/credentials.py
17 changes: 4 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
language: python
python:
- "2.7"
- "3.3"

- "3.4"
install:
- pip install .
- pip install requests
- pip install requests-oauthlib
- pip install fasteners
- pip install coveralls

script:
- make coverage

after_success:
- coveralls
- "pip install -r requirements/base.txt"
- "pip install -r requirements/development.txt"
script: nosetests
1 change: 1 addition & 0 deletions DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This SDK is a client library for interacting with the Mangopay API.
26 changes: 14 additions & 12 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
The MIT License (MIT)

Copyright (c) 2013 Mangopay
Copyright (c) 2016 MANGOPAY

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

10 changes: 8 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
include *.txt
include README.md
include LICENSE
include MANIFEST.in
include README.md
include DESCRIPTION.md
include Makefile

recursive-include mangopay *
recursive-include tests *
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# These targets are not files
.PHONY: coverage test
install:
pip install -r requirements/base.txt

test:
python test_suite.py
nosetests -s tests --with-coverage --cover-erase --cover-package=tests

coverage:
coverage run --source=mangopaysdk test_suite.py
release:
python setup.py sdist register upload -s
125 changes: 22 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,130 +5,49 @@ MangopaySDK is a Python client library to work with
[Mangopay REST API](http://docs.mangopay.com/api-references/).


Compatibility Note
-------------------------------------------------
Since v1.8 of this SDK, you must be using at least v2.01 of the API ([more information about the changes required](https://docs.mangopay.com/api-v2-01-overview/))
Installation
------------

python-mangopay requires:

Installation and package dependencies
-------------------------------------------------
SDK has been written in Python 2.7+ and requires:
* [requests](https://pypi.python.org/pypi/requests)
* [blinker](https://pypi.python.org/pypi/blinker)

To install the package:

requests
requests-oauthlib
fasteners
```
pip install python-mangopay
```

If you have problem with using token file based cache (Configuration.TempPath) you can use memory cache:
By installing this package with [pip](https://pypi.python.org/pypi/pip), all dependencies will be installed for you.

sdk = MangoPayApi()
sdk.OAuthTokenManager.RegisterCustomStorageStrategy(MemoryStorageStrategy())

We strongly recommend using PIP as installation method:
Documentation
-------------

pip install mangopaysdk
For documentation and examples of usage for the Mangopay API please refer to: [API references](https://docs.mangopay.com/api-references/)

See [docs](https://github.com/mangopay/mangopay2-python-sdk-v2/tree/master/docs) to find examples.

License
-------------------------------------------------
MangopaySDK is distributed under MIT license, see LICENSE file.


Unit Tests (not included in pip package)
-------------------------------------------------

cd project_directory

# runs ALL tests:
python -m unittest test_suite

# runs single module/class/method:
python -m unittest test_module1 test_module2
python -m unittest test_module.TestClass
python -m unittest test_module.TestClass.test_method


Contact
-------------------------------------------------
Report bugs or suggest features using [issue tracker at GitHub](https://github.com/MangoPay/mangopay2-python-sdk).
Report bugs or suggest features using [issue tracker at GitHub](https://github.com/MangoPay/mangopay2-python-sdk-v2).


Account creation
-------------------------------------------------
You can get yourself a [free sandbox account](https://www.mangopay.com/signup/create-sandbox/) or sign up for a [production account](https://www.mangopay.com/signup/submit-your-app/go-live/) (note that validation of your production account can take a few days, so think about doing it in advance of when you actually want to go live).

Inspiration
-----------

Configuration
-------------------------------------------------
Using the credential info from the signup process above, you should then set `api.Config.ClientID` to your MangoPay Client ID and `api.Config.ClientPassword` to your passphrase.

You also need to set a folder path in `api.Config.TempPath` that SDK needs to store temporary files.
This path should be outside your www folder.
It could be `/tmp/` or `/var/tmp/` or any other location that Python can write to.

`api.Config.BaseUrl` is set to sandbox environment by default. To enable production environment, set it to `https://api.mangopay.com`.

Below is the example showing how to configure SDK:

from mangopaysdk.mangopayapi import MangoPayApi
api = MangoPayApi()

# configure client credentials
api.Config.ClientID = 'your-client-id'
api.Config.ClientPassword = 'your-client-passphrase'
api.Config.TempPath = "C:\Temp\\" # or "/tmp" on linux
api.Config.BaseUrl = "https://api.sandbox.mangopay.com"
api.Config.SSLVerification = 'path-to-your-cacert.pem-file'

# call API methods, i.e.:
users = api.users.GetAll()


SSL verification
-------------------------------------------------
The default value of `SSLVerification` is `False`, which means there's no verification. In such a case you will be notified about that by the `InsecureRequestWarning` message, i.e.:
`InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html`

In order to easily verify your HTTPS requests (and remove warning message), you can put a path to the `cacert.pem` file as the value of `SSLVerification` property.
You should find that file in `Python_installation_folder\Lib\site-packages\requests`, so setting the path may look similar to the following (for Windows OS):

sdk.Config.SSLVerification = 'C:\\Python27\\Lib\\site-packages\\requests\\cacert.pem'


Connection pooling
-------------------------------------------------
To benefit from HTTP connection reuse you need to set `api.Config.Session` like this:

import requests
api.Config.Session = requests.Session()

WARNING: sessions are not guaranteed to be thread-safe!

See the upstream [Session Objects](http://docs.python-requests.org/en/master/user/advanced/#session-objects) documentation for more details.


Sample usage
-------------------------------------------------

from mangopaysdk.mangopayapi import MangoPayApi
api = MangoPayApi()

# configuration
api.Config.ClientID = 'your-client-id'
api.Config.ClientPassword = 'your-client-passphrase'

# get some user by ID
john = api.users.Get(userId)

# change and update some of his data
john.LastName += " - CHANGED"
api.users.Update(john)

# get all users (with pagination)
from mangopaysdk.types.pagination import Pagination
pagination = Pagination(1, 8) # get 1st page, 8 items per page
users = api.users.GetAll(pagination)
The data model of python-mangopay is highly inspired by [peewee](https://github.com/coleifer/peewee).

# get his bank accounts
pagination = Pagination(2, 10) # get 2nd page, 10 items per page
accounts = api.users.GetBankAccounts(john.Id, pagination)
Credits
-----------

The inital basis of this SDK was generously coded and donated by [Ulule](https://www.ulule.com/)
33 changes: 0 additions & 33 deletions _tmp_example.py

This file was deleted.

Loading

0 comments on commit 0e65150

Please sign in to comment.