Skip to content

Commit

Permalink
Generated Xendit python SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
xendit-devx-bot committed Nov 29, 2023
1 parent 6c60b12 commit 988b18b
Show file tree
Hide file tree
Showing 134 changed files with 3,658 additions and 120 deletions.
61 changes: 58 additions & 3 deletions .github/workflows/generate-release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,67 @@ on:
types: [create-release-tag]

jobs:
build:
testing:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10","3.11","3.12"]
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Print python version
run: python --version

- name: Install dependencies
run: pip install -r requirements.txt

- name: Run test
run: DEVELOPMENT_API_KEY=${{ secrets.DEVELOPMENT_API_KEY }} pytest -s --log-cli-level=DEBUG

send-test-result:
name: Slack Notification
needs: [testing]
if: always() && (needs.testing.result == 'success' || needs.testing.result == 'failure')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set Slack Color
id: set_color
run: |
if [ "${{ needs.testing.result }}" == "success" ]; then
echo "color=good" >> $GITHUB_ENV
else
echo "color=danger" >> $GITHUB_ENV
fi
- name: Send Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_TITLE: "[xendi-python] CI pipeline for ${{ github.event.client_payload.version }}"
SLACK_MESSAGE: 'Test Result: ${{ needs.testing.result }}'
SLACK_COLOR: ${{ steps.set_color.outputs.color }}

publish-release-tag:
runs-on: ubuntu-latest
needs: [testing]
steps:
- uses: actions/checkout@v3

- name: Set the value in bash
id: parse-changelog
run: |
echo "changelog<<EOF" >> "$GITHUB_OUTPUT"
echo "${{ github.event.client_payload.changelog }}" | sed -e 's/%0A/\n/g' >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Create Release
id: create-release
uses: actions/create-release@latest
Expand All @@ -27,7 +78,7 @@ jobs:
prerelease: false

publish-pypi:
needs: [build]
needs: [publish-release-tag]
runs-on: ubuntu-latest
environment:
name: pypi
Expand All @@ -36,16 +87,20 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: '1.6.1'

- name: Build Package
run: |
poetry install
poetry build
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@release/v1
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,4 @@ target/
.ipynb_checkpoints

.vscode/
test.py

# virtual environment
xendit-python
test.py
10 changes: 10 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.gitignore
LICENSE
README.md
docs/Configuration.md
docs/PaymentRequestApi.md
docs/payment_request/Capture.md
docs/payment_request/CaptureList.md
Expand Down Expand Up @@ -31,10 +32,13 @@ docs/payment_request/EWalletChannelCode.md
docs/payment_request/EWalletChannelProperties.md
docs/payment_request/EWalletParameters.md
docs/payment_request/Error.md
docs/payment_request/InvoicePartnerMetadata.md
docs/payment_request/OverTheCounter.md
docs/payment_request/OverTheCounterChannelCode.md
docs/payment_request/OverTheCounterChannelProperties.md
docs/payment_request/OverTheCounterParameters.md
docs/payment_request/PaymentCallback.md
docs/payment_request/PaymentCallbackData.md
docs/payment_request/PaymentMethod.md
docs/payment_request/PaymentMethodParameters.md
docs/payment_request/PaymentMethodReusability.md
Expand Down Expand Up @@ -84,6 +88,9 @@ test/test_direct_debit_channel_properties_bank_account.py
test/test_direct_debit_channel_properties_bank_redirect.py
test/test_direct_debit_channel_properties_debit_card.py
test/test_e_wallet_all_of.py
test/test_invoice_partner_metadata.py
test/test_payment_callback.py
test/test_payment_callback_data.py
test/test_payment_request.py
test/test_payment_request_action.py
test/test_payment_request_api.py
Expand Down Expand Up @@ -142,10 +149,13 @@ xendit/payment_request/model/e_wallet_channel_code.py
xendit/payment_request/model/e_wallet_channel_properties.py
xendit/payment_request/model/e_wallet_parameters.py
xendit/payment_request/model/error.py
xendit/payment_request/model/invoice_partner_metadata.py
xendit/payment_request/model/over_the_counter.py
xendit/payment_request/model/over_the_counter_channel_code.py
xendit/payment_request/model/over_the_counter_channel_properties.py
xendit/payment_request/model/over_the_counter_parameters.py
xendit/payment_request/model/payment_callback.py
xendit/payment_request/model/payment_callback_data.py
xendit/payment_request/model/payment_method.py
xendit/payment_request/model/payment_method_parameters.py
xendit/payment_request/model/payment_method_reusability.py
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The official Xendit Python SDK provides a simple and convenient way to call Xendit's REST API
in applications written in Python.

