Class: ActsAsIcontact::List

Inherits:
Resource show all
Defined in:
lib/acts_as_icontact/resources/list.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, all, #connection, #error, #errors, find, find_by_id, first, #id, #initialize, #inspect, #method_missing, #new_record?, #property_names, #save, #save!

Constructor Details

This class inherits a constructor from ActsAsIcontact::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActsAsIcontact::Resource

Class Method Details

.boolean_fieldsObject

The following can be set with true or false: emailOwnerOnChange, welcomeOnManualAdd, welcomeOnSignupAdd



15
16
17
# File 'lib/acts_as_icontact/resources/list.rb', line 15

def self.boolean_fields
  super << "emailOwnerOnChange" << "welcomeOnManualAdd" << "welcomeOnSignupAdd"
end

.find_by_string(value) ⇒ Object

Searches on list name.



5
6
7
# File 'lib/acts_as_icontact/resources/list.rb', line 5

def self.find_by_string(value)
  first(:name => value)
end

.required_on_createObject

Requires name, emailOwnerOnChange, welcomeOnManualAdd, welcomeOnSignupAdd, and welcomeMessageId.



10
11
12
# File 'lib/acts_as_icontact/resources/list.rb', line 10

def self.required_on_create
  super << "name" << "emailOwnerOnChange" << "welcomeOnManualAdd" << "welcomeOnSignupAdd" << "welcomeMessageId"
end

Instance Method Details

#subscribe(contact) ⇒ Object

Creates a new subscription for the specified list by the contact



31
32
33
34
35
# File 'lib/acts_as_icontact/resources/list.rb', line 31

def subscribe(contact)
  c = ActsAsIcontact::Contact.find(contact)
  s = ActsAsIcontact::Subscription.new(:contactId => c.id, :listId => id)
  s.save
end

#subscribersObject

Returns the contacts subscribed to this list (via the Subscription class).



26
27
28
# File 'lib/acts_as_icontact/resources/list.rb', line 26

def subscribers
  @subscribers ||= ActsAsIcontact::Subscription.contacts(:listId => id)
end

#welcomeMessageObject

The welcome message pointed to by the welcomeMessageId.



20
21
22
23
# File 'lib/acts_as_icontact/resources/list.rb', line 20

def welcomeMessage
  return nil unless welcomeMessageId
  ActsAsIcontact::Message.find(welcomeMessageId)
end