Class: EmailDirect::Subscriber
- Inherits:
-
Object
- Object
- EmailDirect::Subscriber
- Defined in:
- lib/emaildirect/subscriber.rb
Overview
Represents a subscriber and associated functionality
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
Class Method Summary collapse
- .active(options = {}) ⇒ Object
- .bounces(options = {}) ⇒ Object
- .complaints(options = {}) ⇒ Object
- .create(email, options = {}) ⇒ Object
- .removes(options = {}) ⇒ Object
Instance Method Summary collapse
- #change_email(new_email) ⇒ Object
- #delete ⇒ Object
- #details ⇒ Object
- #history ⇒ Object
-
#initialize(email) ⇒ Subscriber
constructor
A new instance of Subscriber.
- #properties ⇒ Object
- #remove ⇒ Object
- #update(options) ⇒ Object
- #update_custom_field(attribute, value) ⇒ Object
- #update_custom_fields(attributes) ⇒ Object
Constructor Details
#initialize(email) ⇒ Subscriber
Returns a new instance of Subscriber.
46 47 48 |
# File 'lib/emaildirect/subscriber.rb', line 46 def initialize(email) @email = email end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
44 45 46 |
# File 'lib/emaildirect/subscriber.rb', line 44 def email @email end |
Class Method Details
.active(options = {}) ⇒ Object
8 9 10 11 |
# File 'lib/emaildirect/subscriber.rb', line 8 def active( = {}) response = EmailDirect.get '/Subscribers', :query => Hashie::Mash.new(response) end |
.bounces(options = {}) ⇒ Object
18 19 20 21 |
# File 'lib/emaildirect/subscriber.rb', line 18 def bounces( = {}) response = EmailDirect.get '/Subscribers/Bounces', :query => Hashie::Mash.new(response) end |
.complaints(options = {}) ⇒ Object
23 24 25 26 |
# File 'lib/emaildirect/subscriber.rb', line 23 def complaints( = {}) response = EmailDirect.get '/Subscribers/Complaints', :query => Hashie::Mash.new(response) end |
.create(email, options = {}) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/emaildirect/subscriber.rb', line 28 def create(email, = {}) .merge! :EmailAddress => email self.convert_custom_fields response = EmailDirect.post '/Subscribers', :body => .to_json Hashie::Mash.new(response) end |
.removes(options = {}) ⇒ Object
13 14 15 16 |
# File 'lib/emaildirect/subscriber.rb', line 13 def removes( = {}) response = EmailDirect.get '/Subscribers/Removes', :query => Hashie::Mash.new(response) end |
Instance Method Details
#change_email(new_email) ⇒ Object
91 92 93 94 95 |
# File 'lib/emaildirect/subscriber.rb', line 91 def change_email(new_email) = { :EmailAddress => new_email } response = EmailDirect.post uri_for('ChangeEmail'), :body => .to_json Hashie::Mash.new(response) end |
#delete ⇒ Object
80 81 82 83 |
# File 'lib/emaildirect/subscriber.rb', line 80 def delete response = EmailDirect.delete uri_for, {} Hashie::Mash.new(response) end |
#details ⇒ Object
50 51 52 53 |
# File 'lib/emaildirect/subscriber.rb', line 50 def details response = get Hashie::Mash.new(response) end |
#history ⇒ Object
60 61 62 63 |
# File 'lib/emaildirect/subscriber.rb', line 60 def history response = get 'History' Hashie::Mash.new(response) end |
#properties ⇒ Object
55 56 57 58 |
# File 'lib/emaildirect/subscriber.rb', line 55 def properties response = get 'Properties' Hashie::Mash.new(response) end |
#remove ⇒ Object
85 86 87 88 89 |
# File 'lib/emaildirect/subscriber.rb', line 85 def remove = { :EmailAddress => email } response = EmailDirect.post '/Subscribers/Remove', :body => .to_json Hashie::Mash.new(response) end |
#update(options) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/emaildirect/subscriber.rb', line 65 def update() .merge! :EmailAddress => email self.class.convert_custom_fields response = EmailDirect.put uri_for, :body => .to_json Hashie::Mash.new(response) end |
#update_custom_field(attribute, value) ⇒ Object
72 73 74 |
# File 'lib/emaildirect/subscriber.rb', line 72 def update_custom_field(attribute, value) self.class.create email, :CustomFields => [ { :FieldName => attribute, :Value => value } ] end |
#update_custom_fields(attributes) ⇒ Object
76 77 78 |
# File 'lib/emaildirect/subscriber.rb', line 76 def update_custom_fields(attributes) self.class.create email, :CustomFields => attributes end |