class Caren::ChatSession < Caren::Base 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 def self.all subject_id, session from_xml session.get(self.resource_url(subject_id)) end def self.find subject_id, id, session from_xml session.get(self.resource_url(subject_id,id)) end def update session self.class.from_xml session.put self.class.resource_url(self.subject_id,self.id), self.to_xml end def self.array_root :chat_sessions end def self.node_root :chat_session end def as_xml { :starts_at => self.starts_at, :ends_at => self.ends_at } end def self.resource_location "/api/pro/people/%i/chat_sessions" end private def resource_url subject_id, id=nil self.class.resource_url(subject_id,id) end def self.resource_url subject_id, id=nil "#{self.resource_location % subject_id}#{id}" end end