Class: Warb::Resources::InteractiveReplyButton
- Defined in:
- lib/warb/resources/interactive_reply_button.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#body ⇒ Object
Returns the value of attribute body.
-
#footer ⇒ Object
Returns the value of attribute footer.
-
#header ⇒ Object
Returns the value of attribute header.
Instance Method Summary collapse
- #add_document_header(media_id: nil, link: nil, filename: nil) ⇒ Object
- #add_image_header(media_id: nil, link: nil) ⇒ Object
-
#add_text_header(text) ⇒ Object
rubocop:enable Metrics/MethodLength.
- #add_video_header(media_id: nil, link: nil) ⇒ Object
- #build_action(**params) ⇒ Object
-
#build_payload ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods inherited from Resource
#build_header, #build_template_named_parameter, #build_template_positional_parameter, #call, #initialize
Methods included from Validation
#blank?, #raw_value, #resolve, #validates
Constructor Details
This class inherits a constructor from Warb::Resources::Resource
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
6 7 8 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 6 def action @action end |
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 6 def body @body end |
#footer ⇒ Object
Returns the value of attribute footer.
6 7 8 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 6 def @footer end |
#header ⇒ Object
Returns the value of attribute header.
6 7 8 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 6 def header @header end |
Instance Method Details
#add_document_header(media_id: nil, link: nil, filename: nil) ⇒ Object
39 40 41 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 39 def add_document_header(media_id: nil, link: nil, filename: nil) @header = Warb::Resources::Document.new(media_id:, link:, filename:).build_header end |
#add_image_header(media_id: nil, link: nil) ⇒ Object
31 32 33 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 31 def add_image_header(media_id: nil, link: nil) @header = Warb::Resources::Image.new(media_id:, link:).build_header end |
#add_text_header(text) ⇒ Object
rubocop:enable Metrics/MethodLength
27 28 29 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 27 def add_text_header(text) @header = Warb::Resources::Text.new(text:).build_header end |
#add_video_header(media_id: nil, link: nil) ⇒ Object
35 36 37 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 35 def add_video_header(media_id: nil, link: nil) @header = Warb::Resources::Video.new(media_id:, link:).build_header end |
#build_action(**params) ⇒ Object
43 44 45 46 47 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 43 def build_action(**params, &) @action = Warb::Components::ReplyButtonAction.new(**params) block_given? ? @action.tap(&) : @action end |
#build_payload ⇒ Object
rubocop:disable Metrics/MethodLength
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/warb/resources/interactive_reply_button.rb', line 9 def build_payload { type: 'interactive', interactive: { type: 'button', header: header || @params[:header]&.to_h, body: { text: body || @params[:body] }, footer: { text: || @params[:footer] }, action: (action || @params[:action])&.to_h } } end |