Class: Warb::Resources::Text
- Defined in:
- lib/warb/resources/text.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#examples ⇒ Object
Returns the value of attribute examples.
-
#message ⇒ Object
Returns the value of attribute message.
-
#parameter_name ⇒ Object
Returns the value of attribute parameter_name.
-
#preview_url ⇒ Object
Returns the value of attribute preview_url.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #build_header ⇒ Object
- #build_payload ⇒ Object
- #build_template_example_parameter ⇒ Object
- #build_template_named_parameter(parameter_name) ⇒ Object
- #build_template_positional_parameter ⇒ Object
Methods inherited from Resource
#add_document_header, #add_image_header, #add_text_header, #add_video_header, #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
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/warb/resources/text.rb', line 6 def content @content end |
#examples ⇒ Object
Returns the value of attribute examples.
6 7 8 |
# File 'lib/warb/resources/text.rb', line 6 def examples @examples end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/warb/resources/text.rb', line 6 def @message end |
#parameter_name ⇒ Object
Returns the value of attribute parameter_name.
6 7 8 |
# File 'lib/warb/resources/text.rb', line 6 def parameter_name @parameter_name end |
#preview_url ⇒ Object
Returns the value of attribute preview_url.
6 7 8 |
# File 'lib/warb/resources/text.rb', line 6 def preview_url @preview_url end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/warb/resources/text.rb', line 6 def text @text end |
Instance Method Details
#build_header ⇒ Object
8 9 10 11 12 13 |
# File 'lib/warb/resources/text.rb', line 8 def build_header { type: 'text', text: }.tap do |header| parameter_name ||= @params[:parameter_name] header[:parameter_name] = parameter_name unless parameter_name.nil? end end |
#build_payload ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/warb/resources/text.rb', line 15 def build_payload { type: 'text', text: { preview_url: preview_url || @params[:preview_url], body: } } end |
#build_template_example_parameter ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/warb/resources/text.rb', line 40 def build_template_example_parameter { type: 'body', text: }.tap do |param| examples ||= @params[:examples] next unless examples.is_a?(Array) param[:example] = { body_text: [examples] } end end |
#build_template_named_parameter(parameter_name) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/warb/resources/text.rb', line 25 def build_template_named_parameter(parameter_name) { type: 'text', text: , parameter_name: parameter_name } end |
#build_template_positional_parameter ⇒ Object
33 34 35 36 37 38 |
# File 'lib/warb/resources/text.rb', line 33 def build_template_positional_parameter { type: 'text', text: } end |