Class: Caren::ChatSession

Inherits:
Base
  • Object
show all
Defined in:
lib/caren/chat_session.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



20
21
22
# File 'lib/caren/chat_session.rb', line 20

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

.array_rootObject



32
33
34
# File 'lib/caren/chat_session.rb', line 32

def self.array_root
  :chat_sessions
end

.find(subject_id, id, session) ⇒ Object



24
25
26
# File 'lib/caren/chat_session.rb', line 24

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
16
17
18
# File 'lib/caren/chat_session.rb', line 3

def self.keys
  [ :id,                  # Integer (Caren message id)
    :person_name,         # String (Andre Foeken)
    :person_id,           # Integer (Caren person id, if applicable)
    :external_person_id,  # String (Your person id)
    :care_provider_id,    # Integer (Caren CP id)
    :comment,             # Text
    :external_id,         # String (Your message id)
    :billable_id,         # String (Caren billable id)
    :event_id,            # String (Caren event id)
    :starts_at,           # DateTime
    :ends_at,             # DateTime
    :duration,            # DateTime
    :subject_id           # Integer (Caren person id)
  ] + super
end

.node_rootObject



36
37
38
# File 'lib/caren/chat_session.rb', line 36

def self.node_root
  :chat_session
end

.resource_locationObject



46
47
48
# File 'lib/caren/chat_session.rb', line 46

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

Instance Method Details

#as_xmlObject



40
41
42
43
44
# File 'lib/caren/chat_session.rb', line 40

def as_xml
  { :starts_at => self.starts_at,
    :ends_at => self.ends_at,
    :external_id => self.external_id }
end

#update(session) ⇒ Object



28
29
30
# File 'lib/caren/chat_session.rb', line 28

def update session
  self.class.from_xml session.put self.class.resource_url(self.subject_id,self.id), self.to_xml
end