-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from plivo/SMS-6236
SMS-6236: Verify Service SDK
- Loading branch information
Showing
11 changed files
with
340 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
module Plivo | ||
module Resources | ||
include Plivo::Utils | ||
class Session < Base::Resource | ||
def initialize(client, options = nil) | ||
@_name = 'Session' | ||
@_identifier_string = 'session_uuid' | ||
super | ||
end | ||
def to_s | ||
{ | ||
api_id: @api_id, | ||
session_uuid: @session_uuid, | ||
app_uuid: @app_uuid, | ||
alias: @alias, | ||
recipient: @recipient, | ||
channel: @channel, | ||
status: @status, | ||
count: @count, | ||
requestor_ip: @requestor_ip, | ||
destination_country_iso2: @destination_country_iso2, | ||
destination_network: @destination_network, | ||
attempt_details: @attempt_details, | ||
charges: @charges, | ||
created_at: @created_at, | ||
updated_at: @updated_at | ||
}.to_s | ||
end | ||
end | ||
|
||
class SessionInterface < Base::ResourceInterface | ||
def initialize(client, resource_list_json = nil) | ||
@_name = 'Verify/Session' | ||
@_resource_type = Session | ||
@_identifier_string = 'session_uuid' | ||
super | ||
end | ||
|
||
# @param [String] session_uuid | ||
def get(session_uuid) | ||
perform_get(session_uuid) | ||
end | ||
|
||
def create(app_uuid = nil, recipient = nil,channel = nil,url = nil, method = nil) | ||
valid_param?(:app_uuid, app_uuid, [String, Symbol], false) | ||
valid_param?(:recipient, recipient, [Integer, String, Symbol], true) | ||
valid_param?(:channel, channel, [String, Symbol], false) | ||
valid_param?(:url, url, [String], false) | ||
valid_param?(:method, method, String, false, %w[POST GET]) | ||
|
||
params = { | ||
app_uuid: app_uuid, | ||
recipient: recipient, | ||
channel: channel, | ||
url: url, | ||
method: method | ||
} | ||
perform_create(params) | ||
end | ||
|
||
def list(options = nil) | ||
return perform_list if options.nil? | ||
valid_param?(:options, options, Hash, true) | ||
params = {} | ||
params_expected = %i[ | ||
subaccount status session_time__gt session_time__gte | ||
session_time__lt session_time__lte session_time country alias app_uuid recipient | ||
] | ||
|
||
params_expected.each do |param| | ||
if options.key?(param) && | ||
valid_param?(param, options[param], [String, Symbol], true) | ||
params[param] = options[param] | ||
end | ||
end | ||
|
||
%i[offset limit].each do |param| | ||
if options.key?(param) && | ||
valid_param?(param, options[param], [Integer, Integer], true) | ||
params[param] = options[param] | ||
end | ||
end | ||
|
||
if options.key?(:limit) && | ||
(options[:limit] > 20 || options[:limit] <= 0) | ||
raise_invalid_request('The maximum number of results that can be '\ | ||
"fetched is 20. limit can't be more than 20 or less than 1") | ||
end | ||
|
||
raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0 | ||
|
||
perform_list_without_object(params) | ||
end | ||
|
||
def validate(session_uuid = nil, otp = nil) | ||
valid_param?(:session_uuid, session_uuid, [String, Symbol], true) | ||
valid_param?(:otp, otp, [String], true) | ||
id = session_uuid | ||
params = { | ||
otp: otp | ||
} | ||
perform_action_with_identifier(id, 'POST', params) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Plivo | ||
VERSION = "4.52.0".freeze | ||
VERSION = "4.53.0".freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"api_id": "affc3af1-3ee3-4d8e-a577-317fabd4944e", | ||
"session_uuid": "118a0352-6818-4cc4-99b4-635647730091", | ||
"app_uuid": "bd772d6d-7882-4e77-b2b1-d84c7f73713a", | ||
"alias": "verify_app_210", | ||
"recipient": "1234567890", | ||
"channel": "sms", | ||
"status": "expired", | ||
"count": 1, | ||
"requestor_ip": "122.163.227.219", | ||
"destination_country_iso2": "IN", | ||
"destination_network": "Jio", | ||
"attempt_details": [ | ||
{ | ||
"channel": "sms", | ||
"attempt_uuid": "d67d0b98-4646-4c5e-b76a-7afe29435a02", | ||
"status": "failed", | ||
"time": "2023-08-21T14:32:40.436767+05:30" | ||
} | ||
], | ||
"charges": { | ||
"total_charge": "0.00000", | ||
"validation_charge": "0.0000", | ||
"attempt_charges": [ | ||
{ | ||
"attempt_uuid": "d67d0b98-4646-4c5e-b76a-7afe29435a02", | ||
"channel": "sms", | ||
"charge": "0.00000" | ||
} | ||
] | ||
}, | ||
"created_at": "2023-08-21T14:32:40.42576+05:30", | ||
"updated_at": "2023-08-21T14:32:40.436767+05:30" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"api_id": "0a80fbe1-e2d6-46fd-abf5-885fba1a22fd", | ||
"meta": { | ||
"limit": 1, | ||
"offset": 0, | ||
"next": "/v1/Account/MAODZKMDFJMJU3MTEYNG/Verify/Session/?limit=1&offset=1", | ||
"previous": null | ||
}, | ||
"sessions": [ | ||
{ | ||
"session_uuid": "2879cb3a-3742-4c41-adb6-2d0de6297652", | ||
"app_uuid": "f34e00c4-fdca-4675-bfad-6096553ef33f", | ||
"alias": "default_verify_app", | ||
"recipient": "1234567890", | ||
"channel": "sms", | ||
"status": "expired", | ||
"count": 1, | ||
"requestor_ip": "223.236.171.206", | ||
"destination_country_iso2": "IN", | ||
"destination_network": "Jio", | ||
"attempt_details": [ | ||
{ | ||
"channel": "sms", | ||
"attempt_uuid": "29e48f18-42e1-4ad2-b28d-ed93a4fbd3a1", | ||
"status": "failed", | ||
"time": "2023-08-25T13:00:45.281324+05:30" | ||
} | ||
], | ||
"charges": { | ||
"total_charge": "0.00000", | ||
"validation_charge": "0.0000", | ||
"attempt_charges": [ | ||
{ | ||
"attempt_uuid": "29e48f18-42e1-4ad2-b28d-ed93a4fbd3a1", | ||
"channel": "sms", | ||
"charge": "0.00000" | ||
} | ||
] | ||
}, | ||
"created_at": "2023-08-25T13:00:45.266046+05:30", | ||
"updated_at": "2023-08-25T13:00:45.281324+05:30" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"api_id": "bbeb49e9-8e71-47ac-9701-86455c702138", | ||
"message": "Session initiated", | ||
"session_uuid": "201c62fb-22bb-41da-90b6-e4be2a157299" | ||
} |
Oops, something went wrong.