Class: Ey::Core::Client::Message

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/ey-core/models/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #to_s, #update!, #url

Instance Attribute Details

#request_idObject

Returns the value of attribute request_id.



9
10
11
# File 'lib/ey-core/models/message.rb', line 9

def request_id
  @request_id
end

Instance Method Details

#save!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ey-core/models/message.rb', line 11

def save!
  params = {
    "message" => self.message,
    "url"     => self.collection.url,
  }

  if self.request_id
    params["url"] = self.connection.url_for("/requests/#{self.request_id}/messages")
  end

  if new_record?
    message = self.collection.new(self.connection.create_message(params).body["message"])
    merge_attributes(message.attributes)
  else raise NotImplementedError
  end
end