Skip to content

Commit

Permalink
Merge pull request #12 from leynier/main
Browse files Browse the repository at this point in the history
feat: split implementation in two classes
  • Loading branch information
Carlos Lugones committed Oct 30, 2021
2 parents 086fe8a + e83fc2a commit 6a53093
Show file tree
Hide file tree
Showing 19 changed files with 908 additions and 708 deletions.
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: mixed-line-ending
args: ['--fix=lf']

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.8.0
hooks:
- id: isort
args: ['--multi-line=3', '--trailing-comma', '--force-grid-wrap=0', '--use-parentheses', '--line-width=88']

- repo: https://github.com/humitos/mirrors-autoflake.git
rev: v1.1
hooks:
- id: autoflake
args: ['--in-place', '--remove-all-unused-imports']

- repo: https://github.com/ambv/black
rev: 21.5b1
hooks:
- id: black
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
## 0.2.0 (2021-09-15)
## v0.3.0 (2021-10-30)

### Fix

- improve parsing method for evicting errors by fields aggregations

### Feat

- integrate pre-commit for avoid format errors
- split implementation in two classes

## v0.2.0 (2021-09-17)

### Fix

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ tests: install
poetry run flake8 . --count --show-source --statistics --max-line-length=88 --extend-ignore=E203
poetry run black . --check
poetry run isort . --profile=black
poetry run pre-commit run --all-files
poetry run pytest --cov=./ --cov-report=xml
60 changes: 42 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,62 @@ Create your account to process payments through **QvaPay** at [qvapay.com/regist

## Using the client

First, import the `QvaPayClient` class and create your **QvaPay** client using your app credentials.
First, import the `AsyncQvaPayClient` (or `SyncQvaPayClient`) class and create your **QvaPay** asynchronous (or synchronous) client using your app credentials.

```python
from qvapay.v1 import QvaPayClient
from qvapay.v1 import AsyncQvaPayClient

client = QvaPayClient(app_id, app_secret)
client = AsyncQvaPayClient(app_id, app_secret)
```

It is also possible to use the `QvaPayAuth` class (which by default obtains its properties from environment variables or from the content of the `.env` file) and the static method `QvaPayClient.from_auth` to initialize the client.
It is also possible to use the `QvaPayAuth` class (which by default obtains its properties from environment variables or from the content of the `.env` file) and the static method `AsyncQvaPayClient.from_auth` (or `SyncQvaPayClient.from_auth`) to initialize the client.

```python
from qvapay.v1 import QvaPayAuth, QvaPayClient
from qvapay.v1 import AsyncQvaPayClient, QvaPayAuth

client = QvaPayClient.from_auth(QvaPayAuth())
client = AsyncQvaPayClient.from_auth(QvaPayAuth())
```

### Use context manager

The recommended way to use a client is as a context manager. For example:

```python
[async] with QvaPayClient(...) as client:
async with AsyncQvaPayClient(...) as client:
# Do anything you want
...
```

or

```python
with SyncQvaPayClient(...) as client:
# Do anything you want
...
```

### Get your app info

```python
info = client.get_info()
# Use await when using AsyncQvaPayClient
# With SyncQvaPayClient it is not necessary.
info = await client.get_info()
```

### Get your account balance

```python
balance = client.get_balance()
# Use await when using AsyncQvaPayClient
# With SyncQvaPayClient it is not necessary.
balance = await client.get_balance()
```

### Create an invoice

```python
transaction = client.create_invoice(
# Use await when using AsyncQvaPayClient
# With SyncQvaPayClient it is not necessary.
transaction = await client.create_invoice(
amount=10,
description='Ebook',
remote_id='EE-BOOk-123' # example remote invoice id
Expand All @@ -88,27 +102,37 @@ transaction = client.create_invoice(
### Get transaction

```python
transaction = client.get_transaction(id)
# Use await when using AsyncQvaPayClient
# With SyncQvaPayClient it is not necessary.
transaction = await client.get_transaction(id)
```

### Get transactions

```python
transactions = client.get_transactions(page=1)
# Use await when using AsyncQvaPayClient
# With SyncQvaPayClient it is not necessary.
transactions = await client.get_transactions(page=1)
```

## Async features
You can also read the **QvaPay API** documentation: [qvapay.com/docs](https://qvapay.com/docs).

## For developers

You can also use the asynchronous version of the methods simply by appending `_async` to the method name at the end. For example:
The `_sync` folders were generated automatically executing the command `unasync qvapay tests`.

```python
info = await client.get_info_async()
```
The code that is added in the `_async` folders is automatically transformed.

You can also read the **QvaPay API** documentation: [qvapay.com/docs](https://qvapay.com/docs).
So every time to make a change you must run the command `unasync qvapay tests` to regenerate the folders `_sync` with the synchronous version of the implementation.

Improve `tests` implementation and add `pre-commit` system to ensure format and style.

## Migration guide

### 0.2.0 -> 0.3.0

- `QvaPayClient` was divided into two classes: `AsyncQvaPayClient` and `SyncQvaPayClient`. Both classes have the same methods and properties, with the difference that the methods in `AsyncQvaPayClient` are asynchronous and in `SyncQvaPayClient` are synchronous.

### 0.1.0 -> 0.2.0

- `user_id` of `Transaction` model was removed
Expand Down

0 comments on commit 6a53093

Please sign in to comment.