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, #method_missing, #new_record?, #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

.baseObject

Derives from clientFolder.



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

def self.base
  ActsAsIcontact.client
end

.boolean_fieldsObject



18
19
20
# File 'lib/acts_as_icontact/resources/list.rb', line 18

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

.find_by_string(value) ⇒ Object

Searches on list name.



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

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

.required_on_createObject

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



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

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



34
35
36
37
38
# File 'lib/acts_as_icontact/resources/list.rb', line 34

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).



29
30
31
# File 'lib/acts_as_icontact/resources/list.rb', line 29

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

#welcomeMessageObject

The welcome message pointed to by the welcomeMessageId.



23
24
25
26
# File 'lib/acts_as_icontact/resources/list.rb', line 23

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