Metadata-Version: 2.1
Name: cardberg
Version: 0.2.0
Summary: Cardberg Service Bindings for Python
Home-page: UNKNOWN
Author: Palo Sopko
Author-email: pavol@sopko.sk
License: MIT
Project-URL: Bug Tracker, https://github.com/palosopko/cardberg-python/issues
Project-URL: Source Code, https://github.com/palosopko/cardberg-python
Keywords: cardberg
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
Description-Content-Type: text/markdown
Requires-Dist: requests (>=2.21.0)
Requires-Dist: six (>=1.3.0)

# Cardberg Bindings for Python

Python library for [Cardberg](https://www.cardberg.com)'s API to work with gift cards.

The bindings currently allow you to:

1. Get information on a specific card
2. Create a transaction on a specific card

Detailed information of Cardberg's API can be found at [their website](http://loyal.cardberg.com/api/). If you feel like you need covering additional API methods, please open an issue or create a pull request.

## Setup

You can install this package by using `pip`:

	pip install cardberg

If you fancy `pipenv` use:

	pipenv install cardberg

To install from source, run:

	python setup.py install

For the API client to work you would need Python 2.7+ or Python 3.4+.

To install via `requirements` file from your project, add the following for the moment before updating dependencies:

	git+git://github.com/palosopko/cardberg-python.git#egg=cardberg

## Usage

First off, you need to require the library and set the authentication information by providing your user handle and shared secret you got from the provider.

	import cardberg
	cardberg.api_credentials = ("partner_id", "shared_secret")

**Getting card information** is accomplished by calling `cardberg.Card.get()`. The method returns a `Card` object that includes `id`, `name`, `surname`, `status` and available `credits` and `points`. On this `Card` object we may **create a transaction** (whether positive or negative) by calling `create_transaction()` method with transaction type, decimal value of the transaction and optional bill ID for further reference.

Possible transaction types are either "credits" or "points" depending on what budget do we use. If you want to make a debit (for example your user is buying something) then provide a negative value.

Example:

    import cardberg
    from decimal import Decimal

    cardberg.api_credentials = ("partner_id", "shared_secret")

    card = cardberg.Card.get("D1nd17h")

    card.create_transaction(
        cardberg.Card.TRANSACTION_CREDITS,
        Decimal("-1.00")
    )

## Contributing

1.  Check for open issues or open a new issue for a feature request or a bug.
2.  Fork the repository and make your changes to the master branch (or branch off of it).
3.  Send a pull request.

## Development

Run all tests on all supported Python versions:

	make test

Run the linter with:

	make lint

The client library uses Black for code formatting. Code must be formatted with Black before PRs are submitted. Run the formatter with:

	make fmt

## Changelog

### v0.2.0: 03/10/2019

Python 3 compatibility, code formatting covered by Black and various small fixes and formal changes to make everything better.

### v0.1.1: 21/03/2016

Added rounding to two decimal places on credits and points returned from Cardberg's API.

### v0.1.0: 14/03/2016

Initial version with support for `card_info` and `create_transaction` API methods.


