From 4958c37d14723e5b8d25e85537a13b72286065de Mon Sep 17 00:00:00 2001 From: ignacio-chiazzo Date: Thu, 14 Sep 2023 20:30:11 -0400 Subject: [PATCH] rename error with errors --- lib/whatsapp_sdk/api/messages.rb | 23 ++++++++++++------ .../resource/{error.rb => errors.rb} | 2 +- .../resource/interactive_action.rb | 10 ++++---- .../interactive_action_reply_button.rb | 4 ++-- .../resource/interactive_action_section.rb | 4 ++-- .../interactive_action_section_row.rb | 6 ++--- lib/whatsapp_sdk/resource/interactive_body.rb | 2 +- .../resource/interactive_footer.rb | 2 +- .../resource/interactive_header.rb | 2 +- lib/whatsapp_sdk/resource/parameter_object.rb | 4 ++-- test/whatsapp/api/messages_test.rb | 12 +++++----- .../interactive_action_section_row_test.rb | 6 ++--- .../interactive_action_section_test.rb | 2 +- .../resource/interactive_action_test.rb | 10 ++++---- test/whatsapp/resource/interactive_test.rb | 24 +++++++++---------- .../resource/parameter_object_test.rb | 4 ++-- 16 files changed, 63 insertions(+), 54 deletions(-) rename lib/whatsapp_sdk/resource/{error.rb => errors.rb} (98%) diff --git a/lib/whatsapp_sdk/api/messages.rb b/lib/whatsapp_sdk/api/messages.rb index bc8c5db..aca7e49 100644 --- a/lib/whatsapp_sdk/api/messages.rb +++ b/lib/whatsapp_sdk/api/messages.rb @@ -111,7 +111,7 @@ def send_location( def send_image( sender_id:, recipient_number:, image_id: nil, link: nil, caption: "", message_id: nil ) - raise WhatsappSdk::Resource::Error::MissingArgumentError, "image_id or link is required" if !image_id && !link + raise WhatsappSdk::Resource::Errors::MissingArgumentError, "image_id or link is required" if !image_id && !link params = { messaging_product: "whatsapp", @@ -153,7 +153,7 @@ def send_image( ).returns(WhatsappSdk::Api::Response) end def send_audio(sender_id:, recipient_number:, audio_id: nil, link: nil, message_id: nil) - raise WhatsappSdk::Resource::Error::MissingArgumentError, "audio_id or link is required" if !audio_id && !link + raise WhatsappSdk::Resource::Errors::MissingArgumentError, "audio_id or link is required" if !audio_id && !link params = { messaging_product: "whatsapp", @@ -195,7 +195,7 @@ def send_audio(sender_id:, recipient_number:, audio_id: nil, link: nil, message_ def send_video( sender_id:, recipient_number:, video_id: nil, link: nil, caption: "", message_id: nil ) - raise WhatsappSdk::Resource::Error::MissingArgumentError, "video_id or link is required" if !video_id && !link + raise WhatsappSdk::Resource::Errors::MissingArgumentError, "video_id or link is required" if !video_id && !link params = { messaging_product: "whatsapp", @@ -241,7 +241,10 @@ def send_video( def send_document( sender_id:, recipient_number:, document_id: nil, link: nil, caption: "", message_id: nil ) - raise WhatsappSdk::Resource::Error::MissingArgumentError, "document or link is required" if !document_id && !link + if !document_id && !link + raise WhatsappSdk::Resource::Errors::MissingArgumentError, + "document or link is required" + end params = { messaging_product: "whatsapp", @@ -283,7 +286,7 @@ def send_document( ).returns(WhatsappSdk::Api::Response) end def send_sticker(sender_id:, recipient_number:, sticker_id: nil, link: nil, message_id: nil) - raise WhatsappSdk::Resource::Error::MissingArgumentError, "sticker or link is required" if !sticker_id && !link + raise WhatsappSdk::Resource::Errors::MissingArgumentError, "sticker or link is required" if !sticker_id && !link params = { messaging_product: "whatsapp", @@ -371,7 +374,10 @@ def send_contacts( def send_interactive_message( sender_id:, recipient_number:, interactive: nil, interactive_json: nil, message_id: nil ) - raise WhatsappSdk::Resource::Error::MissingArgumentError, "interactive or interactive_json is required" if !interactive && !interactive_json + if !interactive && !interactive_json + raise WhatsappSdk::Resource::Errors::MissingArgumentError, + "interactive or interactive_json is required" + end params = { messaging_product: "whatsapp", @@ -446,7 +452,10 @@ def read_message(sender_id:, message_id:) def send_template( sender_id:, recipient_number:, name:, language:, components: nil, components_json: nil ) - raise WhatsappSdk::Resource::Error::MissingArgumentError, "components or components_json is required" if !components && !components_json + if !components && !components_json + raise WhatsappSdk::Resource::Errors::MissingArgumentError, + "components or components_json is required" + end params = { messaging_product: "whatsapp", diff --git a/lib/whatsapp_sdk/resource/error.rb b/lib/whatsapp_sdk/resource/errors.rb similarity index 98% rename from lib/whatsapp_sdk/resource/error.rb rename to lib/whatsapp_sdk/resource/errors.rb index aea3ae4..9c5f50c 100644 --- a/lib/whatsapp_sdk/resource/error.rb +++ b/lib/whatsapp_sdk/resource/errors.rb @@ -3,7 +3,7 @@ module WhatsappSdk module Resource - module Error + module Errors class MissingArgumentError < StandardError extend T::Sig diff --git a/lib/whatsapp_sdk/resource/interactive_action.rb b/lib/whatsapp_sdk/resource/interactive_action.rb index 3f1b4d7..638a4f3 100644 --- a/lib/whatsapp_sdk/resource/interactive_action.rb +++ b/lib/whatsapp_sdk/resource/interactive_action.rb @@ -103,18 +103,18 @@ def validate_list_message button_length = button.length sections_count = sections.length unless button_length.positive? - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionButton, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionButton, "Invalid button in action. Button label is required." end unless button_length <= LIST_BUTTON_TITLE_MAXIMUM - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionButton, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionButton, "Invalid length #{button_length} for button. Maximum length: " \ "#{LIST_BUTTON_TITLE_MAXIMUM} characters." end unless (LIST_SECTIONS_MINIMUM..LIST_SECTIONS_MAXIMUM).cover?(sections_count) - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionSection, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionSection, "Invalid length #{sections_count} for sections in action. It should be between " \ "#{LIST_SECTIONS_MINIMUM} and #{LIST_SECTIONS_MAXIMUM}." end @@ -125,7 +125,7 @@ def validate_list_message def validate_reply_button buttons_count = buttons.length unless (REPLY_BUTTONS_MINIMUM..REPLY_BUTTONS_MAXIMUM).cover?(buttons_count) - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton, "Invalid length #{buttons_count} for buttons in action. It should be between " \ "#{REPLY_BUTTONS_MINIMUM} and #{REPLY_BUTTONS_MAXIMUM}." end @@ -133,7 +133,7 @@ def validate_reply_button button_ids = buttons.map(&:id) return if button_ids.length.eql?(button_ids.uniq.length) - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton, "Duplicate ids #{button_ids} for buttons in action. They should be unique." end end diff --git a/lib/whatsapp_sdk/resource/interactive_action_reply_button.rb b/lib/whatsapp_sdk/resource/interactive_action_reply_button.rb index b1bcec7..17b4e7b 100644 --- a/lib/whatsapp_sdk/resource/interactive_action_reply_button.rb +++ b/lib/whatsapp_sdk/resource/interactive_action_reply_button.rb @@ -67,7 +67,7 @@ def validate_title title_length = title.length return if title_length <= ACTION_BUTTON_TITLE_MAXIMUM - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton, "Invalid length #{title_length} for title in button. " \ "Maximum length: #{ACTION_BUTTON_TITLE_MAXIMUM} characters." end @@ -80,7 +80,7 @@ def validate_id id_length = id.length return if id_length <= ACTION_BUTTON_ID_MAXIMUM - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton, "Invalid length #{id_length} for id in button. Maximum length: #{ACTION_BUTTON_ID_MAXIMUM} characters." end end diff --git a/lib/whatsapp_sdk/resource/interactive_action_section.rb b/lib/whatsapp_sdk/resource/interactive_action_section.rb index eeb5c2b..775d8a7 100644 --- a/lib/whatsapp_sdk/resource/interactive_action_section.rb +++ b/lib/whatsapp_sdk/resource/interactive_action_section.rb @@ -53,7 +53,7 @@ def validate_title title_length = title.length return if title_length <= ACTION_SECTION_TITLE_MAXIMUM - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionSection, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionSection, "Invalid length #{title_length} for title in section. Maximum length: " \ "#{ACTION_SECTION_TITLE_MAXIMUM} characters." end @@ -63,7 +63,7 @@ def validate_rows rows_length = rows.length return if rows_length <= ACTION_SECTION_ROWS_MAXIMUM - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionSection, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionSection, "Invalid number of rows #{rows_length} in section. Maximum count: " \ "#{ACTION_SECTION_ROWS_MAXIMUM}." end diff --git a/lib/whatsapp_sdk/resource/interactive_action_section_row.rb b/lib/whatsapp_sdk/resource/interactive_action_section_row.rb index 823e99c..939bd32 100644 --- a/lib/whatsapp_sdk/resource/interactive_action_section_row.rb +++ b/lib/whatsapp_sdk/resource/interactive_action_section_row.rb @@ -61,7 +61,7 @@ def validate_title title_length = title.length return if title_length <= ACTION_SECTION_TITLE_MAXIMUM - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionSectionRow, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionSectionRow, "Invalid length #{title_length} for title in section row. "\ "Maximum length: #{ACTION_SECTION_TITLE_MAXIMUM} characters." end @@ -74,7 +74,7 @@ def validate_id id_length = id.length return if id_length <= ACTION_SECTION_ID_MAXIMUM - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionSectionRow, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionSectionRow, "Invalid length #{id_length} for id in section row. Maximum length: "\ "#{ACTION_SECTION_ID_MAXIMUM} characters." end @@ -84,7 +84,7 @@ def validate_description description_length = description.length return if description_length <= ACTION_SECTION_DESCRIPTION_MAXIMUM - raise WhatsappSdk::Resource::Error::InvalidInteractiveActionSectionRow, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveActionSectionRow, "Invalid length #{description_length} for description in section " \ "row. Maximum length: #{ACTION_SECTION_DESCRIPTION_MAXIMUM} characters." end diff --git a/lib/whatsapp_sdk/resource/interactive_body.rb b/lib/whatsapp_sdk/resource/interactive_body.rb index 5096ed0..c736f36 100644 --- a/lib/whatsapp_sdk/resource/interactive_body.rb +++ b/lib/whatsapp_sdk/resource/interactive_body.rb @@ -40,7 +40,7 @@ def validate_text text_length = text.length return if text_length <= MAXIMUM_LENGTH - raise WhatsappSdk::Resource::Error::InvalidInteractiveBody, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveBody, "Invalid length #{text_length} for text in body. Maximum length: #{MAXIMUM_LENGTH} characters." end end diff --git a/lib/whatsapp_sdk/resource/interactive_footer.rb b/lib/whatsapp_sdk/resource/interactive_footer.rb index c53ee1a..6b9b09d 100644 --- a/lib/whatsapp_sdk/resource/interactive_footer.rb +++ b/lib/whatsapp_sdk/resource/interactive_footer.rb @@ -40,7 +40,7 @@ def validate_text text_length = text.length return if text_length <= MAXIMUM_LENGTH - raise WhatsappSdk::Resource::Error::InvalidInteractiveFooter, + raise WhatsappSdk::Resource::Errors::InvalidInteractiveFooter, "Invalid length #{text_length} for text in footer. Maximum length: #{MAXIMUM_LENGTH} characters." end end diff --git a/lib/whatsapp_sdk/resource/interactive_header.rb b/lib/whatsapp_sdk/resource/interactive_header.rb index 45ae00a..dee5488 100644 --- a/lib/whatsapp_sdk/resource/interactive_header.rb +++ b/lib/whatsapp_sdk/resource/interactive_header.rb @@ -109,7 +109,7 @@ def validate_attributes next unless value.nil? - raise WhatsappSdk::Resource::Error::MissingValue.new( + raise WhatsappSdk::Resource::Errors::MissingValue.new( type.serialize, "#{type.serialize} is required when the type is #{type_b}" ) diff --git a/lib/whatsapp_sdk/resource/parameter_object.rb b/lib/whatsapp_sdk/resource/parameter_object.rb index 20f0355..d5b2e43 100644 --- a/lib/whatsapp_sdk/resource/parameter_object.rb +++ b/lib/whatsapp_sdk/resource/parameter_object.rb @@ -154,8 +154,8 @@ def validate_attributes next unless type == type_b if value.nil? - raise WhatsappSdk::Resource::Error::MissingValue.new(type.serialize, - "#{type_b} is required when the type is #{type_b}") + raise WhatsappSdk::Resource::Errors::MissingValue.new(type.serialize, + "#{type_b} is required when the type is #{type_b}") end end end diff --git a/test/whatsapp/api/messages_test.rb b/test/whatsapp/api/messages_test.rb index 234684e..a6526bc 100644 --- a/test/whatsapp/api/messages_test.rb +++ b/test/whatsapp/api/messages_test.rb @@ -134,7 +134,7 @@ def test_send_location_message_with_valid_params end def test_send_image_raises_an_error_if_link_and_image_are_not_provided - assert_raises(WhatsappSdk::Resource::Error::MissingArgumentError) do + assert_raises(WhatsappSdk::Resource::Errors::MissingArgumentError) do @messages_api.send_image( sender_id: 123_123, recipient_number: 56_789, image_id: nil, link: nil, caption: "" @@ -205,7 +205,7 @@ def test_send_audio_message_with_success_response end def test_send_audio_raises_an_error_if_link_and_image_are_not_provided - assert_raises(WhatsappSdk::Resource::Error::MissingArgumentError) do + assert_raises(WhatsappSdk::Resource::Errors::MissingArgumentError) do @messages_api.send_audio( sender_id: 123_123, recipient_number: 56_789, link: nil, audio_id: nil ) @@ -255,7 +255,7 @@ def test_send_audio_message_with_an_audio_id end def test_send_video_raises_an_error_if_link_and_image_are_not_provided - assert_raises(WhatsappSdk::Resource::Error::MissingArgumentError) do + assert_raises(WhatsappSdk::Resource::Errors::MissingArgumentError) do @messages_api.send_video( sender_id: 123_123, recipient_number: 56_789, link: nil, video_id: nil ) @@ -316,7 +316,7 @@ def test_send_video_message_with_an_video_id end def test_send_document_raises_an_error_if_link_and_image_are_not_provided - assert_raises(WhatsappSdk::Resource::Error::MissingArgumentError) do + assert_raises(WhatsappSdk::Resource::Errors::MissingArgumentError) do @messages_api.send_document( sender_id: 123_123, recipient_number: 56_789, link: nil, document_id: nil ) @@ -377,7 +377,7 @@ def test_send_document_message_with_an_document_id end def test_send_sticker_raises_an_error_if_link_and_image_are_not_provided - assert_raises(WhatsappSdk::Resource::Error::MissingArgumentError) do + assert_raises(WhatsappSdk::Resource::Errors::MissingArgumentError) do @messages_api.send_sticker( sender_id: 123_123, recipient_number: 56_789, link: nil, sticker_id: nil ) @@ -497,7 +497,7 @@ def test_read_message_with_an_invalid_response end def test_send_template_raises_an_error_when_component_and_component_json_are_not_provided - error = assert_raises(WhatsappSdk::Resource::Error::MissingArgumentError) do + error = assert_raises(WhatsappSdk::Resource::Errors::MissingArgumentError) do @messages_api.send_template( sender_id: 123_123, recipient_number: 56_789, name: "template", language: "en_US" ) diff --git a/test/whatsapp/resource/interactive_action_section_row_test.rb b/test/whatsapp/resource/interactive_action_section_row_test.rb index fb26cc2..126579f 100644 --- a/test/whatsapp/resource/interactive_action_section_row_test.rb +++ b/test/whatsapp/resource/interactive_action_section_row_test.rb @@ -7,7 +7,7 @@ module WhatsappSdk module Resource class InteractionActionSectionRowTest < Minitest::Test def test_validation - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSectionRow) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSectionRow) do WhatsappSdk::Resource::InteractiveActionSectionRow.new( title: "I am the longer row title", id: "section_row", @@ -19,7 +19,7 @@ def test_validation error.message ) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSectionRow) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSectionRow) do WhatsappSdk::Resource::InteractiveActionSectionRow.new( title: "I am the row title", id: "section_row", @@ -31,7 +31,7 @@ def test_validation error.message ) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSectionRow) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSectionRow) do WhatsappSdk::Resource::InteractiveActionSectionRow.new( title: "I am the row title", id: "section_row" * 25, diff --git a/test/whatsapp/resource/interactive_action_section_test.rb b/test/whatsapp/resource/interactive_action_section_test.rb index af8ac8a..5ec7d20 100644 --- a/test/whatsapp/resource/interactive_action_section_test.rb +++ b/test/whatsapp/resource/interactive_action_section_test.rb @@ -7,7 +7,7 @@ module WhatsappSdk module Resource class InteractionActionSectionTest < Minitest::Test def test_validation - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSection) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSection) do WhatsappSdk::Resource::InteractiveActionSection.new( title: "I am the longer section title" ) diff --git a/test/whatsapp/resource/interactive_action_test.rb b/test/whatsapp/resource/interactive_action_test.rb index aad9c02..57dcc0e 100644 --- a/test/whatsapp/resource/interactive_action_test.rb +++ b/test/whatsapp/resource/interactive_action_test.rb @@ -7,7 +7,7 @@ module WhatsappSdk module Resource class InteractionActionTest < Minitest::Test def test_validation - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionButton) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionButton) do interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ListMessage ) @@ -18,7 +18,7 @@ def test_validation error.message ) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionButton) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionButton) do interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ListMessage ) @@ -30,7 +30,7 @@ def test_validation error.message ) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSection) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSection) do interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ListMessage ) @@ -42,7 +42,7 @@ def test_validation error.message ) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton) do interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ReplyButton ) @@ -53,7 +53,7 @@ def test_validation error.message ) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton) do interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ReplyButton ) diff --git a/test/whatsapp/resource/interactive_test.rb b/test/whatsapp/resource/interactive_test.rb index 78ac189..53cc0a8 100644 --- a/test/whatsapp/resource/interactive_test.rb +++ b/test/whatsapp/resource/interactive_test.rb @@ -15,7 +15,7 @@ module WhatsappSdk module Resource class InteractiveTest < Minitest::Test def test_validation_reply_buttons - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton) do interactive_body = WhatsappSdk::Resource::InteractiveBody.new(text: "This is the body!") interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ReplyButton @@ -49,7 +49,7 @@ def test_validation_reply_buttons end assert_equal("Invalid length 4 for buttons in action. It should be between 1 and 3.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton) do interactive_body = WhatsappSdk::Resource::InteractiveBody.new(text: "This is the body!") interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ReplyButton @@ -74,7 +74,7 @@ def test_validation_reply_buttons assert_equal("Duplicate ids [\"button_1\", \"button_1\"] for buttons in action. They should be unique.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton) do interactive_body = WhatsappSdk::Resource::InteractiveBody.new(text: "This is the body!") interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ReplyButton @@ -93,7 +93,7 @@ def test_validation_reply_buttons end assert_equal("Invalid length 24 for title in button. Maximum length: 20 characters.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionReplyButton) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionReplyButton) do interactive_body = WhatsappSdk::Resource::InteractiveBody.new(text: "This is the body!") interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ReplyButton @@ -112,7 +112,7 @@ def test_validation_reply_buttons end assert_equal("Invalid length 287 for id in button. Maximum length: 256 characters.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveFooter) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveFooter) do interactive_body = WhatsappSdk::Resource::InteractiveBody.new(text: "This is the body!") interactive_footer = WhatsappSdk::Resource::InteractiveFooter.new(text: "Footer " * 10) interactive_action = WhatsappSdk::Resource::InteractiveAction.new( @@ -143,7 +143,7 @@ def test_validation_reply_buttons end assert_equal("Invalid length 70 for text in footer. Maximum length: 60 characters.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveBody) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveBody) do interactive_body = WhatsappSdk::Resource::InteractiveBody.new(text: "Body " * 250) interactive_action = WhatsappSdk::Resource::InteractiveAction.new( type: WhatsappSdk::Resource::InteractiveAction::Type::ReplyButton @@ -174,7 +174,7 @@ def test_validation_reply_buttons end def test_validation_list_messages - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionButton) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionButton) do interactive_header = WhatsappSdk::Resource::InteractiveHeader.new( type: WhatsappSdk::Resource::InteractiveHeader::Type::Text, text: "I am the header!" @@ -213,7 +213,7 @@ def test_validation_list_messages end assert_equal("Invalid button in action. Button label is required.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSection) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSection) do interactive_header = WhatsappSdk::Resource::InteractiveHeader.new( type: WhatsappSdk::Resource::InteractiveHeader::Type::Text, text: "I am the header!" @@ -254,7 +254,7 @@ def test_validation_list_messages end assert_equal("Invalid length 25 for title in section. Maximum length: 24 characters.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSection) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSection) do interactive_header = WhatsappSdk::Resource::InteractiveHeader.new( type: WhatsappSdk::Resource::InteractiveHeader::Type::Text, text: "I am the header!" @@ -297,7 +297,7 @@ def test_validation_list_messages end assert_equal("Invalid number of rows 11 in section. Maximum count: 10.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSectionRow) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSectionRow) do interactive_header = WhatsappSdk::Resource::InteractiveHeader.new( type: WhatsappSdk::Resource::InteractiveHeader::Type::Text, text: "I am the header!" @@ -338,7 +338,7 @@ def test_validation_list_messages end assert_equal("Invalid length 27 for title in section row. Maximum length: 24 characters.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSectionRow) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSectionRow) do interactive_header = WhatsappSdk::Resource::InteractiveHeader.new( type: WhatsappSdk::Resource::InteractiveHeader::Type::Text, text: "I am the header!" @@ -379,7 +379,7 @@ def test_validation_list_messages end assert_equal("Invalid length 319 for id in section row. Maximum length: 256 characters.", error.message) - error = assert_raises(WhatsappSdk::Resource::Error::InvalidInteractiveActionSectionRow) do + error = assert_raises(WhatsappSdk::Resource::Errors::InvalidInteractiveActionSectionRow) do interactive_header = WhatsappSdk::Resource::InteractiveHeader.new( type: WhatsappSdk::Resource::InteractiveHeader::Type::Text, text: "I am the header!" diff --git a/test/whatsapp/resource/parameter_object_test.rb b/test/whatsapp/resource/parameter_object_test.rb index 66647dd..925feb3 100644 --- a/test/whatsapp/resource/parameter_object_test.rb +++ b/test/whatsapp/resource/parameter_object_test.rb @@ -7,7 +7,7 @@ require_relative '../../../lib/whatsapp_sdk/resource/date_time' require_relative '../../../lib/whatsapp_sdk/resource/currency' require_relative '../../../lib/whatsapp_sdk/error' -require_relative '../../../lib/whatsapp_sdk/resource/error' +require_relative '../../../lib/whatsapp_sdk/resource/errors' module WhatsappSdk module Resource @@ -38,7 +38,7 @@ def setup attr_name = :image end - error = assert_raises(WhatsappSdk::Resource::Error::MissingValue) do + error = assert_raises(WhatsappSdk::Resource::Errors::MissingValue) do T.unsafe(WhatsappSdk::Resource::ParameterObject).new(type: type, attr_name => object) end