Class: Mailee::Contact
- Defined in:
- lib/mailee/active_resource.rb
Overview
The Contact class gives you default access to your contacts (all, first, create, update, destroy) plus some facilities, like searching contacts by email, keyword (a smart search), signature (name & email) and internal id.
Also, you can subscribe contacts to lists and unsubscribe. In Mailee unsubscribing a contact is radical: it will be unsubscribed from ALL lists FOREVER. House rules.
If you use mailee gem to sync a model, it will always set the internal_id to your “local” model id and then search based on it to update de remote record.
Writable attributes:
:name, :email, :internal_id, :sex, :birthday, :age, :phone, :mobile, :address, :notes, :photo, :company, :position
Class Method Summary collapse
- .find_by_email(email) ⇒ Object
- .find_by_internal_id(iid) ⇒ Object
- .search(keyword, page = 1) ⇒ Object
Instance Method Summary collapse
- #list_subscribe(list) ⇒ Object
- #list_unsubscribe(list) ⇒ Object
- #subscribe(list) ⇒ Object
- #unsubscribe(data = {}) ⇒ Object
Class Method Details
.find_by_email(email) ⇒ Object
34 35 36 |
# File 'lib/mailee/active_resource.rb', line 34 def self.find_by_email email find(:first, :params => {:email => email, :status => 'all'}) end |
.find_by_internal_id(iid) ⇒ Object
31 32 33 |
# File 'lib/mailee/active_resource.rb', line 31 def self.find_by_internal_id iid find(:first, :params => {:internal_id => iid}) end |
.search(keyword, page = 1) ⇒ Object
37 38 39 |
# File 'lib/mailee/active_resource.rb', line 37 def self.search keyword, page=1 find(:all, :params => {:page => page, :by_keyword => keyword, :status => 'all' }) end |
Instance Method Details
#list_subscribe(list) ⇒ Object
48 49 50 |
# File 'lib/mailee/active_resource.rb', line 48 def list_subscribe(list) put(:list_subscribe, :list => list) end |
#list_unsubscribe(list) ⇒ Object
51 52 53 |
# File 'lib/mailee/active_resource.rb', line 51 def list_unsubscribe(list) put(:list_unsubscribe, :list => list) end |
#subscribe(list) ⇒ Object
44 45 46 47 |
# File 'lib/mailee/active_resource.rb', line 44 def subscribe(list) print "Warning: Mailee::Contact.subscribe will be deprecated. Use Mailee::Contact.list_subscribe instead." put(:list_subscribe, :list => list) end |
#unsubscribe(data = {}) ⇒ Object
40 41 42 43 |
# File 'lib/mailee/active_resource.rb', line 40 def unsubscribe(data={}) #E.g. data --> {:reason => 'Trip to nowhere', :spam => false} put(:unsubscribe, :unsubscribe => {:reason => 'Motivo não especificado'}.merge(data)) end |