Class: Urbanairship::Devices::EmailNotification
- Inherits:
-
Object
- Object
- Urbanairship::Devices::EmailNotification
- Defined in:
- lib/urbanairship/devices/email_notification.rb
Constant Summary
Constants included from Common
Instance Attribute Summary collapse
-
#bcc ⇒ Object
Returns the value of attribute bcc.
-
#bypass_opt_in_level ⇒ Object
Returns the value of attribute bypass_opt_in_level.
-
#click_tracking ⇒ Object
Returns the value of attribute click_tracking.
-
#html_body ⇒ Object
Returns the value of attribute html_body.
-
#message_type ⇒ Object
Returns the value of attribute message_type.
-
#open_tracking ⇒ Object
Returns the value of attribute open_tracking.
-
#plaintext_body ⇒ Object
Returns the value of attribute plaintext_body.
-
#reply_to ⇒ Object
Returns the value of attribute reply_to.
-
#sender_address ⇒ Object
Returns the value of attribute sender_address.
-
#sender_name ⇒ Object
Returns the value of attribute sender_name.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#template_id ⇒ Object
Returns the value of attribute template_id.
-
#variable_details ⇒ Object
Returns the value of attribute variable_details.
Instance Method Summary collapse
- #define_fields ⇒ Object
- #define_template_object ⇒ Object
- #email_override ⇒ Object
- #email_with_inline_template ⇒ Object
-
#initialize(client: required('client')) ⇒ EmailNotification
constructor
A new instance of EmailNotification.
Methods included from Loggable
create_logger, logger, #logger
Methods included from Common
#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper
Constructor Details
#initialize(client: required('client')) ⇒ EmailNotification
Returns a new instance of EmailNotification.
23 24 25 |
# File 'lib/urbanairship/devices/email_notification.rb', line 23 def initialize(client: required('client')) @client = client end |
Instance Attribute Details
#bcc ⇒ Object
Returns the value of attribute bcc.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def bcc @bcc end |
#bypass_opt_in_level ⇒ Object
Returns the value of attribute bypass_opt_in_level.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def bypass_opt_in_level @bypass_opt_in_level end |
#click_tracking ⇒ Object
Returns the value of attribute click_tracking.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def click_tracking @click_tracking end |
#html_body ⇒ Object
Returns the value of attribute html_body.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def html_body @html_body end |
#message_type ⇒ Object
Returns the value of attribute message_type.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def @message_type end |
#open_tracking ⇒ Object
Returns the value of attribute open_tracking.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def open_tracking @open_tracking end |
#plaintext_body ⇒ Object
Returns the value of attribute plaintext_body.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def plaintext_body @plaintext_body end |
#reply_to ⇒ Object
Returns the value of attribute reply_to.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def reply_to @reply_to end |
#sender_address ⇒ Object
Returns the value of attribute sender_address.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def sender_address @sender_address end |
#sender_name ⇒ Object
Returns the value of attribute sender_name.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def sender_name @sender_name end |
#subject ⇒ Object
Returns the value of attribute subject.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def subject @subject end |
#template_id ⇒ Object
Returns the value of attribute template_id.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def template_id @template_id end |
#variable_details ⇒ Object
Returns the value of attribute variable_details.
9 10 11 |
# File 'lib/urbanairship/devices/email_notification.rb', line 9 def variable_details @variable_details end |
Instance Method Details
#define_fields ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/urbanairship/devices/email_notification.rb', line 81 def define_fields if subject && plaintext_body { subject: subject, plaintext_body: plaintext_body } end end |
#define_template_object ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/urbanairship/devices/email_notification.rb', line 72 def define_template_object fail ArgumentError, 'Must choose between template_id or fields object' if template_id && plaintext_body && subject template_portion = { template_id: template_id, fields: define_fields, variable_details: variable_details }.delete_if {|key, value| value.nil?} end |
#email_override ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/urbanairship/devices/email_notification.rb', line 27 def email_override fail ArgumentError, 'message_type is needed for email override' if @message_type.nil? fail ArgumentError, 'plaintext_body is needed for email override' if @plaintext_body.nil? fail ArgumentError, 'reply_to is needed for email override' if @reply_to.nil? fail ArgumentError, 'sender_address is needed for email override' if @sender_address.nil? fail ArgumentError, 'sender_name is needed for email override' if @sender_name.nil? fail ArgumentError, 'subject is needed for email override' if @subject.nil? override = { bcc: bcc, bypass_opt_in_level: bypass_opt_in_level, click_tracking: click_tracking, html_body: html_body, message_type: , open_tracking: open_tracking, plaintext_body: plaintext_body, reply_to: reply_to, sender_address: sender_address, sender_name: sender_name, subject: subject }.delete_if {|key, value| value.nil?} #this removes the nil key value pairs {'email': override} end |
#email_with_inline_template ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/urbanairship/devices/email_notification.rb', line 52 def email_with_inline_template fail ArgumentError, 'message_type is needed for email with inline template' if @message_type.nil? fail ArgumentError, 'reply_to is needed for email with inline template' if @reply_to.nil? fail ArgumentError, 'sender_address is needed for email with inline template' if @sender_address.nil? fail ArgumentError, 'sender_name is needed for email with inline template' if @sender_name.nil? inline_template = { bcc: bcc, click_tracking: click_tracking, message_type: , open_tracking: open_tracking, reply_to: reply_to, sender_address: sender_address, sender_name: sender_name, template: define_template_object }.delete_if {|key, value| value.nil?} #this removes the nil key value pairs {'email': inline_template} end |