Class: Spark::Message

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #delete, #refresh, #update

Constructor Details

#initialize(data) ⇒ Message

Returns a new instance of Message.



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

def initialize(data)
    @api_endpoint = 'messages'
    @update_fields = []
    super
end

Instance Attribute Details

#createdObject

Returns the value of attribute created.



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

def created
  @created
end

#filesObject

Returns the value of attribute files.



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

def files
  @files
end

#htmlObject

Returns the value of attribute html.



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

def html
  @html
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#markdownObject

Returns the value of attribute markdown.



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

def markdown
  @markdown
end

#mentionedPeopleObject

Returns the value of attribute mentionedPeople.



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

def mentionedPeople
  @mentionedPeople
end

#personEmailObject

Returns the value of attribute personEmail.



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

def personEmail
  @personEmail
end

#personIdObject

Returns the value of attribute personId.



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

def personId
  @personId
end

#roomIdObject

Returns the value of attribute roomId.



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

def roomId
  @roomId
end

#roomTypeObject

Returns the value of attribute roomType.



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

def roomType
  @roomType
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

Class Method Details

.Create(roomId, payload = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/message.rb', line 18

def Create(roomId, payload={})
    payload[:roomId] = roomId
    res = Spark::rest('POST',"/messages", {:payload => payload})
    if res.ok
        message = Spark::Message.new(JSON.parse(res.body))
        return message
    end
    return nil
end

.Get(id) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/message.rb', line 10

def Get(id)
    res = Spark::rest('GET',"/messages/#{id}")
    if res.ok
        message = Spark::Message.new(JSON.parse(res.body))
        return message
    end
    return nil
end