Sha256: 70ffcf407d19487a22867696bafc28356763eddaa9b327762079cf35db9c30e6

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
caren-api-0.11.0 lib/caren/chat_session.rb
caren-api-0.10.0 lib/caren/chat_session.rb
caren-api-0.9.10 lib/caren/chat_session.rb
caren-api-0.9.9 lib/caren/chat_session.rb
caren-api-0.9.8 lib/caren/chat_session.rb
caren-api-0.9.7 lib/caren/chat_session.rb
caren-api-0.9.6 lib/caren/chat_session.rb
caren-api-0.9.4 lib/caren/chat_session.rb
caren-api-0.9.3 lib/caren/chat_session.rb
caren-api-0.9.2 lib/caren/chat_session.rb