Class: FlexmlsApi::Models::Note

Inherits:
Base
  • Object
show all
Extended by:
Subresource
Defined in:
lib/flexmls_api/models/note.rb

Constant Summary

Constants included from Paginate

Paginate::DEFAULT_PAGE_SIZE

Instance Attribute Summary

Attributes inherited from Base

#attributes, #changed, #errors

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Subresource

build_subclass, find_by_id, find_by_listing_key

Methods inherited from Base

#connection, connection, count, element_name, element_name=, first, #initialize, #load, #method_missing, #parse_id, path, prefix, prefix=, #respond_to?

Methods included from Paginate

#collect, #paginate, #per_page

Constructor Details

This class inherits a constructor from FlexmlsApi::Models::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class FlexmlsApi::Models::Base

Class Method Details

.get(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/flexmls_api/models/note.rb', line 7

def self.get(options={})
  ret = super(options)
  if ret.empty?
    return nil
  else
    return ret.first
  end
end

Instance Method Details

#delete(args = {}) ⇒ Object



35
36
37
# File 'lib/flexmls_api/models/note.rb', line 35

def delete(args={})
  connection.delete(self.class.path, args)
end

#save(arguments = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/flexmls_api/models/note.rb', line 16

def save(arguments={})
  begin
    return save!(arguments)
  rescue BadResourceRequest => e
  rescue NotFound => e
    # log and leave
    FlexmlsApi.logger.error("Failed to save note #{self} (path: #{self.class.path}): #{e.message}")
  end 
  false
end

#save!(args = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/flexmls_api/models/note.rb', line 27

def save!(args={})
  args.merge(:Notes => attributes['Note'])
  results = connection.put(self.class.path, {:Note => attributes['Note']}, args)
  result = results.first
  attributes['ResourceUri'] = result['ResourceUri']
  true
end