Package: ding-api-client
Ding Python SDKThe Ding Python library provides convenient access to the Ding API from applications written in the Python language.SDK Installationpipinstallding_api_clientSDK Example UsageSDK Example UsageSend a codeSend an OTP code to a user's phone number.importdingfromding.modelsimportcomponentss=ding.Ding(api_key="YOUR_API_KEY",)req=components.CreateAuthenticationRequest(customer_uuid='eae192ab-9e1e-4b21-b5b1-bfcb79a32fcc',phone_number='+1234567890',)res=s.otp.create_autentication(req)ifres.create_authentication_responseisnotNone:# handle responsepassCheck a codeCheck that a code entered by a user is valid.importdingfromding.modelsimportcomponentss=ding.Ding(api_key="YOUR_API_KEY",)req=components.CreateCheckRequest(customer_uuid='e0e7b0e9-739d-424b-922f-1c2cb48ab077',authentication_uuid='8f1196d5-806e-4b71-9b24-5f96ec052808',check_code='123456',)res=s.otp.check(req)ifres.create_check_responseisnotNone:# handle responsepassPerform a retryPerform a retry if a user has not received the code.importdingfromding.modelsimportcomponentss=ding.Ding(api_key="YOUR_API_KEY",)req=components.RetryAuthenticationRequest(customer_uuid='a74ee547-564d-487a-91df-37fb25413a91',authentication_uuid='3c8b3a46-881e-4cdd-93a6-f7f238bf020a',)res=s.otp.retry(req)ifres.retry_authentication_responseisnotNone:# handle responsepassAvailable Resources and Operationsotpcreate_autentication- Send a codecheck- Check a coderetry- Perform a retrylookuplookup- Perform a phone number lookupError HandlingHandling errors in this SDK should largely match your expectations.  All operations return a response object or raise an error.  If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.Error ObjectStatus CodeContent Typeerrors.ErrorResponse400application/jsonerrors.SDKError4x-5xx/Exampleimportdingfromding.modelsimportcomponents,errorss=ding.Ding(api_key="YOUR_API_KEY",)req=components.CreateAuthenticationRequest(customer_uuid='eae192ab-9e1e-4b21-b5b1-bfcb79a32fcc',phone_number='+1234567890',)res=Nonetry:res=s.otp.create_autentication(req)excepterrors.ErrorResponsease:# handle exceptionraise(e)excepterrors.SDKErrorase:# handle exceptionraise(e)ifres.create_authentication_responseisnotNone:# handle responsepassServer SelectionSelect Server by IndexYou can override the default server globally by passing a server index to theserver_idx: intoptional 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:#ServerVariables0https://api.ding.live/v1NoneExampleimportdingfromding.modelsimportcomponentss=ding.Ding(server_idx=0,api_key="YOUR_API_KEY",)req=components.CreateAuthenticationRequest(customer_uuid='eae192ab-9e1e-4b21-b5b1-bfcb79a32fcc',phone_number='+1234567890',)res=s.otp.create_autentication(req)ifres.create_authentication_responseisnotNone:# handle responsepassOverride Server URL Per-ClientThe default server can also be overridden globally by passing a URL to theserver_url: stroptional parameter when initializing the SDK client instance. For example:importdingfromding.modelsimportcomponentss=ding.Ding(server_url="https://api.ding.live/v1",api_key="YOUR_API_KEY",)req=components.CreateAuthenticationRequest(customer_uuid='eae192ab-9e1e-4b21-b5b1-bfcb79a32fcc',phone_number='+1234567890',)res=s.otp.create_autentication(req)ifres.create_authentication_responseisnotNone:# handle responsepassCustom HTTP ClientThe Python SDK makes API calls using therequestsHTTP 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 customrequests.Sessionobject.For example, you could specify a header for every request that this sdk makes as follows:importdingimportrequestshttp_client=requests.Session()http_client.headers.update({'x-custom-header':'someValue'})s=ding.Ding(client:http_client)AuthenticationPer-Client Security SchemesThis SDK supports the following security scheme globally:NameTypeSchemeapi_keyapiKeyAPI keyTo authenticate with the API theapi_keyparameter must be set when initializing the SDK client instance. For example:importdingfromding.modelsimportcomponentss=ding.Ding(api_key="YOUR_API_KEY",)req=components.CreateAuthenticationRequest(customer_uuid='eae192ab-9e1e-4b21-b5b1-bfcb79a32fcc',phone_number='+1234567890',)res=s.otp.create_autentication(req)ifres.create_authentication_responseisnotNone:# handle responsepassDevelopmentContributionsWhile 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!