inttegro.resources.otp

Generated public typing surface. Do not edit by hand.

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

Otp(http: inttegro.http_client.HttpClient)
20    def __init__(self, http: HttpClient):
21        """Initialize OTP resource with HTTP client."""
22        self.http = http

Initialize OTP resource with HTTP client.

http
def initiate( self, payload: inttegro.otp.InitiateRequest) -> inttegro.otp.Transaction:
24    def initiate(self, payload: dict):
25        """
26        Initiate an OTP verification flow.
27
28        Generates and sends a one-time password to the specified recipient. The customer
29        receives the OTP via SMS and must submit it via verify() to complete verification.
30
31        Args:
32            payload: Initiation parameters including recipient, sender, and service_name
33
34        Returns:
35            domain object containing the OTP transaction with id and expiry information
36
37        Example:
38            ```python
39            result = client.otp.initiate({
40                "recipient": "+233241234567",
41                "sender": "Acme",
42                "service_name": "Acme Bank",
43                "request_meta": {"idempotency_key": "otp_login_1700000000"}
44            })
45            txn_id = result.id
46            ```
47
48        See Also:
49            - verify(): Submit OTP code to complete verification
50        """
51        return 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
def verify( self, payload: inttegro.otp.VerifyRequest) -> inttegro.otp.Verification:
53    def verify(self, payload: dict):
54        """
55        Verify an OTP code submitted by the user.
56
57        Validates the OTP code entered by the customer against the active OTP transaction.
58        If the code is correct and not expired, verification succeeds.
59
60        Args:
61            payload: Verification parameters including transaction_id, recipient, and token
62
63        Returns:
64            domain object containing the OTP session with updated status and verified flag
65
66        Example:
67            ```python
68            result = client.otp.verify({
69                "transaction_id": "ot_abc123",
70                "recipient": "+233241234567",
71                "token": "123456"
72            })
73            if result.status == "verified":
74                print("OTP verified!")
75            ```
76
77        See Also:
78            - initiate(): Start OTP verification flow
79        """
80        return 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
def lookup( self, payload: inttegro.otp.LookupRequest) -> inttegro.otp.Transaction:
 82    def lookup(self, payload: dict):
 83        """
 84        Retrieve details of an OTP transaction.
 85
 86        Fetches information about an OTP verification transaction including its status
 87        and expiration. Use debug_mode=1 to include verification attempts.
 88
 89        Args:
 90            payload: Lookup parameters including transaction_id
 91
 92        Returns:
 93            domain object containing the OTP session details
 94
 95        Example:
 96            ```python
 97            result = client.otp.lookup({"transaction_id": "ot_abc123"})
 98            print(f"Status: {result.status}")
 99            ```
100
101        See Also:
102            - initiate(): Create OTP sessions
103        """
104        return 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
def cancel( self, payload: inttegro.otp.LookupRequest) -> inttegro.otp.Transaction:
106    def cancel(self, payload: dict):
107        """
108        Cancel an active OTP transaction.
109
110        Invalidates an OTP transaction before it expires naturally. Use this when the user
111        abandons the verification flow or requests a new OTP.
112
113        Args:
114            payload: Cancellation parameters including transaction_id and reason
115
116        Returns:
117            domain object containing the cancelled OTP session
118
119        Example:
120            ```python
121            result = client.otp.cancel({
122                "transaction_id": "ot_abc123",
123                "reason": "user_requested_new_code"
124            })
125            ```
126
127        See Also:
128            - initiate(): Create new OTP after cancellation
129        """
130        return 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