Sha256: a1380ea3296dba3c67fd6babd11043c89e814e1d89d658883d6fd76e7c4732ed

Contents?: true

Size: 1.24 KB

Versions: 27

Compression:

Stored size: 1.24 KB

Contents

class Agilibox::SMS::Strategies::AmazonSNS < Agilibox::SMS::Strategies::Base
  class << self
    attr_writer :sns_region

    def sns_region
      @sns_region ||= (ENV["SNS_REGION"] || ENV["AWS_REGION"])
    end

    attr_writer :sns_access_key_id

    def sns_access_key_id
      @sns_access_key_id ||= (ENV["SNS_ACCESS_KEY_ID"] || ENV["AWS_ACCESS_KEY_ID"])
    end

    attr_writer :sns_secret_access_key

    def sns_secret_access_key
      @sns_secret_access_key ||= (ENV["SNS_SECRET_ACCESS_KEY"] || ENV["AWS_SECRET_ACCESS_KEY"])
    end
  end # class << self

  def client
    @client ||= Aws::SNS::Client.new(
      :region            => self.class.sns_region,
      :access_key_id     => self.class.sns_access_key_id,
      :secret_access_key => self.class.sns_secret_access_key,
    )
  end

  def call
    from = data[:from] || Agilibox::SMS.default_from

    client.publish(
      :phone_number       => data[:to],
      :message            => data[:body],
      :message_attributes => {
        "AWS.SNS.SMS.SenderID" => {
          :data_type    => "String",
          :string_value => from,
        },
        "AWS.SNS.SMS.SMSType"  => {
          :data_type    => "String",
          :string_value => "Transactional",
        },
      },
    )
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
agilibox-2.0.0 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.11.0 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.10.5 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.10.2 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.10.1 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.10.0 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.20 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.19 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.18 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.17 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.16 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.15 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.14 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.13 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.12 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.11 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.10 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.9 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.8 app/sms/agilibox/sms/strategies/amazon_sns.rb
agilibox-1.9.7 app/sms/agilibox/sms/strategies/amazon_sns.rb