Class: Soteria::SMS
- Inherits:
-
Object
- Object
- Soteria::SMS
- Defined in:
- lib/soteria/sms.rb
Instance Method Summary collapse
-
#check_otp(client, user_id, otp) ⇒ Hash
Check if the otp that a user entered is valid or not.
-
#create_check_otp_body(user_id, otp) ⇒ Hash
Creates the body for a check otp request.
-
#create_send_sms_body(user_id, phone_number) ⇒ Hash
Creates the body for a send SMS otp request.
-
#send_sms(client, user_id, phone_number) ⇒ Hash
Send a sms One Time Password to a user.
Instance Method Details
#check_otp(client, user_id, otp) ⇒ Hash
Check if the otp that a user entered is valid or not.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/soteria/sms.rb', line 65 def check_otp(client, user_id, otp) check_otp_response = client.call(:check_otp, message: create_check_otp_body(user_id, otp)) result_hash = check_otp_response.body[:check_otp_response] success = result_hash[:status] == '0000' { success: success, id: result_hash[:request_id], message: result_hash[:status_message] } end |
#create_check_otp_body(user_id, otp) ⇒ Hash
Creates the body for a check otp request.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/soteria/sms.rb', line 47 def create_check_otp_body(user_id, otp) { 'vip:requestId': Utilities.get_request_id('check_sms_otp'), 'vip:userId': user_id, 'vip:otpAuthData': { 'vip:otp': otp } } end |
#create_send_sms_body(user_id, phone_number) ⇒ Hash
Creates the body for a send SMS otp request.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/soteria/sms.rb', line 11 def create_send_sms_body(user_id, phone_number) { 'vip:requestId': Utilities.get_request_id('send_sms_otp'), 'vip:userId': user_id, 'vip:smsDeliveryInfo': { 'vip:phoneNumber': phone_number } } end |
#send_sms(client, user_id, phone_number) ⇒ Hash
Send a sms One Time Password to a user.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/soteria/sms.rb', line 29 def send_sms(client, user_id, phone_number) sms_res = client.call(:send_otp, message: create_send_sms_body(user_id, phone_number)) result_hash = sms_res.body[:send_otp_response] success = result_hash[:status] == '0000' { success: success, id: result_hash[:request_id], message: result_hash[:status_message] } end |