Class: Posthubify::OtpResource

Inherits:
Object
  • Object
show all
Defined in:
lib/posthubify/resources/telecom.rb

Overview

OTP generation + verification (Node sdk .otp).

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ OtpResource

Returns a new instance of OtpResource.



72
73
74
# File 'lib/posthubify/resources/telecom.rb', line 72

def initialize(http)
  @http = http
end

Instance Method Details

#send(input, idempotency_key: nil) ⇒ Object

Generate an OTP code + send it via SMS ({ ‘senderId’ => …, ‘to’ => …, ‘appName’ => …, ‘locale’ => … }); the code is not returned in the response.



77
78
79
# File 'lib/posthubify/resources/telecom.rb', line 77

def send(input, idempotency_key: nil)
  @http.data('POST', '/otp/send', body: input, idempotency_key: idempotency_key)
end

#verify(input) ⇒ Object

Verify the code the user entered ({ ‘senderId’ => …, ‘to’ => …, ‘code’ => … }).



82
83
84
# File 'lib/posthubify/resources/telecom.rb', line 82

def verify(input)
  @http.data('POST', '/otp/verify', body: input)
end