class Urbanairship::Devices::MmsNotification

Attributes

content_length[RW]
content_type[RW]
fallback_text[RW]
slide_1_text[RW]
subject[RW]
template_id[RW]
text[RW]
url[RW]

Public Class Methods

new(client: required('client')) click to toggle source
# File lib/urbanairship/devices/mms_notification.rb, line 20
def initialize(client: required('client'))
  @client = client
end

Public Instance Methods

mms_inline_template() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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