Class: SparkApi::Models::Contact

Inherits:
Base
  • Object
show all
Extended by:
Finders
Includes:
SparkApi::Models::Concerns::Destroyable, SparkApi::Models::Concerns::Savable
Defined in:
lib/spark_api/models/contact.rb

Constant Summary

Constants included from Paginate

Paginate::DEFAULT_PAGE_SIZE

Instance Attribute Summary

Attributes inherited from Base

#attributes, #errors, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Finders

find, find_one, first, last

Methods included from SparkApi::Models::Concerns::Savable

#create!, #params_for_save, #post_data, #save, #save!, #update!, #update_attributes

Methods included from SparkApi::Models::Concerns::Destroyable

#destroy, #destroy!, #destroyed?, included

Methods inherited from Base

connection, #connection, count, element_name, element_name=, first, get, #id, #initialize, #load, #method_missing, #parse_id, path, #path, #persisted?, prefix, prefix=, #resource_pluralized, #resource_uri, #respond_to?, #to_param, #to_partial_path

Methods included from Paginate

#collect, #paginate, #per_page

Methods included from Dirty

#changed, #changed?, #changed_attributes, #changes, #dirty_attributes, #previous_changes

Constructor Details

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

Dynamic Method Handling

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

Class Method Details

.by_tag(tag_name, arguments = {}) ⇒ Object



10
11
12
# File 'lib/spark_api/models/contact.rb', line 10

def self.by_tag(tag_name, arguments={})
  collect(connection.get("#{path}/tags/#{tag_name}", arguments))
end

.export(arguments = {}) ⇒ Object



22
23
24
# File 'lib/spark_api/models/contact.rb', line 22

def self.export(arguments={})
  collect(connection.get("/contacts/export", arguments))
end

.export_all(arguments = {}) ⇒ Object



26
27
28
# File 'lib/spark_api/models/contact.rb', line 26

def self.export_all(arguments={})
  collect(connection.get("/contacts/export/all", arguments))
end

.my(arguments = {}) ⇒ Object



18
19
20
# File 'lib/spark_api/models/contact.rb', line 18

def self.my(arguments={})
  new(connection.get('/my/contact', arguments).first)
end

.tags(arguments = {}) ⇒ Object



14
15
16
# File 'lib/spark_api/models/contact.rb', line 14

def self.tags(arguments={})
  connection.get("#{path}/tags", arguments)
end

Instance Method Details

#comment(body) ⇒ Object



51
52
53
54
55
56
# File 'lib/spark_api/models/contact.rb', line 51

def comment(body)
  comment = Comment.new({ :Comment => body })
  comment.parent = self
  comment.save
  comment
end

#comments(arguments = {}) ⇒ Object



48
49
50
# File 'lib/spark_api/models/contact.rb', line 48

def comments(arguments = {})
  @comments ||= Comment.collect(connection.get("/contacts/#{self.Id}/comments", arguments))
end

#listing_carts(arguments = {}) ⇒ Object



44
45
46
# File 'lib/spark_api/models/contact.rb', line 44

def listing_carts(arguments = {})
  @listing_carts ||= ListingCart.collect(connection.get("/contacts/#{self.Id}/listingcarts", arguments))
end

#notify=(notify_me) ⇒ Object



32
33
34
# File 'lib/spark_api/models/contact.rb', line 32

def notify=(notify_me)
  params_for_save[:Notify] = notify_me
end

#notify?Boolean

Notify the agent of contact creation via a Spark notification.

Returns:

  • (Boolean)


31
# File 'lib/spark_api/models/contact.rb', line 31

def notify?; params_for_save[:Notify] == true end

#provided_searches(arguments = {}) ⇒ Object



40
41
42
# File 'lib/spark_api/models/contact.rb', line 40

def provided_searches(arguments = {})
  @provided_searches ||= SavedSearch.collect(connection.get("/contacts/#{self.Id}/provided/savedsearches", arguments))
end

#saved_searches(arguments = {}) ⇒ Object



36
37
38
# File 'lib/spark_api/models/contact.rb', line 36

def saved_searches(arguments = {})
  @saved_searches ||= SavedSearch.collect(connection.get("/contacts/#{self.Id}/savedsearches", arguments))
end

#vow_account(arguments = {}) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/spark_api/models/contact.rb', line 58

def (arguments={})
  return @vow_account if @vow_account
  begin
    @vow_account = VowAccount.new(connection.get("/contacts/#{self.Id}/portal", arguments).first)
    @vow_account.parent = self
    @vow_account
  rescue NotFound
    nil
  end
end