Sha256: 96fb5a3fe4119d4e61451746deff2d410cf88c9489370f61ec38d916c73c7414

Contents?: true

Size: 1.58 KB

Versions: 20

Compression:

Stored size: 1.58 KB

Contents

class Caren::ChatSessionMessage < Caren::Base

  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

  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 create session
    self.class.from_xml session.post self.class.resource_url(self.subject_id), self.to_xml
  end

  def self.array_root
    :chat_session_messages
  end

  def self.node_root
    :chat_session_message
  end

  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

  def self.resource_location
    "/api/pro/people/%i/chat_session_messages"
  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

20 entries across 20 versions & 1 rubygems

Version Path
caren-api-0.12.5 lib/caren/chat_session_message.rb
caren-api-0.12.4 lib/caren/chat_session_message.rb
caren-api-0.12.3 lib/caren/chat_session_message.rb
caren-api-0.12.2 lib/caren/chat_session_message.rb
caren-api-0.12.1 lib/caren/chat_session_message.rb
caren-api-0.12.0 lib/caren/chat_session_message.rb
caren-api-0.11.1 lib/caren/chat_session_message.rb
caren-api-0.11.0 lib/caren/chat_session_message.rb
caren-api-0.10.0 lib/caren/chat_session_message.rb
caren-api-0.9.10 lib/caren/chat_session_message.rb
caren-api-0.9.9 lib/caren/chat_session_message.rb
caren-api-0.9.8 lib/caren/chat_session_message.rb
caren-api-0.9.7 lib/caren/chat_session_message.rb
caren-api-0.9.6 lib/caren/chat_session_message.rb
caren-api-0.9.4 lib/caren/chat_session_message.rb
caren-api-0.9.3 lib/caren/chat_session_message.rb
caren-api-0.9.2 lib/caren/chat_session_message.rb
caren-api-0.9.1 lib/caren/chat_session_message.rb
caren-api-0.9.0 lib/caren/chat_session_message.rb
caren-api-0.8.0 lib/caren/chat_session_message.rb