Class: FlexmlsApi::Models::Contact
- Extended by:
- Finders
- Defined in:
- lib/flexmls_api/models/contact.rb
Constant Summary
Constants included from Paginate
Instance Attribute Summary
Attributes inherited from Base
#attributes, #changed, #errors
Class Method Summary collapse
- .by_tag(tag_name, arguments = {}) ⇒ Object
- .my(arguments = {}) ⇒ Object
- .tags(arguments = {}) ⇒ Object
Instance Method Summary collapse
- #notify=(notify_me = true) ⇒ Object
-
#notify? ⇒ Boolean
Notify the agent of contact creation via a flexmls message.
- #save(arguments = {}) ⇒ Object
- #save!(arguments = {}) ⇒ Object
Methods included from Finders
Methods inherited from Base
#connection, connection, count, element_name, element_name=, first, get, #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
.by_tag(tag_name, arguments = {}) ⇒ Object
27 28 29 |
# File 'lib/flexmls_api/models/contact.rb', line 27 def self.by_tag(tag_name, arguments={}) collect(connection.get("#{path}/tags/#{tag_name}", arguments)) end |
.my(arguments = {}) ⇒ Object
35 36 37 |
# File 'lib/flexmls_api/models/contact.rb', line 35 def self.my(arguments={}) new(connection.get('/my/contact', arguments).first) end |
.tags(arguments = {}) ⇒ Object
31 32 33 |
# File 'lib/flexmls_api/models/contact.rb', line 31 def self.(arguments={}) connection.get("#{path}/tags", arguments) end |
Instance Method Details
#notify=(notify_me = true) ⇒ Object
43 44 45 |
# File 'lib/flexmls_api/models/contact.rb', line 43 def notify=(notify_me=true) @notify = notify_me end |
#notify? ⇒ Boolean
Notify the agent of contact creation via a flexmls message.
40 41 42 |
# File 'lib/flexmls_api/models/contact.rb', line 40 def notify? @notify == true end |
#save(arguments = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/flexmls_api/models/contact.rb', line 7 def save(arguments={}) self.errors = [] # clear the errors hash begin return save!(arguments) rescue BadResourceRequest => e self.errors << {:code => e.code, :message => e.} FlexmlsApi.logger.error("Failed to save resource #{self}: #{e.}") rescue NotFound => e FlexmlsApi.logger.error("Failed to save resource #{self}: #{e.}") end false end |
#save!(arguments = {}) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/flexmls_api/models/contact.rb', line 19 def save!(arguments={}) results = connection.post self.class.path, {"Contacts" => [ attributes ], "Notify" => notify? }, arguments result = results.first attributes['ResourceUri'] = result['ResourceUri'] attributes['Id'] = parse_id(result['ResourceUri']) true end |