Class: Warb::Resources::Text

Inherits:
Resource show all
Defined in:
lib/warb/resources/text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject

Returns the value of attribute content.



6
7
8
# File 'lib/warb/resources/text.rb', line 6

def content
  @content
end

#examplesObject

Returns the value of attribute examples.



6
7
8
# File 'lib/warb/resources/text.rb', line 6

def examples
  @examples
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/warb/resources/text.rb', line 6

def message
  @message
end

#parameter_nameObject

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_urlObject

Returns the value of attribute preview_url.



6
7
8
# File 'lib/warb/resources/text.rb', line 6

def preview_url
  @preview_url
end

#textObject

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_headerObject



8
9
10
11
12
13
# File 'lib/warb/resources/text.rb', line 8

def build_header
  { type: 'text', text: message_per_priority }.tap do |header|
    parameter_name ||= @params[:parameter_name]
    header[:parameter_name] = parameter_name unless parameter_name.nil?
  end
end

#build_payloadObject



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: message_per_priority
    }
  }
end

#build_template_example_parameterObject



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: message_per_priority }.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: message_per_priority,
    parameter_name: parameter_name
  }
end

#build_template_positional_parameterObject



33
34
35
36
37
38
# File 'lib/warb/resources/text.rb', line 33

def build_template_positional_parameter
  {
    type: 'text',
    text: message_per_priority
  }
end