Class: Mailee::Contact

Inherits:
Config
  • Object
show all
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

Instance Method Summary collapse

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

#subscribe(list) ⇒ Object



43
44
45
# File 'lib/mailee/active_resource.rb', line 43

def subscribe(list)
  put(:subscribe, :list => {:name => 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