diff --git a/CHANGES.md b/CHANGES.md index 6fd5d583..67365e17 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/lib/vonage/verify2/channels/sms.rb b/lib/vonage/verify2/channels/sms.rb index e27801f2..f7cb1a79 100644 --- a/lib/vonage/verify2/channels/sms.rb +++ b/lib/vonage/verify2/channels/sms.rb @@ -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' @@ -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 diff --git a/lib/vonage/version.rb b/lib/vonage/version.rb index 40253a63..d6ee0b97 100644 --- a/lib/vonage/version.rb +++ b/lib/vonage/version.rb @@ -1,5 +1,5 @@ # typed: strong module Vonage - VERSION = '7.19.0' + VERSION = '7.20.0' end diff --git a/test/vonage/verify2/channels/sms_test.rb b/test/vonage/verify2/channels/sms_test.rb index 7f0168d6..1f069803 100644 --- a/test/vonage/verify2/channels/sms_test.rb +++ b/test/vonage/verify2/channels/sms_test.rb @@ -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