Sha256: 8cf3c16cd38494c1811fa007c5710b697917641f3dad8a10a9b5d8090421796e

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require 'urbanairship'
require 'json'

module Urbanairship
  module Devices
    class SmsNotification
      include Urbanairship::Common
      include Urbanairship::Loggable

      attr_accessor :sms_alert,
                    :generic_alert,
                    :expiry,
                    :shorten_links,
                    :template_id

      def initialize(client: required('client'))
        @client = client
        @alert = nil
        @generic_alert = nil
        @expiry = nil
        @shorten_links = nil
        @template_id = nil
      end

      def sms_notification_override
        {
           "alert": @generic_alert,
           "sms": {
              "alert": @sms_alert,
              "expiry": @expiry,
              "shorten_links": @shorten_links
           }
        }
      end

      def sms_inline_template
        inline_template = {
          "sms": {
            "template": {}
          }
        }

        if @template_id
          inline_template[:sms][:template][:template_id] = @template_id
        end

        if @sms_alert
          inline_fields= {
            "fields": {"alert": @sms_alert}
          }
          inline_template[:sms][:template] = inline_fields
        end
        
        inline_template
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
urbanairship-5.5.1 lib/urbanairship/devices/sms_notification.rb
urbanairship-5.5.0 lib/urbanairship/devices/sms_notification.rb