Class: Bottle::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/api_objects/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to = nil, name = nil, body = nil, file = nil, tags = nil) ⇒ Message



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/api_objects/message.rb', line 8

def initialize(to=nil, name=nil, body=nil, file=nil, tags=nil)
  @url_extension = 'messages'
  if to.is_a?(Hash)
    attributes = to.convert_keys_to_symbols
    @to = attributes[:to]
    @name = attributes[:name]
    @body = attributes[:body]
    @file = attributes[:file]
    @tags = attributes[:tags]
    @id = attributes[:id]
    @from_number = attributes[:from_number]
    @to_number = attributes[:to_number]
    @delivered_at = attributes[:delivered_at]
    @viewed_at = attributes[:viewed_at]
    @created_at = attributes[:created_at]
    @updated_at = attributes[:updated_at]
    @direction = attributes[:direction]
    @conversation_id = attributes[:conversation_id]
    @origin = attributes[:origin]
    @object_name = attributes[:object_name]
    @object_key = attributes[:object_key]
    @user_id = attributes[:user_id]
    @created_from_rule_id = attributes[:created_from_rule_id]
    @body_decoded = attributes[:body_decoded]
    @attachments = attributes[:attachments]
  else
    @to = to
    @name = name
    @body = body
    @file = file
    @tags = tags
  end
end

Instance Attribute Details

#attachmentsObject

Returns the value of attribute attachments.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def attachments
  @attachments
end

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def body
  @body
end

#body_decodedObject

Returns the value of attribute body_decoded.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def body_decoded
  @body_decoded
end

#conversation_idObject

Returns the value of attribute conversation_id.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def conversation_id
  @conversation_id
end

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def created_at
  @created_at
end

#created_from_rule_idObject

Returns the value of attribute created_from_rule_id.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def created_from_rule_id
  @created_from_rule_id
end

#delivered_atObject

Returns the value of attribute delivered_at.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def delivered_at
  @delivered_at
end

#directionObject

Returns the value of attribute direction.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def direction
  @direction
end

#fileObject

Returns the value of attribute file.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def file
  @file
end

#from_numberObject

Returns the value of attribute from_number.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def from_number
  @from_number
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def name
  @name
end

#object_keyObject

Returns the value of attribute object_key.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def object_key
  @object_key
end

#object_nameObject

Returns the value of attribute object_name.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def object_name
  @object_name
end

#originObject

Returns the value of attribute origin.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def origin
  @origin
end

#tagsObject

Returns the value of attribute tags.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def tags
  @tags
end

#toObject

Returns the value of attribute to.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def to
  @to
end

#to_numberObject

Returns the value of attribute to_number.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def to_number
  @to_number
end

#updated_atObject

Returns the value of attribute updated_at.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def updated_at
  @updated_at
end

#user_idObject

Returns the value of attribute user_id.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def user_id
  @user_id
end

#viewed_atObject

Returns the value of attribute viewed_at.



4
5
6
# File 'lib/api_objects/message.rb', line 4

def viewed_at
  @viewed_at
end

Instance Method Details

#send(client) ⇒ Object



42
43
44
# File 'lib/api_objects/message.rb', line 42

def send(client)
  client.post(@url_extension, {message: {to: self.to, name: self.name, text: self.body, file: self.file}, conversation: {tags: self.tags}})
end