Module: Chimpactions::Subscriber::ClassMethods
- Defined in:
- lib/chimpactions/subscriber.rb
Overview
listSubscribe(string apikey, string id, string email_address, array merge_vars, string email_type, bool double_optin, bool update_existing, bool replace_interests, bool send_welcome)
Subscribe the provided email to a list.
listUnsubscribe(string apikey, string id, string email_address, boolean delete_member, boolean send_goodbye, boolean send_notify)
Unsubscribe the given email address from the list
Instance Method Summary collapse
-
#add_to(list, opts = {}) ⇒ Object
Add the Subscriber to the specified list.
- #chimpactions ⇒ Object
- #merge_vars(hash = Chimpactions.merge_map) ⇒ Object
-
#move_to(list) ⇒ Object
Remove Subscriber from all lists in the account and add to the specified List.
-
#on_list?(list, opts = {}) ⇒ Boolean
Check if this Subscriber is on the specified list.
-
#remove_from(list, opts = {}) ⇒ Object
Remove the Subscriber from the specified list.
-
#send_response_email(list, title) ⇒ Object
Send the specified MailChimp pre-defined “Response Email” to this Subscriber.
-
#subscribed?(list, opts = {}) ⇒ Boolean
Check if this Subscriber is ‘subscribed’ to the list.
Instance Method Details
#add_to(list, opts = {}) ⇒ Object
Add the Subscriber to the specified list.
32 33 34 35 36 37 38 |
# File 'lib/chimpactions/subscriber.rb', line 32 def add_to(list, opts={}) list = validate_list(list) list.socket.listSubscribe({:id => list.id, :email_address => self.email, :merge_vars => self.merge_vars, :send_welcome => Chimpactions.default_send_welcome, :double_optin => Chimpactions.default_double_optin, :update_existing => Chimpactions.default_update_existing}.merge opts) == "true" end |
#chimpactions ⇒ Object
26 27 28 |
# File 'lib/chimpactions/subscriber.rb', line 26 def chimpactions Chimpactions.actions.each{|action| action.execute(self)} end |
#merge_vars(hash = Chimpactions.merge_map) ⇒ Object
89 90 91 |
# File 'lib/chimpactions/subscriber.rb', line 89 def merge_vars(hash = Chimpactions.merge_map) collect_merge_vars(hash) end |
#move_to(list) ⇒ Object
Remove Subscriber from all lists in the account and add to the specified List
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/chimpactions/subscriber.rb', line 42 def move_to(list) list = validate_list(list) # add to the specified list if add_to(list) == true #remove from all the others Chimpactions.available_lists.each do |l| remove_from(l) if l != list end true else false end end |
#on_list?(list, opts = {}) ⇒ Boolean
Check if this Subscriber is on the specified list.
73 74 75 76 77 |
# File 'lib/chimpactions/subscriber.rb', line 73 def on_list?(list, opts={}) list = validate_list(list) answer = list.socket.listMemberInfo({:id => list.id, :email_address => self.email}.merge opts) answer['success'] == 1 && answer['errors'] == 0 end |
#remove_from(list, opts = {}) ⇒ Object
Remove the Subscriber from the specified list.
58 59 60 61 |
# File 'lib/chimpactions/subscriber.rb', line 58 def remove_from(list, opts={}) list = validate_list(list) list.socket.listUnsubscribe({:id => list.id, :email_address => self.email}.merge opts) == "true" end |
#send_response_email(list, title) ⇒ Object
Send the specified MailChimp pre-defined “Response Email” to this Subscriber
65 66 67 68 |
# File 'lib/chimpactions/subscriber.rb', line 65 def send_response_email(list, title) list = validate_list(list) false # stub for test failure end |
#subscribed?(list, opts = {}) ⇒ Boolean
Check if this Subscriber is ‘subscribed’ to the list.
82 83 84 85 86 |
# File 'lib/chimpactions/subscriber.rb', line 82 def subscribed?(list,opts={}) list = validate_list(list) answer = list.socket.listMemberInfo({:id => list.id, :email_address => self.email}.merge opts) answer['success'] == 1 && answer['data'][0]['status'] == 'subscribed' end |