Skip to content

Commit

Permalink
DEVX-8065/DEVX-7991: Verify2 SMS Updates (#303)
Browse files Browse the repository at this point in the history
* Updating properties on SMS channel for Verify v2
  • Loading branch information
superchilled authored Feb 2, 2024
1 parent 4636c34 commit 16e948f
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 7.20.0

* Updates Verify v2 API SMS channel to add new parameters. [#303](https://github.com/Vonage/vonage-ruby-sdk/pull/303)

# 7.19.0

* Adds Video API functionality. [#297](https://github.com/Vonage/vonage-ruby-sdk/pull/297)
Expand Down
16 changes: 15 additions & 1 deletion lib/vonage/verify2/channels/sms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Vonage
class Verify2::Channels::SMS
APP_HASH_LENGTH = 11

attr_reader :channel, :to, :app_hash
attr_reader :channel, :to, :from, :entity_id, :content_id, :app_hash

def initialize(to:, app_hash: nil)
self.channel = 'sms'
Expand All @@ -19,6 +19,20 @@ def to=(to)
@to = to
end

def from=(from)
@from = from
end

def entity_id=(entity_id)
raise ArgumentError, "Invalid 'entity_id' value #{entity_id}. Length must be between 1 and 20 characters." unless entity_id.length.between?(1, 20)
@entity_id = entity_id
end

def content_id=(content_id)
raise ArgumentError, "Invalid 'content_id' value #{content_id}. Length must be between 1 and 20 characters ." unless content_id.length.between?(1, 20)
@content_id = content_id
end

def app_hash=(app_hash)
raise ArgumentError, "Invalid 'app_hash' value #{app_hash}. Length must be #{APP_HASH_LENGTH}" unless app_hash.length == APP_HASH_LENGTH
@app_hash = app_hash
Expand Down
2 changes: 1 addition & 1 deletion lib/vonage/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# typed: strong

module Vonage
VERSION = '7.19.0'
VERSION = '7.20.0'
end
58 changes: 58 additions & 0 deletions test/vonage/verify2/channels/sms_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,64 @@ def test_to_setter_method_with_invalid_number
end
end

def test_from_getter_method
assert_nil sms_channel.from
end

def test_from_setter_method
channel = sms_channel
new_number = '447000000002'
channel.from = new_number

assert_equal new_number, channel.instance_variable_get(:@from)
end

def test_entity_id_getter_method
assert_nil sms_channel.entity_id
end

def test_entity_id_setter_method
channel = sms_channel
channel.entity_id = '1101407360000017170'

assert_equal '1101407360000017170', channel.instance_variable_get(:@entity_id)
end

def test_entity_id_setter_method_with_invalid_arg_too_short
assert_raises ArgumentError do
sms_channel.entity_id = ''
end
end

def test_entity_id_setter_method_with_invalid_arg_too_long
assert_raises ArgumentError do
sms_channel.entity_id = '110140736000001717072'
end
end

def test_content_id_getter_method
assert_nil sms_channel.content_id
end

def test_content_id_setter_method
channel = sms_channel
channel.content_id = '1101407360000017170'

assert_equal '1101407360000017170', channel.instance_variable_get(:@content_id)
end

def test_content_id_setter_method_with_invalid_arg_too_short
assert_raises ArgumentError do
sms_channel.content_id = ''
end
end

def test_content_id_setter_method_with_invalid_arg_too_long
assert_raises ArgumentError do
sms_channel.content_id = '110140736000001717072'
end
end

def test_app_hash_getter_method
assert_nil sms_channel.app_hash
end
Expand Down

0 comments on commit 16e948f

Please sign in to comment.