Class: Urbanairship::Devices::MmsNotification
- Inherits:
-
Object
- Object
- Urbanairship::Devices::MmsNotification
- Defined in:
- lib/urbanairship/devices/mms_notification.rb
Constant Summary
Constants included from Common
Instance Attribute Summary collapse
-
#content_length ⇒ Object
Returns the value of attribute content_length.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#fallback_text ⇒ Object
Returns the value of attribute fallback_text.
-
#shorten_links ⇒ Object
Returns the value of attribute shorten_links.
-
#slide_1_text ⇒ Object
Returns the value of attribute slide_1_text.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#template_id ⇒ Object
Returns the value of attribute template_id.
-
#text ⇒ Object
Returns the value of attribute text.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(client: required('client')) ⇒ MmsNotification
constructor
A new instance of MmsNotification.
- #mms_inline_template ⇒ Object
- #mms_override ⇒ Object
- #mms_template_with_id ⇒ Object
- #validate_url ⇒ Object
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')) ⇒ MmsNotification
Returns a new instance of MmsNotification.
20 21 22 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 20 def initialize(client: required('client')) @client = client end |
Instance Attribute Details
#content_length ⇒ Object
Returns the value of attribute content_length.
10 11 12 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 10 def content_length @content_length end |
#content_type ⇒ Object
Returns the value of attribute content_type.
10 11 12 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 10 def content_type @content_type end |
#fallback_text ⇒ Object
Returns the value of attribute fallback_text.
10 11 12 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 10 def fallback_text @fallback_text end |
#shorten_links ⇒ Object
Returns the value of attribute shorten_links.
10 11 12 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 10 def shorten_links @shorten_links end |
#slide_1_text ⇒ Object
Returns the value of attribute slide_1_text.
10 11 12 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 10 def @slide_1_text end |
#subject ⇒ Object
Returns the value of attribute subject.
10 11 12 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 10 def subject @subject end |
#template_id ⇒ Object
Returns the value of attribute template_id.
10 11 12 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 10 def template_id @template_id end |
#text ⇒ Object
Returns the value of attribute text.
10 11 12 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 10 def text @text end |
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 10 def url @url end |
Instance Method Details
#mms_inline_template ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 81 def mms_inline_template fail ArgumentError, 'slide_1_text text is needed for MMS with inline template' if text.nil? {"mms": { "template": { "fields": { "subject": subject, "fallback_text": fallback_text, "slide_1_text": text } }, "slides": [ { "media": { "url": url, "content_type": content_type, "content_length": content_length } } ] } } end |
#mms_override ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 30 def mms_override fail ArgumentError, 'fallback_text is needed for MMS override' if fallback_text.nil? fail ArgumentError, 'content_length is needed for MMS override' if content_length.nil? fail ArgumentError, 'content_type is needed for MMS override' if content_type.nil? fail ArgumentError, 'url is needed for MMS override' if url.nil? validate_url override = {"mms": { "subject": subject, "fallback_text": fallback_text, "shorten_links": shorten_links, "slides": [ { "text": text, "media": { "url": url, "content_type": content_type, "content_length": content_length } } ] } } override end |
#mms_template_with_id ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 57 def mms_template_with_id fail ArgumentError, 'content_length is needed for MMS Inline Template with ID' if content_length.nil? fail ArgumentError, 'content_type is needed for MMS Inline Template with ID' if content_type.nil? fail ArgumentError, 'url is needed for MMS Inline Template with ID' if url.nil? fail ArgumentError, 'template_id is needed for MMS Inline Template with ID' if template_id.nil? {"mms": { "template": { "template_id": template_id }, "shorten_links": true, "slides": [ { "media": { "url": url, "content_type": content_type, "content_length": content_length } } ] } } end |
#validate_url ⇒ Object
24 25 26 27 28 |
# File 'lib/urbanairship/devices/mms_notification.rb', line 24 def validate_url unless ['.jpg', '.gif', '.png', 'jpeg'].include?(@url[-4..-1]) fail ArgumentError, 'url must end in .gif, .jpg, .png, or .jpeg' end end |