Module: Twizo::Verification

Defined in:
lib/twizo/modules/verification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#paramsObject (readonly)

Getter for params



21
22
23
# File 'lib/twizo/modules/verification.rb', line 21

def params
  @params
end

Instance Method Details

#sendObject

Send message to the server and return response

Returns:

  • (Object)


39
40
41
42
43
44
45
46
47
# File 'lib/twizo/modules/verification.rb', line 39

def send
  post_params = @params.to_json

  response = send_api_call(Entity::ACTION_CREATE, location, post_params)

  raise response if response.kind_of?(TwizoError)

  response_to_array(response)
end

#set(recipient) ⇒ Object

Parameters:

  • recipient (String)


26
27
28
29
30
31
32
# File 'lib/twizo/modules/verification.rb', line 26

def set(recipient)
  @params = VerificationParams.new
  @params.recipient = recipient

  # set default type
  @params.type ||= 'sms'
end

#verify(message_id, token) ⇒ Object

Parameters:

  • token (String)

Returns:

  • (Object)


54
55
56
57
58
59
60
# File 'lib/twizo/modules/verification.rb', line 54

def verify(message_id, token)
  response = send_api_call(Entity::ACTION_RETRIEVE, "#{location}/#{message_id}?token=#{token}")

  raise response if response.kind_of?(TwizoError)

  response_to_array(response)
end