inttegro.async_resources.otp
Generated public typing surface. Do not edit by hand.
1# Generated by scripts/generate_async_resources.py; do not edit by hand. 2"""OTP resource for one-time password verification.""" 3from __future__ import annotations 4from ..async_http_client import AsyncHttpClient 5 6class AsyncOtp: 7 """ 8 OTP resource for generating and verifying one-time passwords. 9 10 The OTP resource provides standalone one-time password functionality for verifying 11 phone numbers, confirming sensitive actions, or adding two-factor authentication. 12 This is separate from payment and payment method verification OTPs. 13 14 See https://studio.inttegro.com/api/otp for detailed documentation. 15 """ 16 17 def __init__(self, http: AsyncHttpClient): 18 """Initialize OTP resource with HTTP client.""" 19 self.http = http 20 21 async def initiate(self, payload: dict): 22 """ 23 Initiate an OTP verification flow. 24 25 Generates and sends a one-time password to the specified recipient. The customer 26 receives the OTP via SMS and must submit it via verify() to complete verification. 27 28 Args: 29 payload: Initiation parameters including recipient, sender, and service_name 30 31 Returns: 32 domain object containing the OTP transaction with id and expiry information 33 34 Example: 35 ```python 36 result = client.otp.initiate({ 37 "recipient": "+233241234567", 38 "sender": "Acme", 39 "service_name": "Acme Bank", 40 "request_meta": {"idempotency_key": "otp_login_1700000000"} 41 }) 42 txn_id = result.id 43 ``` 44 45 See Also: 46 - verify(): Submit OTP code to complete verification 47 """ 48 return await self.http.post('/otp/initiate', payload) 49 50 async def verify(self, payload: dict): 51 """ 52 Verify an OTP code submitted by the user. 53 54 Validates the OTP code entered by the customer against the active OTP transaction. 55 If the code is correct and not expired, verification succeeds. 56 57 Args: 58 payload: Verification parameters including transaction_id, recipient, and token 59 60 Returns: 61 domain object containing the OTP session with updated status and verified flag 62 63 Example: 64 ```python 65 result = client.otp.verify({ 66 "transaction_id": "ot_abc123", 67 "recipient": "+233241234567", 68 "token": "123456" 69 }) 70 if result.status == "verified": 71 print("OTP verified!") 72 ``` 73 74 See Also: 75 - initiate(): Start OTP verification flow 76 """ 77 return await self.http.post('/otp/verify', payload) 78 79 async def lookup(self, payload: dict): 80 """ 81 Retrieve details of an OTP transaction. 82 83 Fetches information about an OTP verification transaction including its status 84 and expiration. Use debug_mode=1 to include verification attempts. 85 86 Args: 87 payload: Lookup parameters including transaction_id 88 89 Returns: 90 domain object containing the OTP session details 91 92 Example: 93 ```python 94 result = client.otp.lookup({"transaction_id": "ot_abc123"}) 95 print(f"Status: {result.status}") 96 ``` 97 98 See Also: 99 - initiate(): Create OTP sessions 100 """ 101 return await self.http.post('/otp/lookup', payload) 102 103 async def cancel(self, payload: dict): 104 """ 105 Cancel an active OTP transaction. 106 107 Invalidates an OTP transaction before it expires naturally. Use this when the user 108 abandons the verification flow or requests a new OTP. 109 110 Args: 111 payload: Cancellation parameters including transaction_id and reason 112 113 Returns: 114 domain object containing the cancelled OTP session 115 116 Example: 117 ```python 118 result = client.otp.cancel({ 119 "transaction_id": "ot_abc123", 120 "reason": "user_requested_new_code" 121 }) 122 ``` 123 124 See Also: 125 - initiate(): Create new OTP after cancellation 126 """ 127 return await self.http.post('/otp/cancel', payload)
7class AsyncOtp: 8 """ 9 OTP resource for generating and verifying one-time passwords. 10 11 The OTP resource provides standalone one-time password functionality for verifying 12 phone numbers, confirming sensitive actions, or adding two-factor authentication. 13 This is separate from payment and payment method verification OTPs. 14 15 See https://studio.inttegro.com/api/otp for detailed documentation. 16 """ 17 18 def __init__(self, http: AsyncHttpClient): 19 """Initialize OTP resource with HTTP client.""" 20 self.http = http 21 22 async def initiate(self, payload: dict): 23 """ 24 Initiate an OTP verification flow. 25 26 Generates and sends a one-time password to the specified recipient. The customer 27 receives the OTP via SMS and must submit it via verify() to complete verification. 28 29 Args: 30 payload: Initiation parameters including recipient, sender, and service_name 31 32 Returns: 33 domain object containing the OTP transaction with id and expiry information 34 35 Example: 36 ```python 37 result = client.otp.initiate({ 38 "recipient": "+233241234567", 39 "sender": "Acme", 40 "service_name": "Acme Bank", 41 "request_meta": {"idempotency_key": "otp_login_1700000000"} 42 }) 43 txn_id = result.id 44 ``` 45 46 See Also: 47 - verify(): Submit OTP code to complete verification 48 """ 49 return await self.http.post('/otp/initiate', payload) 50 51 async def verify(self, payload: dict): 52 """ 53 Verify an OTP code submitted by the user. 54 55 Validates the OTP code entered by the customer against the active OTP transaction. 56 If the code is correct and not expired, verification succeeds. 57 58 Args: 59 payload: Verification parameters including transaction_id, recipient, and token 60 61 Returns: 62 domain object containing the OTP session with updated status and verified flag 63 64 Example: 65 ```python 66 result = client.otp.verify({ 67 "transaction_id": "ot_abc123", 68 "recipient": "+233241234567", 69 "token": "123456" 70 }) 71 if result.status == "verified": 72 print("OTP verified!") 73 ``` 74 75 See Also: 76 - initiate(): Start OTP verification flow 77 """ 78 return await self.http.post('/otp/verify', payload) 79 80 async def lookup(self, payload: dict): 81 """ 82 Retrieve details of an OTP transaction. 83 84 Fetches information about an OTP verification transaction including its status 85 and expiration. Use debug_mode=1 to include verification attempts. 86 87 Args: 88 payload: Lookup parameters including transaction_id 89 90 Returns: 91 domain object containing the OTP session details 92 93 Example: 94 ```python 95 result = client.otp.lookup({"transaction_id": "ot_abc123"}) 96 print(f"Status: {result.status}") 97 ``` 98 99 See Also: 100 - initiate(): Create OTP sessions 101 """ 102 return await self.http.post('/otp/lookup', payload) 103 104 async def cancel(self, payload: dict): 105 """ 106 Cancel an active OTP transaction. 107 108 Invalidates an OTP transaction before it expires naturally. Use this when the user 109 abandons the verification flow or requests a new OTP. 110 111 Args: 112 payload: Cancellation parameters including transaction_id and reason 113 114 Returns: 115 domain object containing the cancelled OTP session 116 117 Example: 118 ```python 119 result = client.otp.cancel({ 120 "transaction_id": "ot_abc123", 121 "reason": "user_requested_new_code" 122 }) 123 ``` 124 125 See Also: 126 - initiate(): Create new OTP after cancellation 127 """ 128 return await self.http.post('/otp/cancel', payload)
OTP resource for generating and verifying one-time passwords.
The OTP resource provides standalone one-time password functionality for verifying phone numbers, confirming sensitive actions, or adding two-factor authentication. This is separate from payment and payment method verification OTPs.
See https://studio.inttegro.com/api/otp for detailed documentation.
18 def __init__(self, http: AsyncHttpClient): 19 """Initialize OTP resource with HTTP client.""" 20 self.http = http
Initialize OTP resource with HTTP client.
22 async def initiate(self, payload: dict): 23 """ 24 Initiate an OTP verification flow. 25 26 Generates and sends a one-time password to the specified recipient. The customer 27 receives the OTP via SMS and must submit it via verify() to complete verification. 28 29 Args: 30 payload: Initiation parameters including recipient, sender, and service_name 31 32 Returns: 33 domain object containing the OTP transaction with id and expiry information 34 35 Example: 36 ```python 37 result = client.otp.initiate({ 38 "recipient": "+233241234567", 39 "sender": "Acme", 40 "service_name": "Acme Bank", 41 "request_meta": {"idempotency_key": "otp_login_1700000000"} 42 }) 43 txn_id = result.id 44 ``` 45 46 See Also: 47 - verify(): Submit OTP code to complete verification 48 """ 49 return await self.http.post('/otp/initiate', payload)
Initiate an OTP verification flow.
Generates and sends a one-time password to the specified recipient. The customer receives the OTP via SMS and must submit it via verify() to complete verification.
Arguments:
- payload: Initiation parameters including recipient, sender, and service_name
Returns:
domain object containing the OTP transaction with id and expiry information
Example:
result = client.otp.initiate({ "recipient": "+233241234567", "sender": "Acme", "service_name": "Acme Bank", "request_meta": {"idempotency_key": "otp_login_1700000000"} }) txn_id = result.id
See Also:
- verify(): Submit OTP code to complete verification
51 async def verify(self, payload: dict): 52 """ 53 Verify an OTP code submitted by the user. 54 55 Validates the OTP code entered by the customer against the active OTP transaction. 56 If the code is correct and not expired, verification succeeds. 57 58 Args: 59 payload: Verification parameters including transaction_id, recipient, and token 60 61 Returns: 62 domain object containing the OTP session with updated status and verified flag 63 64 Example: 65 ```python 66 result = client.otp.verify({ 67 "transaction_id": "ot_abc123", 68 "recipient": "+233241234567", 69 "token": "123456" 70 }) 71 if result.status == "verified": 72 print("OTP verified!") 73 ``` 74 75 See Also: 76 - initiate(): Start OTP verification flow 77 """ 78 return await self.http.post('/otp/verify', payload)
Verify an OTP code submitted by the user.
Validates the OTP code entered by the customer against the active OTP transaction. If the code is correct and not expired, verification succeeds.
Arguments:
- payload: Verification parameters including transaction_id, recipient, and token
Returns:
domain object containing the OTP session with updated status and verified flag
Example:
result = client.otp.verify({ "transaction_id": "ot_abc123", "recipient": "+233241234567", "token": "123456" }) if result.status == "verified": print("OTP verified!")
See Also:
- initiate(): Start OTP verification flow
80 async def lookup(self, payload: dict): 81 """ 82 Retrieve details of an OTP transaction. 83 84 Fetches information about an OTP verification transaction including its status 85 and expiration. Use debug_mode=1 to include verification attempts. 86 87 Args: 88 payload: Lookup parameters including transaction_id 89 90 Returns: 91 domain object containing the OTP session details 92 93 Example: 94 ```python 95 result = client.otp.lookup({"transaction_id": "ot_abc123"}) 96 print(f"Status: {result.status}") 97 ``` 98 99 See Also: 100 - initiate(): Create OTP sessions 101 """ 102 return await self.http.post('/otp/lookup', payload)
Retrieve details of an OTP transaction.
Fetches information about an OTP verification transaction including its status and expiration. Use debug_mode=1 to include verification attempts.
Arguments:
- payload: Lookup parameters including transaction_id
Returns:
domain object containing the OTP session details
Example:
result = client.otp.lookup({"transaction_id": "ot_abc123"}) print(f"Status: {result.status}")
See Also:
- initiate(): Create OTP sessions
104 async def cancel(self, payload: dict): 105 """ 106 Cancel an active OTP transaction. 107 108 Invalidates an OTP transaction before it expires naturally. Use this when the user 109 abandons the verification flow or requests a new OTP. 110 111 Args: 112 payload: Cancellation parameters including transaction_id and reason 113 114 Returns: 115 domain object containing the cancelled OTP session 116 117 Example: 118 ```python 119 result = client.otp.cancel({ 120 "transaction_id": "ot_abc123", 121 "reason": "user_requested_new_code" 122 }) 123 ``` 124 125 See Also: 126 - initiate(): Create new OTP after cancellation 127 """ 128 return await self.http.post('/otp/cancel', payload)
Cancel an active OTP transaction.
Invalidates an OTP transaction before it expires naturally. Use this when the user abandons the verification flow or requests a new OTP.
Arguments:
- payload: Cancellation parameters including transaction_id and reason
Returns:
domain object containing the cancelled OTP session
Example:
result = client.otp.cancel({ "transaction_id": "ot_abc123", "reason": "user_requested_new_code" })
See Also:
- initiate(): Create new OTP after cancellation