Class: Tend::Contact

Inherits:
Garden show all
Includes:
Util::NoPost
Defined in:
lib/tend/models/contact.rb

Constant Summary collapse

ATTRIBUTES =
[:id, :name, :firstName, :lastName, :email, :company, :title, :bio, :website, :address, :city, :state, :zip, :country, :photo, :facebook, :twitter, :linkedin, :activity, :segments, :referrers, :campaigns]

Instance Attribute Summary

Attributes inherited from Garden

#attributes

Instance Method Summary collapse

Methods included from Util::NoPost

included

Methods inherited from Garden

all, create, find

Methods included from Util::Util

included

Methods included from Util::Ht

included

Constructor Details

#initialize(*args) ⇒ Contact

Returns a new instance of Contact.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tend/models/contact.rb', line 9

def initialize *args
  init(*args) do |att, value|
    case att
    when :segments
      a = []
      value.each do |h|
        a << Tend::Segment.new( h )
      end
      @segments = a
    when :campaign
      a = []
      value.each do |h|
        a << Tend::Campaign.new( h )
      end
      @campaigns = a
    when :referrer
      a = []
      value.each do |h|
        a << Tend::Referrer.new( h )
      end
      @referrers = a
    else
      send("#{att}=", value)
    end
  end
end

Instance Method Details

#segments(options = {}) ⇒ Object



41
42
43
44
# File 'lib/tend/models/contact.rb', line 41

def segments options = {}
  return @segments if @segments && !options.delete(:reload)
  collection "segments", Tend::Segment, options
end

#visits(options = {}) ⇒ Object



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

def visits options = {}
  return @visits if @visits && !options.delete(:reload)
  collection "visits", Tend::Visit, options
end