Class: CiscoSpark::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

#mentionedGroupsObject

Returns the value of attribute mentionedGroups.



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

def mentionedGroups
  @mentionedGroups
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

#toPersonEmailObject

Returns the value of attribute toPersonEmail.



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

def toPersonEmail
  @toPersonEmail
end

#toPersonIdObject

Returns the value of attribute toPersonId.



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

def toPersonId
  @toPersonId
end

Class Method Details

.create(payload = {}) ⇒ Object



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

def create(payload = {})
  # TODO: uploading attachments is a special case https://developer.ciscospark.com/attachments.html
  # TODO: we need some way to check that either a roomID, toPersonID or toPersonEmail was passed
  res = CiscoSpark.rest('POST', '/messages', payload: payload)
  if res.ok
    message = CiscoSpark::Message.new(JSON.parse(res.body))
    return message
  end
  nil
end

.get(id) ⇒ Object



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

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