Class: ET::Subscriber
- Inherits:
-
CUDSupport
- Object
- BaseObject
- GetSupport
- CUDSupport
- ET::Subscriber
- Defined in:
- lib/exact-target-api/subscriber.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Attributes inherited from GetSupport
Attributes inherited from BaseObject
#client, #endpoint, #lastRequestID, #obj, #props
Instance Method Summary collapse
- #create(params = {}) ⇒ Object
- #find(email) ⇒ Object
-
#initialize(client, list_id = nil) ⇒ Subscriber
constructor
A new instance of Subscriber.
- #update(params) ⇒ Object
Methods inherited from CUDSupport
Methods inherited from GetSupport
Methods inherited from BaseObject
#stringify_keys!, #symbolize_keys!
Constructor Details
#initialize(client, list_id = nil) ⇒ Subscriber
Returns a new instance of Subscriber.
5 6 7 8 9 10 |
# File 'lib/exact-target-api/subscriber.rb', line 5 def initialize(client, list_id = nil) super() @client = client @list_id = list_id @obj = 'Subscriber' end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/exact-target-api/subscriber.rb', line 3 def code @code end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
3 4 5 |
# File 'lib/exact-target-api/subscriber.rb', line 3 def email @email end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/exact-target-api/subscriber.rb', line 3 def end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
3 4 5 |
# File 'lib/exact-target-api/subscriber.rb', line 3 def results @results end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/exact-target-api/subscriber.rb', line 3 def status @status end |
Instance Method Details
#create(params = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/exact-target-api/subscriber.rb', line 12 def create(params = {}) stringify_keys!(params) email = params.delete('email') raise("Please provide email") if email.blank? list_id = if params['list'] params.delete('list').id elsif params['list_id'] params.delete('list_id') elsif @list_id @list_id end props = {'EmailAddress' => email} props['SubscriberKey'] = if params['SubscriberKey'] params.delete('SubscriberKey') else email end props['Lists'] = [{'ID' => list_id.to_s}] if list_id if params.count > 0 props['Attributes'] = params.map do |k, v| {'Name' => k.to_s, 'Value' => v} end end res = post(props) if assign_values(res) @email = email @list_id = list_id end self end |
#find(email) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/exact-target-api/subscriber.rb', line 50 def find(email) @email = email props = ["SubscriberKey", "EmailAddress", "Status"] filter = {'Property' => 'SubscriberKey', 'SimpleOperator' => 'equals', 'Value' => email} res = get(props, filter) if assign_values(res) @email = email end self end |
#update(params) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/exact-target-api/subscriber.rb', line 64 def update(params) params.merge!('EmailAddress' => @email) # TODO ... end |