Skip to content

Commit

Permalink
adding pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkahan committed Aug 24, 2023
1 parent dfeb751 commit e2cdd38
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 36 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ jobs:
- name: Run codecov
uses: codecov/codecov-action@v3

format:
runs-on: ubuntu-latest
steps:
- name: Format commits
uses: pre-commit-ci/lite-action@v1.0.1
if: always()

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
- uses: psf/black@stable
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.4
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
language_version: python3.11
- repo: https://github.com/ambv/black
rev: 18.6b4
rev: 23.7.0
hooks:
- id: black
language_version: python3.11
66 changes: 34 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ The delivery receipt URL can be unset by sending an empty string.

## Messages API

The Messages API is an API that allows you to send messages via SMS, MMS, WhatsApp, Messenger and Viber. Call the API from your Python code by
The Messages API is an API that allows you to send messages via SMS, MMS, WhatsApp, Messenger and Viber. Call the API from your Python code by
passing a dict of parameters into the `client.messages.send_message()` method.

It accepts JWT or API key/secret authentication.
Expand All @@ -174,9 +174,9 @@ Some basic samples are below. For more detailed information and code snippets, p
### Send an SMS
```python
responseData = client.messages.send_message({
'channel': 'sms',
'message_type': 'text',
'to': '447123456789',
'channel': 'sms',
'message_type': 'text',
'to': '447123456789',
'from': 'Vonage',
'text': 'Hello from Vonage'
})
Expand All @@ -187,9 +187,9 @@ Note: only available in the US. You will need a 10DLC number to send an MMS mess

```python
client.messages.send_message({
'channel': 'mms',
'message_type': 'image',
'to': '11112223333',
'channel': 'mms',
'message_type': 'image',
'to': '11112223333',
'from': '1223345567',
'image': {'url': 'https://example.com/image.jpg', 'caption': 'Test Image'}
})
Expand All @@ -203,9 +203,9 @@ type to a user if they have messaged your business number in the last 24 hours.

```python
client.messages.send_message({
'channel': 'whatsapp',
'message_type': 'audio',
'to': '447123456789',
'channel': 'whatsapp',
'message_type': 'audio',
'to': '447123456789',
'from': '440123456789',
'audio': {'url': 'https://example.com/audio.mp3'}
})
Expand All @@ -218,9 +218,9 @@ You will need to link your Facebook business page to your Vonage account in the

```python
client.messages.send_message({
'channel': 'messenger',
'message_type': 'video',
'to': '594123123123123',
'channel': 'messenger',
'message_type': 'video',
'to': '594123123123123',
'from': '1012312312312',
'video': {'url': 'https://example.com/video.mp4'}
})
Expand Down Expand Up @@ -420,7 +420,7 @@ You can also verify a user by WhatsApp Interactive Message or by Silent Authenti

```python
params = {
'brand': 'ACME, Inc',
'brand': 'ACME, Inc',
'workflow': [{'channel': 'sms', 'to': '447700900000'}]
}
verify_request = verify2.new_request(params)
Expand All @@ -430,7 +430,7 @@ verify_request = verify2.new_request(params)

```python
params = {
'brand': 'ACME, Inc',
'brand': 'ACME, Inc',
'workflow': [
{'channel': 'silent_auth', 'to': '447700900000'},
{'channel': 'email', 'to': 'customer@example.com', 'from': 'business@example.com'}
Expand Down Expand Up @@ -459,8 +459,8 @@ This feature is only enabled if you have requested for it to be added to your ac

```python
params = {
'brand': 'ACME, Inc',
'fraud_check': False,
'brand': 'ACME, Inc',
'fraud_check': False,
'workflow': [{'channel': 'sms', 'to': '447700900000'}]
}
verify_request = verify2.new_request(params)
Expand Down Expand Up @@ -845,7 +845,7 @@ client.account.get_balance()
This feature is only enabled when you enable auto-reload for your account in the dashboard.
```python
# trx is the reference from when auto-reload was enabled and money was added
client.account.topup(trx=transaction_reference)
client.account.topup(trx=transaction_reference)
```

## Subaccounts API
Expand All @@ -867,8 +867,8 @@ client.subaccounts.create_subaccount(name='my subaccount')

# With options
client.subaccounts.create_subaccount(
name='my subaccount',
secret='Password123',
name='my subaccount',
secret='Password123',
use_primary_account_balance=False,
)
```
Expand Down Expand Up @@ -898,7 +898,7 @@ All fields are optional. If `start_date` or `end_date` are used, the dates must
client.subaccounts.list_credit_transfers(
start_date='2022-03-29T14:16:56Z',
end_date='2023-06-12T17:20:01Z',
subaccount=SUBACCOUNT_API_KEY, # Use to show only the results that contain this key
subaccount=SUBACCOUNT_API_KEY, # Use to show only the results that contain this key
)
```

Expand All @@ -908,9 +908,9 @@ Transferring credit is only possible for postpaid accounts, i.e. accounts that c

```python
client.subaccounts.transfer_credit(
from_=FROM_ACCOUNT,
to=TO_ACCOUNT,
amount=0.50,
from_=FROM_ACCOUNT,
to=TO_ACCOUNT,
amount=0.50,
reference='test credit transfer',
)
```
Expand All @@ -923,17 +923,17 @@ All fields are optional. If `start_date` or `end_date` are used, the dates must
client.subaccounts.list_balance_transfers(
start_date='2022-03-29T14:16:56Z',
end_date='2023-06-12T17:20:01Z',
subaccount=SUBACCOUNT_API_KEY, # Use to show only the results that contain this key
subaccount=SUBACCOUNT_API_KEY, # Use to show only the results that contain this key
)
```

### Transfer account balances between accounts

```python
client.subaccounts.transfer_balance(
from_=FROM_ACCOUNT,
to=TO_ACCOUNT,
amount=0.50,
from_=FROM_ACCOUNT,
to=TO_ACCOUNT,
amount=0.50,
reference='test balance transfer',
)
```
Expand All @@ -942,9 +942,9 @@ client.subaccounts.transfer_balance(

```python
client.subaccounts.transfer_balance(
from_=FROM_ACCOUNT,
to=TO_ACCOUNT,
number=NUMBER_TO_TRANSFER,
from_=FROM_ACCOUNT,
to=TO_ACCOUNT,
number=NUMBER_TO_TRANSFER,
country='US',
)
```
Expand Down Expand Up @@ -1217,7 +1217,7 @@ We don't currently support asyncio in the Python SDK but we are planning to do s

## Contributing

We :heart: contributions! But if you plan to work on something big or controversial, please [contact us](mailto:devrel@vonage.com) first!
We :heart: contributions! But if you plan to work on something big or controversial, please contact us by raising an issue first!

We recommend working on `vonage-python-sdk` with a [virtualenv][virtualenv]. The following command will install all the Python dependencies you need to run the tests:

Expand All @@ -1231,6 +1231,8 @@ The tests are all written with pytest. You run them with:
make test
```

We use [Black](https://black.readthedocs.io/en/stable/index.html) for code formatting, with our config in the `pyproject.toml` file. Please make sure your PRs follow this format.

## License

This library is released under the [Apache License][license].
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pydantic>=1.10,==1.*

bump2version
build
twine
twine
pre-commit

0 comments on commit e2cdd38

Please sign in to comment.