Class: Schatter::Conversation
Instance Method Summary
collapse
Methods inherited from Resource
#delete, #destroy, #formatted_timestamp, #get, #initialize, #links, #post, #resource, #timestamp, #uuid
Instance Method Details
#create_message(params) ⇒ Object
31
32
33
|
# File 'lib/schatter/conversation.rb', line 31
def create_message params
post links[:messages], params
end
|
#create_person(params) ⇒ Object
35
36
37
|
# File 'lib/schatter/conversation.rb', line 35
def create_person params
post links[:people], params
end
|
#messages(reload = false) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/schatter/conversation.rb', line 6
def messages reload=false
@messages = nil if reload
return @messages if @messages
@messages = Hash[get(links[:messages])['messages'].map do |resource|
[resource['uuid'], Schatter::Message.new(resource: resource)]
end]
end
|
#name ⇒ Object
39
40
41
|
# File 'lib/schatter/conversation.rb', line 39
def name
resource['name']
end
|
#new_messages ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/schatter/conversation.rb', line 14
def new_messages
params = {}
params[:message_id] = messages.last.uuid unless messages.empty?
get(links[:messages], params)['messages'].each do |resource|
messages[resource['uuid']] = Schatter::Message.new(resource: resource)
end
@messages
end
|
#people(reload = false) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/schatter/conversation.rb', line 23
def people reload=false
@people = nil if reload
return @people if @people
@people = Hash[get(links[:people])['people'].map do |resource|
[resource['uuid'], Schatter::Person.new(resource: resource)]
end]
end
|