Class: PersonaApi::PhoneNumberVerificationsResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/persona_api/resources/phone_number_verifications.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#delete_request, #get_request, #handle_response, #initialize, #patch_request, #post_request, #put_request

Constructor Details

This class inherits a constructor from PersonaApi::Resource

Instance Method Details

#confirm(ver_id:, **attributes) ⇒ Object



3
4
5
# File 'lib/persona_api/resources/phone_number_verifications.rb', line 3

def confirm(ver_id:, **attributes)
  PhoneNumberVerification.new post_request("verification/phone-numbers/#{ver_id}/confirm", body: attributes).body.dig("data")
end

#create(**attributes) ⇒ Object



7
8
9
10
11
# File 'lib/persona_api/resources/phone_number_verifications.rb', line 7

def create(**attributes)
  # Phone number attributes must include a 'verification-template-id', 'phone-number' and 'country-code' as well
  # as other fields as laid out in the documentation https://docs.withpersona.com/reference/create-a-phone-number-verification
  PhoneNumberVerification.new post_request("verification/phone-numbers", body: attributes).body.dig("data")
end

#retrieve(ver_id:) ⇒ Object



13
14
15
# File 'lib/persona_api/resources/phone_number_verifications.rb', line 13

def retrieve(ver_id:)
  PhoneNumberVerification.new get_request("verification/phone-numbers/#{ver_id}").body.dig("data")
end

#send_sms(ver_id:, **attributes) ⇒ Object



17
18
19
# File 'lib/persona_api/resources/phone_number_verifications.rb', line 17

def send_sms(ver_id:, **attributes)
  PhoneNumberVerification.new post_request("verification/phone-numbers/#{ver_id}/send-confirmation-code", body: attributes).body.dig("data")
end