Class: TocaroWebhook::Payload

Inherits:
Object
  • Object
show all
Defined in:
lib/tocaro_webhook/payload.rb

Defined Under Namespace

Classes: Attachments

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attachmentsObject

Returns the value of attribute attachments.



5
6
7
# File 'lib/tocaro_webhook/payload.rb', line 5

def attachments
  @attachments
end

#colorObject

Returns the value of attribute color.



5
6
7
# File 'lib/tocaro_webhook/payload.rb', line 5

def color
  @color
end

#textObject

Returns the value of attribute text.



5
6
7
# File 'lib/tocaro_webhook/payload.rb', line 5

def text
  @text
end

Instance Method Details

#add_attachment(options = {}) ⇒ Object



24
25
26
# File 'lib/tocaro_webhook/payload.rb', line 24

def add_attachment(options={})
  attachments.add(options)
end

#to_bodyObject

uri encode json object



8
9
10
# File 'lib/tocaro_webhook/payload.rb', line 8

def to_body
  "payload=" + URI.encode(to_json_string)
end

#to_hObject



12
13
14
# File 'lib/tocaro_webhook/payload.rb', line 12

def to_h
  { text: text, color: color, attachments: attachments.to_a }
end