Skip to content

Commit

Permalink
resolve the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshkumar-plivo committed Sep 11, 2023
1 parent 2d22b41 commit 473f918
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 63 deletions.
7 changes: 0 additions & 7 deletions lib/plivo/base/resource_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ def perform_create(params, use_multipart_conn=false)
)
end

def perform_create_with_id(id, params, use_multipart_conn=false)
Response.new(
@_client.send_request(@_resource_uri + id + '/', 'POST', params, 10, use_multipart_conn, is_voice_request: @_is_voice_request),
@_identifier_string
)
end

def perform_delete(identifier, params = nil)
valid_param?(:identifier, identifier, [String, Symbol], true)
Response.new(
Expand Down
70 changes: 20 additions & 50 deletions lib/plivo/resources/verify_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,20 @@ def get(session_uuid)
end

def create(app_uuid = nil, recipient = nil,channel = nil,url = nil, method = nil)
value = app_uuid
if(value.is_a?(Hash))
valid_param?(:app_uuid, value[:app_uuid], [String, Symbol], false)
valid_param?(:recipient, value[:recipient], [Integer, String, Symbol], true)
valid_param?(:channel, value[:channel], [String, Symbol], false)
valid_param?(:url, value[:url], [String], false)
valid_param?(:method, value[:method], String, false, %w[POST GET])
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: value[:app_uuid],
recipient: value[:recipient],
channel: value[:channel],
url: value[:url],
method: value[:method]
}

else
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
}

end
perform_create(params)
params = {
app_uuid: app_uuid,
recipient: recipient,
channel: channel,
url: url,
method: method
}
perform_create(params)
end

def list(options = nil)
Expand Down Expand Up @@ -112,24 +93,13 @@ def list(options = nil)
end

def validate(session_uuid = nil, otp = nil)
value = session_uuid
id = ""
if(value.is_a?(Hash))
valid_param?(:session_uuid, value[:session_uuid], [String, Symbol], true)
valid_param?(:otp, value[:otp], [String], true)
id = value[:session_uuid]
params = {
otp: value[:otp]
}
else
valid_param?(:session_uuid, session_uuid, [String, Symbol], true)
valid_param?(:otp, otp, [String], true)
id = session_uuid
params = {
otp: otp
}
end
perform_create_with_id(id,params)
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
Expand Down
2 changes: 1 addition & 1 deletion spec/mocks/sessionGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"session_uuid": "118a0352-6818-4cc4-99b4-635647730091",
"app_uuid": "bd772d6d-7882-4e77-b2b1-d84c7f73713a",
"alias": "verify_app_210",
"recipient": "918707046409",
"recipient": "1234567890",
"channel": "sms",
"status": "expired",
"count": 1,
Expand Down
2 changes: 1 addition & 1 deletion spec/mocks/sessionListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"session_uuid": "2879cb3a-3742-4c41-adb6-2d0de6297652",
"app_uuid": "f34e00c4-fdca-4675-bfad-6096553ef33f",
"alias": "default_verify_app",
"recipient": "918707046409",
"recipient": "1234567890",
"channel": "sms",
"status": "expired",
"count": 1,
Expand Down
8 changes: 4 additions & 4 deletions spec/resource_verify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def to_json_list(list_object)
contents = File.read(Dir.pwd + '/spec/mocks/sessionSendResponse.json')
mock(201, JSON.parse(contents))
expect(JSON.parse(to_json_create(@api.verify_session
.create(
recipient: '1234567890'
.create(nil,
'1234567890',nil,nil,nil
))))
.to eql(JSON.parse(contents))
compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Verify/Session/',
Expand All @@ -121,8 +121,8 @@ def to_json_list(list_object)
mock(201, JSON.parse(contents))
expect(JSON.parse(to_json_create(@api.verify_session
.validate(
session_uuid: '12345-6789-0000',
otp: '123456'
'12345-6789-0000',
'123456'
))))
.to eql(JSON.parse(contents))
compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Verify/Session/12345-6789-0000/',
Expand Down

0 comments on commit 473f918

Please sign in to comment.