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
33 34 35 |
# File 'lib/mailee/active_resource.rb', line 33 def self.find_by_email email find(:first, :params => {:email => email}) end |
.find_by_internal_id(iid) ⇒ Object
30 31 32 |
# File 'lib/mailee/active_resource.rb', line 30 def self.find_by_internal_id iid find(:first, :params => {:internal_id => iid}) end |
.search(keyword, page = 1) ⇒ Object
36 37 38 |
# File 'lib/mailee/active_resource.rb', line 36 def self.search keyword, page=1 find(:all, :params => {:page => page, :by_keyword => keyword }) end |
Instance Method Details
#list_subscribe(list) ⇒ Object
47 48 49 |
# File 'lib/mailee/active_resource.rb', line 47 def list_subscribe(list) put(:list_subscribe, :list => list) end |
#list_unsubscribe(list) ⇒ Object
50 51 52 |
# File 'lib/mailee/active_resource.rb', line 50 def list_unsubscribe(list) put(:list_unsubscribe, :list => list) end |
#subscribe(list) ⇒ Object
43 44 45 46 |
# File 'lib/mailee/active_resource.rb', line 43 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
39 40 41 42 |
# File 'lib/mailee/active_resource.rb', line 39 def unsubscribe(data={}) #E.g. data --> {:reason => 'Trip to nowhere', :spam => false} put(:unsubscribe, :unsubscribe => {:reason => 'Motivo não especificado'}.merge(data)) end |