Class: Caren::ChatSessionMessage

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

Instance Attribute Summary

Attributes inherited from Base

#attributes, #original_xml

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

from_xml, hash_from_image, init_dependent_objects, #initialize, #node_root, search_url, to_xml, #to_xml

Constructor Details

This class inherits a constructor from Caren::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Caren::Base

Class Method Details

.all(subject_id, session) ⇒ Object



17
18
19
# File 'lib/caren/chat_session_message.rb', line 17

def self.all subject_id, session
  from_xml session.get(self.resource_url(subject_id))
end

.array_rootObject



29
30
31
# File 'lib/caren/chat_session_message.rb', line 29

def self.array_root
  :chat_session_messages
end

.find(subject_id, id, session) ⇒ Object



21
22
23
# File 'lib/caren/chat_session_message.rb', line 21

def self.find subject_id, id, session
  from_xml session.get(self.resource_url(subject_id,id))
end

.keysObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/caren/chat_session_message.rb', line 3

def self.keys
  [ :id,                  # Integer (Caren message id)
    :person_name,         # String (Andre Foeken)
    :person_id,           # Integer (Caren person id)
    :external_person_id,  # String (Your person id)
    :care_provider_id,    # Integer (Caren CP id)
    :body,                # Text
    :external_id,         # String (Your message id)
    :in_reply_to_id,      # Integer (Caren message id)
    :in_reply_to_type,    # The type of message this is a reply to. (Always ChatSessionMessage if reply is set)
    :subject_id           # Integer (Caren person id)
  ] + super
end

.node_rootObject



33
34
35
# File 'lib/caren/chat_session_message.rb', line 33

def self.node_root
  :chat_session_message
end

.resource_locationObject



45
46
47
# File 'lib/caren/chat_session_message.rb', line 45

def self.resource_location
  "/api/pro/people/%i/chat_session_messages"
end

Instance Method Details

#as_xmlObject



37
38
39
40
41
42
43
# File 'lib/caren/chat_session_message.rb', line 37

def as_xml
  { :person_name => self.person_name,
    :external_person_id => self.external_person_id,
    :body => self.body,
    :external_id => self.external_id,
    :in_reply_to_id => self.in_reply_to_id }
end

#create(session) ⇒ Object



25
26
27
# File 'lib/caren/chat_session_message.rb', line 25

def create session
  self.class.from_xml session.post self.class.resource_url(self.subject_id), self.to_xml
end