Class: Mosaic::Lyris::Record
- Defined in:
- lib/mosaic/lyris/record.rb
Instance Attribute Summary collapse
-
#demographics ⇒ Object
readonly
Returns the value of attribute demographics.
-
#doubleoptin ⇒ Object
readonly
Returns the value of attribute doubleoptin.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#joindate ⇒ Object
readonly
Returns the value of attribute joindate.
-
#list_id ⇒ Object
readonly
Returns the value of attribute list_id.
-
#proof ⇒ Object
readonly
Returns the value of attribute proof.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#statedate ⇒ Object
readonly
Returns the value of attribute statedate.
-
#trashed ⇒ Object
readonly
Returns the value of attribute trashed.
-
#trigger ⇒ Object
readonly
Returns the value of attribute trigger.
Class Method Summary collapse
- .add(email, options = {}) ⇒ Object
- .query(what, options = {}) ⇒ Object
- .update(email, options = {}) ⇒ Object
Methods inherited from Object
callback_url, configuration, configuration=, default_list_id, default_trigger_id, get_array_data, get_boolean_data, get_data, get_date_data, get_demographic_data, get_element, get_integer_data, get_integer_element, get_time_data, get_time_element, get_time_offset_data, get_xml_time_data, #initialize, load_configuration, logger, logger=, password, post, put_array_data, put_data, put_demographic_data, put_extra_data, server, site_id, #to_param, triggers
Constructor Details
This class inherits a constructor from Mosaic::Lyris::Object
Instance Attribute Details
#demographics ⇒ Object (readonly)
Returns the value of attribute demographics.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def demographics @demographics end |
#doubleoptin ⇒ Object (readonly)
Returns the value of attribute doubleoptin.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def doubleoptin @doubleoptin end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def email @email end |
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def encoding @encoding end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def id @id end |
#joindate ⇒ Object (readonly)
Returns the value of attribute joindate.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def joindate @joindate end |
#list_id ⇒ Object (readonly)
Returns the value of attribute list_id.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def list_id @list_id end |
#proof ⇒ Object (readonly)
Returns the value of attribute proof.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def proof @proof end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def state @state end |
#statedate ⇒ Object (readonly)
Returns the value of attribute statedate.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def statedate @statedate end |
#trashed ⇒ Object (readonly)
Returns the value of attribute trashed.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def trashed @trashed end |
#trigger ⇒ Object (readonly)
Returns the value of attribute trigger.
4 5 6 |
# File 'lib/mosaic/lyris/record.rb', line 4 def trigger @trigger end |
Class Method Details
.add(email, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mosaic/lyris/record.rb', line 18 def add(email, = {}) () reply = post('record', 'add') do |request| request.MLID [:list_id] if [:list_id] put_data(request, 'email', email) put_demographic_data(request, [:demographics]) put_extra_data(request, 'trigger', 'yes') if [:trigger] put_extra_data(request, 'proof', 'yes') if [:proof] put_extra_data(request, 'state', [:state]) put_extra_data(request, 'encoding', [:encoding]) put_extra_data(request, 'doubleoptin', 'yes') if [:doubleoptin] end new(.merge(:id => reply.at('/DATASET/DATA').inner_html, :email => email, :state => [:state] || 'active', :trashed => %w(bounced unsubscribed trashed).include?([:state].to_s))) end |
.query(what, options = {}) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/mosaic/lyris/record.rb', line 33 def query(what, = {}) if /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i === what query_one(what, ) else query_all(what, ) end end |
.update(email, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mosaic/lyris/record.rb', line 41 def update(email, = {}) () reply = post('record', 'update') do |request| request.MLID [:list_id] if [:list_id] put_data(request, 'email', email) put_extra_data(request, 'new_email', [:email]) put_demographic_data(request, [:demographics]) put_extra_data(request, 'trigger', 'yes') if [:trigger] put_extra_data(request, 'proof', 'yes') if [:proof] put_extra_data(request, 'state', [:state]) put_extra_data(request, 'encoding', [:encoding]) end # TODO: query full record? this is an incomplete snapshot of the updated record (ie. it only contains updated attributes/demographics) new(.merge(:id => reply.at('/DATASET/DATA').inner_html, :email => [:email] || email, :state => [:state], :trashed => [:state] && %w(bounced unsubscribed trashed).include?([:state].to_s))) end |