Sha256: 895a35cdfc99ac244403500555446776ea7149493186df10bfa13c5b98017d80

Contents?: true

Size: 984 Bytes

Versions: 2

Compression:

Stored size: 984 Bytes

Contents

module ActsAsIcontact
  class Contact < Resource
    
    # Email is required
    def self.required_on_create
      super << 'email'
    end
    
    # Defaults to status=total to return contacts on or off lists
    def self.default_options
      super.merge(:status=>:total)
    end
   
    # Returns the lists to which this contact is subscribed (via the Subscription class).
    def lists
      @lists ||= ActsAsIcontact::Subscription.lists(:contactId => id)
    end
    
    # Creates a new subscription for the contact to the specified list
    def subscribe(list)
      l = ActsAsIcontact::List.find(list)
      s = ActsAsIcontact::Subscription.new(:contactId => id, :listId => l.id)
      s.save
    end
    
    # Returns a collection of ContactHistory resources for this contact.  The usual iContact search options (limit, offset, search terms, etc.) can be passed.
    def history(options={})
      ActsAsIcontact::ContactHistory.scoped_find(self, options)
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
SFEley-acts_as_icontact-0.4.0 lib/acts_as_icontact/resources/contact.rb
acts_as_icontact-0.4.0 lib/acts_as_icontact/resources/contact.rb