* Package version: 3.6.0
* Package version: 3.7.0

## Requirements

Expand Down Expand Up @@ -48,18 +48,18 @@ You can sign up for a free Dashboard account [here](https://dashboard.xendit.co/

```python
import xendit
from xendit.apis import BalancesApi
from xendit.apis import BalanceApi
from pprint import pprint

xendit.set_api_key('XENDIT_API_KEY')

client = xendit.ApiClient()

try:
response = BalancesApi(client).get_balance('CASH')
response = BalanceApi(client).get_balance('CASH')
pprint(response)
except xendit.XenditSdkException as e:
print("Exception when calling BalancesApi->get_balance: %s\n" % e)
print("Exception when calling BalanceApi->get_balance: %s\n" % e)
```

# Documentation
Expand All @@ -80,4 +80,4 @@ All URIs are relative to *https://api.xendit.co*. For more information about ou
Further Reading

* [Xendit Docs](https://docs.xendit.co/)
* [Xendit API Reference](https://developers.xendit.co/)
* [Xendit API Reference](https://developers.xendit.co/)
1 change: 1 addition & 0 deletions docs/BalanceApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ except xendit.XenditSdkException as e:
print("Exception when calling BalanceApi->get_balance: %s\n" % e)
```


[[Back to README]](../README.md)
46 changes: 46 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Configuration

To start using the API, you need to configure the secret key and initiate the client instance.
You can use all the configurable parameters in the `configuration.py` file to customize your client (e.g. setting up proxy)

## Configuration Parameters

Here are the parameters you can set:

| Name | Type | Description | Default | Example |
|-------------|:----------:|:---------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|--------------------------------------------------------------------------|
| **host** | **str** | Base URL | https://api.xendit.co | https://www.example.com |
| **api_key** | **str** | Xendit API Key | None | `xnd_development_abcdefghijke9112015j1nuq808912tr` |
| **proxy** | **str** | Proxy URL | None | https://www.proxy.example.com |
| **ssl_ca_cert** | **str** | Specifies the path to a PEM format CA certificate files, which can be used to verify the backend server certificates | None | `/path/to/your/example_cert.crt` |
| **logger** | **map** | Logging Settings (e.g. `package_logger`, `urllib3_logger`) | `{"package_logger": "xendit", "urllib3_logger": "urllib3"}` | `{"package_logger": "your_logger_package", "urllib3_logger": "urllib3"}` |
| **logger_format** | **str** | Log format | `%(asctime)s %(levelname)s %(message)s` | `%(asctime)s %(levelname)s %(message)s` |
| **logger_file** | **str** | Debug file location | None | `/path/to/your/debug_file.txt` |
| **debug** | **bool** | Debug Switch | `False` | `True` |
| **connection_pool_maxsize** | **number** | urllib3 connection pool's maximum number of connections saved per pool. | `multiprocessing.cpu_count() * 5` | 5 |

## Sample Usage

Some parameters are able to set during initialization, e.g. `host`, `api_key`
Some are set after initialization, e.g. `proxy`

```python
import xendit

configuration = xendit.Configuration(
host='https://www.example.com',
api_key='xnd_development_abcdefghijke9112015j1nuq808912tr'
)
configuration.proxy = 'https://www.proxy.example.com'
configuration.ssl_ca_cert = '/path/to/your/example_cert.crt'
configuration.logger["package_logger"] = 'your_logger_package'
configuration.logger["urllib3_logger"] = 'urllib3_logger'
configuration.logger_format = '%(asctime)s %(levelname)s %(message)s`'
configuration.logger_file = 'path/to/your/debug_file.txt'
configuration.connection_pool_maxsize = 10

# Enter a context with an instance of the API client
api_client = xendit.ApiClient(configuration)
```


1 change: 1 addition & 0 deletions docs/CustomerApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,5 @@ except xendit.XenditSdkException as e:
print("Exception when calling CustomerApi->update_customer: %s\n" % e)
```


[[Back to README]](../README.md)
51 changes: 47 additions & 4 deletions docs/InvoiceApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ create_invoice_request = CreateInvoiceRequest(
),
],
) # CreateInvoiceRequest
for_user_id = "62efe4c33e45694d63f585f8" # str | Business ID of the sub-account merchant (XP feature)
for_user_id = "62efe4c33e45694d63f585f0" # str | Business ID of the sub-account merchant (XP feature)

# example passing only required values which don't have defaults set
try:
Expand Down Expand Up @@ -204,7 +204,7 @@ api_client = xendit.ApiClient()
# Create an instance of the API class
api_instance = InvoiceApi(api_client)
invoice_id = "62efe4c33e45294d63f585f2" # str | Invoice ID
for_user_id = "62efe4c33e45694d63f585f8" # str | Business ID of the sub-account merchant (XP feature)
for_user_id = "62efe4c33e45694d63f585f0" # str | Business ID of the sub-account merchant (XP feature)

# example passing only required values which don't have defaults set
try:
Expand Down Expand Up @@ -275,7 +275,7 @@ xendit.set_api_key('XENDIT API KEY')
api_client = xendit.ApiClient()
# Create an instance of the API class
api_instance = InvoiceApi(api_client)
for_user_id = "62efe4c33e45694d63f585f8" # str | Business ID of the sub-account merchant (XP feature)
for_user_id = "62efe4c33e45694d63f585f0" # str | Business ID of the sub-account merchant (XP feature)
external_id = "test-external" # str
statuses = [
InvoiceStatus("["PENDING","SETTLED"]"),
Expand Down Expand Up @@ -342,7 +342,7 @@ api_client = xendit.ApiClient()
# Create an instance of the API class
api_instance = InvoiceApi(api_client)
invoice_id = "5f4708b7bd394b0400b96276" # str | Invoice ID to be expired
for_user_id = "62efe4c33e45694d63f585f8" # str | Business ID of the sub-account merchant (XP feature)
for_user_id = "62efe4c33e45694d63f585f0" # str | Business ID of the sub-account merchant (XP feature)

# example passing only required values which don't have defaults set
try:
Expand All @@ -362,4 +362,47 @@ except xendit.XenditSdkException as e:
print("Exception when calling InvoiceApi->expire_invoice: %s\n" % e)
```


## Callback Objects
Use the following callback objects provided by Xendit to receive callbacks (also known as webhooks) that Xendit sends you on events, such as successful payments. Note that the example is meant to illustrate the contents of the callback object -- you will not need to instantiate these objects in practice
### InvoiceCallback Object
>Invoice Callback Object
Model Documentation: [InvoiceCallback](/InvoiceCallback.md)
#### Usage Example
Note that the example is meant to illustrate the contents of the callback object -- you will not need to instantiate these objects in practice
```python
import xendit
from xendit.invoice.model import InvoiceCallback
import json
from pprint import pprint

invoice_callback_obj = {
"id" : "593f4ed1c3d3bb7f39733d83",
"external_id" : "testing-invoice",
"user_id" : "5848fdf860053555135587e7",
"payment_method" : "RETAIL_OUTLET",
"status" : "PAID",
"merchant_name" : "Xendit",
"amount" : 2000000,
"paid_amount" : 2000000,
"paid_at" : "2020-01-14T02:32:50.912Z",
"payer_email" : "[email protected]",
"description" : "Invoice webhook test",
"created" : "2020-01-13T02:32:49.827Z",
"updated" : "2020-01-13T02:32:50.912Z",
"currency" : "IDR",
"payment_channel" : "ALFAMART",
"payment_destination" : "TEST815"
}
invoice_callback_json = json.dumps(invoice_callback_obj)
```

You may then use the callback object in your webhook or callback handler like so,
```python
def SimulateInvoiceCallback(invoice_callback_json) {
callback_obj = InvoiceCallback(**json.loads(invoice_callback_json))
// do things here with the callback
}
```
[[Back to README]](../README.md)
Loading

0 comments on commit 988b18b

Please sign in to comment.