# Ding Python SDK
The Ding Python library provides convenient access to the Ding API from applications written in the Python language.
<!-- Start Summary [summary] -->
## Summary
Ding: The OTP API allows you to send authentication codes to your users using their phone numbers.
<!-- End Summary [summary] -->
<!-- Start Table of Contents [toc] -->
## Table of Contents
* [SDK Installation](https://github.com/ding-live/ding-python/blob/master/#sdk-installation)
* [SDK Example Usage](https://github.com/ding-live/ding-python/blob/master/#sdk-example-usage)
* [Available Resources and Operations](https://github.com/ding-live/ding-python/blob/master/#available-resources-and-operations)
* [Error Handling](https://github.com/ding-live/ding-python/blob/master/#error-handling)
* [Server Selection](https://github.com/ding-live/ding-python/blob/master/#server-selection)
* [Custom HTTP Client](https://github.com/ding-live/ding-python/blob/master/#custom-http-client)
* [Authentication](https://github.com/ding-live/ding-python/blob/master/#authentication)
<!-- End Table of Contents [toc] -->
<!-- Start SDK Installation [installation] -->
## SDK Installation
The SDK can be installed using the *pip* package manager, with dependencies and metadata stored in the `setup.py` file.
```bash
pip install ding_api_client
```
<!-- End SDK Installation [installation] -->
## SDK Example Usage
<!-- Start SDK Example Usage [usage] -->
## SDK Example Usage
### Send a code
Send an OTP code to a user's phone number.
```python
import ding
from ding.models import components
s = ding.Ding(
api_key="YOUR_API_KEY",
)
res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(
customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',
phone_number='+1234567890',
))
if res.create_authentication_response is not None:
# handle response
pass
```
### Check a code
Check that a code entered by a user is valid.
```python
import ding
from ding.models import components
s = ding.Ding(
api_key="YOUR_API_KEY",
)
res = s.otp.check(request=components.CreateCheckRequest(
customer_uuid='e0e7b0e9-739d-424b-922f-1c2cb48ab077',
authentication_uuid='8f1196d5-806e-4b71-9b24-5f96ec052808',
check_code='123456',
))
if res.create_check_response is not None:
# handle response
pass
```
### Perform a retry
Perform a retry if a user has not received the code.
```python
import ding
s = ding.Ding(
api_key="YOUR_API_KEY",
)
res = s.otp.retry()
if res.retry_authentication_response is not None:
# handle response
pass
```
<!-- End SDK Example Usage [usage] -->
<!-- Start Available Resources and Operations [operations] -->
## Available Resources and Operations
<details open>
<summary>Available methods</summary>
### [lookup](https://github.com/ding-live/ding-python/blob/master/docs/sdks/lookup/README.md)
* [lookup](https://github.com/ding-live/ding-python/blob/master/docs/sdks/lookup/README.md#lookup) - Perform a phone number lookup
### [otp](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md)
* [create_authentication](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md#create_authentication) - Send a code
* [check](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md#check) - Check a code
* [feedback](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md#feedback) - Send feedback
* [retry](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md#retry) - Perform a retry
</details>
<!-- End Available Resources and Operations [operations] -->
<!-- Start Error Handling [errors] -->
## Error Handling
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
By default, an API error will raise a errors.SDKError exception, which has the following properties:
| Property | Type | Description |
|-----------------|------------------|-----------------------|
| `.status_code` | *int* | The HTTP status code |
| `.message` | *str* | The error message |
| `.raw_response` | *httpx.Response* | The raw HTTP response |
| `.body` | *str* | The response content |
When custom error responses are specified for an operation, the SDK may also raise their associated exception. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `create_authentication` method may raise the following exceptions:
| Error Type | Status Code | Content Type |
| -------------------- | -------------------- | -------------------- |
| errors.ErrorResponse | 400 | application/json |
| errors.SDKError | 4XX, 5XX | \*/\* |
### Example
```python
import ding
from ding.models import components, errors
s = ding.Ding(
api_key="YOUR_API_KEY",
)
res = None
try:
res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(
customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',
phone_number='+1234567890',
))
except errors.ErrorResponse as e:
# handle exception
raise(e)
except errors.SDKError as e:
# handle exception
raise(e)
if res.create_authentication_response is not None:
# handle response
pass
```
<!-- End Error Handling [errors] -->
<!-- Start Server Selection [server] -->
## Server Selection
### Select Server by Index
You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
| # | Server | Variables |
| - | ------ | --------- |
| 0 | `https://api.ding.live/v1` | None |
#### Example
```python
import ding
from ding.models import components
s = ding.Ding(
server_idx=0,
api_key="YOUR_API_KEY",
)
res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(
customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',
phone_number='+1234567890',
))
if res.create_authentication_response is not None:
# handle response
pass
```
### Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
```python
import ding
from ding.models import components
s = ding.Ding(
server_url="https://api.ding.live/v1",
api_key="YOUR_API_KEY",
)
res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(
customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',
phone_number='+1234567890',
))
if res.create_authentication_response is not None:
# handle response
pass
```
<!-- End Server Selection [server] -->
<!-- Start Custom HTTP Client [http-client] -->
## Custom HTTP Client
The Python SDK makes API calls using the [requests](https://pypi.org/project/requests/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `requests.Session` object.
For example, you could specify a header for every request that this sdk makes as follows:
```python
import ding
import requests
http_client = requests.Session()
http_client.headers.update({'x-custom-header': 'someValue'})
s = ding.Ding(client=http_client)
```
<!-- End Custom HTTP Client [http-client] -->
<!-- Start Authentication [security] -->
## Authentication
### Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
| --------- | --------- | --------- |
| `api_key` | apiKey | API key |
To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
```python
import ding
from ding.models import components
s = ding.Ding(
api_key="YOUR_API_KEY",
)
res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(
customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',
phone_number='+1234567890',
))
if res.create_authentication_response is not None:
# handle response
pass
```
<!-- End Authentication [security] -->
<!-- Placeholder for Future Speakeasy SDK Sections -->
# Development
## Contributions
While we value open-source contributions to this SDK, this library is generated programmatically.
Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!
Raw data
{
"_id": null,
"home_page": "https://github.com/ding-live/ding-python.git",
"name": "ding-api-client",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Ding",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/68/a5/2d28b35817b830bad1ea022d8fdbf7fc0a939fc16977219dbdd615c1c6b5/ding_api_client-3.8.11.tar.gz",
"platform": null,
"description": "# Ding Python SDK\n\nThe Ding Python library provides convenient access to the Ding API from applications written in the Python language.\n\n<!-- Start Summary [summary] -->\n## Summary\n\nDing: The OTP API allows you to send authentication codes to your users using their phone numbers.\n<!-- End Summary [summary] -->\n\n<!-- Start Table of Contents [toc] -->\n## Table of Contents\n\n* [SDK Installation](https://github.com/ding-live/ding-python/blob/master/#sdk-installation)\n* [SDK Example Usage](https://github.com/ding-live/ding-python/blob/master/#sdk-example-usage)\n* [Available Resources and Operations](https://github.com/ding-live/ding-python/blob/master/#available-resources-and-operations)\n* [Error Handling](https://github.com/ding-live/ding-python/blob/master/#error-handling)\n* [Server Selection](https://github.com/ding-live/ding-python/blob/master/#server-selection)\n* [Custom HTTP Client](https://github.com/ding-live/ding-python/blob/master/#custom-http-client)\n* [Authentication](https://github.com/ding-live/ding-python/blob/master/#authentication)\n<!-- End Table of Contents [toc] -->\n\n<!-- Start SDK Installation [installation] -->\n## SDK Installation\n\nThe SDK can be installed using the *pip* package manager, with dependencies and metadata stored in the `setup.py` file.\n\n```bash\npip install ding_api_client\n```\n<!-- End SDK Installation [installation] -->\n\n## SDK Example Usage\n\n<!-- Start SDK Example Usage [usage] -->\n## SDK Example Usage\n\n### Send a code\n\nSend an OTP code to a user's phone number.\n\n\n```python\nimport ding\nfrom ding.models import components\n\ns = ding.Ding(\n api_key=\"YOUR_API_KEY\",\n)\n\n\nres = s.otp.create_authentication(request=components.CreateAuthenticationRequest(\n customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',\n phone_number='+1234567890',\n))\n\nif res.create_authentication_response is not None:\n # handle response\n pass\n\n```\n\n### Check a code\n\nCheck that a code entered by a user is valid.\n\n\n```python\nimport ding\nfrom ding.models import components\n\ns = ding.Ding(\n api_key=\"YOUR_API_KEY\",\n)\n\n\nres = s.otp.check(request=components.CreateCheckRequest(\n customer_uuid='e0e7b0e9-739d-424b-922f-1c2cb48ab077',\n authentication_uuid='8f1196d5-806e-4b71-9b24-5f96ec052808',\n check_code='123456',\n))\n\nif res.create_check_response is not None:\n # handle response\n pass\n\n```\n\n### Perform a retry\n\nPerform a retry if a user has not received the code.\n\n\n```python\nimport ding\n\ns = ding.Ding(\n api_key=\"YOUR_API_KEY\",\n)\n\n\nres = s.otp.retry()\n\nif res.retry_authentication_response is not None:\n # handle response\n pass\n\n```\n<!-- End SDK Example Usage [usage] -->\n\n<!-- Start Available Resources and Operations [operations] -->\n## Available Resources and Operations\n\n<details open>\n<summary>Available methods</summary>\n\n\n### [lookup](https://github.com/ding-live/ding-python/blob/master/docs/sdks/lookup/README.md)\n\n* [lookup](https://github.com/ding-live/ding-python/blob/master/docs/sdks/lookup/README.md#lookup) - Perform a phone number lookup\n\n### [otp](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md)\n\n* [create_authentication](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md#create_authentication) - Send a code\n* [check](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md#check) - Check a code\n* [feedback](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md#feedback) - Send feedback\n* [retry](https://github.com/ding-live/ding-python/blob/master/docs/sdks/otp/README.md#retry) - Perform a retry\n\n</details>\n<!-- End Available Resources and Operations [operations] -->\n\n<!-- Start Error Handling [errors] -->\n## Error Handling\n\nHandling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.\n\nBy default, an API error will raise a errors.SDKError exception, which has the following properties:\n\n| Property | Type | Description |\n|-----------------|------------------|-----------------------|\n| `.status_code` | *int* | The HTTP status code |\n| `.message` | *str* | The error message |\n| `.raw_response` | *httpx.Response* | The raw HTTP response |\n| `.body` | *str* | The response content |\n\nWhen custom error responses are specified for an operation, the SDK may also raise their associated exception. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `create_authentication` method may raise the following exceptions:\n\n| Error Type | Status Code | Content Type |\n| -------------------- | -------------------- | -------------------- |\n| errors.ErrorResponse | 400 | application/json |\n| errors.SDKError | 4XX, 5XX | \\*/\\* |\n\n### Example\n\n```python\nimport ding\nfrom ding.models import components, errors\n\ns = ding.Ding(\n api_key=\"YOUR_API_KEY\",\n)\n\nres = None\ntry:\n res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(\n customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',\n phone_number='+1234567890',\n))\n\nexcept errors.ErrorResponse as e:\n # handle exception\n raise(e)\nexcept errors.SDKError as e:\n # handle exception\n raise(e)\n\nif res.create_authentication_response is not None:\n # handle response\n pass\n\n```\n<!-- End Error Handling [errors] -->\n\n<!-- Start Server Selection [server] -->\n## Server Selection\n\n### Select Server by Index\n\nYou can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:\n\n| # | Server | Variables |\n| - | ------ | --------- |\n| 0 | `https://api.ding.live/v1` | None |\n\n#### Example\n\n```python\nimport ding\nfrom ding.models import components\n\ns = ding.Ding(\n server_idx=0,\n api_key=\"YOUR_API_KEY\",\n)\n\n\nres = s.otp.create_authentication(request=components.CreateAuthenticationRequest(\n customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',\n phone_number='+1234567890',\n))\n\nif res.create_authentication_response is not None:\n # handle response\n pass\n\n```\n\n\n### Override Server URL Per-Client\n\nThe default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:\n```python\nimport ding\nfrom ding.models import components\n\ns = ding.Ding(\n server_url=\"https://api.ding.live/v1\",\n api_key=\"YOUR_API_KEY\",\n)\n\n\nres = s.otp.create_authentication(request=components.CreateAuthenticationRequest(\n customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',\n phone_number='+1234567890',\n))\n\nif res.create_authentication_response is not None:\n # handle response\n pass\n\n```\n<!-- End Server Selection [server] -->\n\n<!-- Start Custom HTTP Client [http-client] -->\n## Custom HTTP Client\n\nThe Python SDK makes API calls using the [requests](https://pypi.org/project/requests/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `requests.Session` object.\n\nFor example, you could specify a header for every request that this sdk makes as follows:\n```python\nimport ding\nimport requests\n\nhttp_client = requests.Session()\nhttp_client.headers.update({'x-custom-header': 'someValue'})\ns = ding.Ding(client=http_client)\n```\n<!-- End Custom HTTP Client [http-client] -->\n\n<!-- Start Authentication [security] -->\n## Authentication\n\n### Per-Client Security Schemes\n\nThis SDK supports the following security scheme globally:\n\n| Name | Type | Scheme |\n| --------- | --------- | --------- |\n| `api_key` | apiKey | API key |\n\nTo authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:\n```python\nimport ding\nfrom ding.models import components\n\ns = ding.Ding(\n api_key=\"YOUR_API_KEY\",\n)\n\n\nres = s.otp.create_authentication(request=components.CreateAuthenticationRequest(\n customer_uuid='c9f826e0-deca-41ec-871f-ecd6e8efeb46',\n phone_number='+1234567890',\n))\n\nif res.create_authentication_response is not None:\n # handle response\n pass\n\n```\n<!-- End Authentication [security] -->\n\n<!-- Placeholder for Future Speakeasy SDK Sections -->\n\n# Development\n\n## Contributions\n\nWhile we value open-source contributions to this SDK, this library is generated programmatically.\nFeel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Python Client SDK",
"version": "3.8.11",
"project_urls": {
"Homepage": "https://github.com/ding-live/ding-python.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2af25b6f33b19b392dbd0d247f83cfa28806b3901c2d5349bbeaa2b9acc7bcb6",
"md5": "7e38504550dea092821e873c232f89ae",
"sha256": "3a84ad687674ffedf3ab3d151bc5a98e85b642fcacafbccdc2c4c4301dabdcf5"
},
"downloads": -1,
"filename": "ding_api_client-3.8.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7e38504550dea092821e873c232f89ae",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 32656,
"upload_time": "2024-10-19T00:14:03",
"upload_time_iso_8601": "2024-10-19T00:14:03.842605Z",
"url": "https://files.pythonhosted.org/packages/2a/f2/5b6f33b19b392dbd0d247f83cfa28806b3901c2d5349bbeaa2b9acc7bcb6/ding_api_client-3.8.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "68a52d28b35817b830bad1ea022d8fdbf7fc0a939fc16977219dbdd615c1c6b5",
"md5": "b690d54637f22c7f099de15846e0121f",
"sha256": "d183fe866c50c1ac8188685d130de53205c7bf799467d52112959f3d25cceed9"
},
"downloads": -1,
"filename": "ding_api_client-3.8.11.tar.gz",
"has_sig": false,
"md5_digest": "b690d54637f22c7f099de15846e0121f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 23925,
"upload_time": "2024-10-19T00:14:05",
"upload_time_iso_8601": "2024-10-19T00:14:05.560710Z",
"url": "https://files.pythonhosted.org/packages/68/a5/2d28b35817b830bad1ea022d8fdbf7fc0a939fc16977219dbdd615c1c6b5/ding_api_client-3.8.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-19 00:14:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ding-live",
"github_project": "ding-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ding-api-client"
}