Class: Mosaic::Lyris::Trigger
- Defined in:
- lib/mosaic/lyris/trigger.rb
Instance Attribute Summary collapse
-
#add ⇒ Object
readonly
Returns the value of attribute add.
-
#clickthru ⇒ Object
readonly
Returns the value of attribute clickthru.
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#from_email ⇒ Object
readonly
Returns the value of attribute from_email.
-
#from_name ⇒ Object
readonly
Returns the value of attribute from_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#message_text ⇒ Object
readonly
Returns the value of attribute message_text.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#not_sent ⇒ Object
readonly
Returns the value of attribute not_sent.
-
#recipients_data ⇒ Object
readonly
Returns the value of attribute recipients_data.
-
#sent ⇒ Object
readonly
Returns the value of attribute sent.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#total_opened ⇒ Object
readonly
Returns the value of attribute total_opened.
-
#total_sent ⇒ Object
readonly
Returns the value of attribute total_sent.
-
#unique_bounced ⇒ Object
readonly
Returns the value of attribute unique_bounced.
-
#unique_click ⇒ Object
readonly
Returns the value of attribute unique_click.
-
#unique_opened ⇒ Object
readonly
Returns the value of attribute unique_opened.
-
#unique_unsubscribed ⇒ Object
readonly
Returns the value of attribute unique_unsubscribed.
Class Method Summary collapse
- .fire(id, *recipients) ⇒ Object
- .lookup_trigger(key, options = {}) ⇒ Object
- .query(what, options = {}) ⇒ Object
- .recipients_data_url(recipients_data) ⇒ Object
Instance Method Summary collapse
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
#add ⇒ Object (readonly)
Returns the value of attribute add.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def add @add end |
#clickthru ⇒ Object (readonly)
Returns the value of attribute clickthru.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def clickthru @clickthru end |
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def enabled @enabled end |
#from_email ⇒ Object (readonly)
Returns the value of attribute from_email.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def from_email @from_email end |
#from_name ⇒ Object (readonly)
Returns the value of attribute from_name.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def from_name @from_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def id @id end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def @message end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def @message_id end |
#message_text ⇒ Object (readonly)
Returns the value of attribute message_text.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def @message_text end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def name @name end |
#not_sent ⇒ Object (readonly)
Returns the value of attribute not_sent.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def not_sent @not_sent end |
#recipients_data ⇒ Object (readonly)
Returns the value of attribute recipients_data.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def recipients_data @recipients_data end |
#sent ⇒ Object (readonly)
Returns the value of attribute sent.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def sent @sent end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def subject @subject end |
#total_opened ⇒ Object (readonly)
Returns the value of attribute total_opened.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def total_opened @total_opened end |
#total_sent ⇒ Object (readonly)
Returns the value of attribute total_sent.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def total_sent @total_sent end |
#unique_bounced ⇒ Object (readonly)
Returns the value of attribute unique_bounced.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def unique_bounced @unique_bounced end |
#unique_click ⇒ Object (readonly)
Returns the value of attribute unique_click.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def unique_click @unique_click end |
#unique_opened ⇒ Object (readonly)
Returns the value of attribute unique_opened.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def unique_opened @unique_opened end |
#unique_unsubscribed ⇒ Object (readonly)
Returns the value of attribute unique_unsubscribed.
6 7 8 |
# File 'lib/mosaic/lyris/trigger.rb', line 6 def unique_unsubscribed @unique_unsubscribed end |
Class Method Details
.fire(id, *recipients) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mosaic/lyris/trigger.rb', line 28 def fire(id, *recipients) = recipients.pop if recipients.last.is_a?(Hash) list_id = [:list_id] || default_list_id id = lookup_trigger(id, :locale => .delete(:locale)) if id.is_a?(Symbol) reply = post('triggers', 'fire-trigger') do |request| request.MLID list_id if list_id put_extra_data(request, 'trigger_id', id) put_extra_data(request, 'recipients', recipients.join(',')) put_extra_data(request, 'recipients_data', recipients_data_url([:recipients_data])) put_extra_data(request, 'subject', [:subject]) put_extra_data(request, 'clickthru', 'on') if [:clickthru] put_extra_data(request, 'add', 'yes') if [:add] put_extra_data(request, 'message', [:message]) put_extra_data(request, 'message_text', [:message_text]) put_extra_data(request, 'from_email', [:from_email]) put_extra_data(request, 'from_name', [:from_name]) end sent = get_data(reply.at('/DATASET'), 'sent') || '' not_sent = get_data(reply.at('/DATASET'), 'not sent') || '' new .merge(:id => id, :not_sent => not_sent.split(','), :sent => sent.split(',')) end |
.lookup_trigger(key, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mosaic/lyris/trigger.rb', line 50 def lookup_trigger(key, = {}) locale = [:locale] || I18n.locale locale = locale.to_s key = key.to_s if triggers[locale].is_a?(Hash) && triggers[locale][key] triggers[locale][key] else triggers[key] end end |
.query(what, options = {}) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/mosaic/lyris/trigger.rb', line 61 def query(what, = {}) if what == :all query_all() else query_one(what, ) end end |
.recipients_data_url(recipients_data) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/mosaic/lyris/trigger.rb', line 69 def recipients_data_url(recipients_data) return if recipients_data.nil? return recipients_data if URI.parse(recipients_data).scheme url = URI.parse(callback_url) url.path = recipients_data url.to_s end |
Instance Method Details
#enabled? ⇒ Boolean
108 109 110 |
# File 'lib/mosaic/lyris/trigger.rb', line 108 def enabled? enabled end |