Sha256: 998da8311776f82aff26014f1c57d214bab2c7037d8daa36a0b5bc790dc40fe4
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require "aws-sdk" require "active_sms" require "active_sms/backend/aws/version" # ActiveSMS backend class to send sms using amazon web services class ActiveSMS::Backend::AWS < ActiveSMS::Backend::Base # To use class, you need access key from AWS. # Go to README for instructions on how to obtain them. # # @param access_key [String] AWS access key # @param secret_access_key [String] AWS secret access key # @param region [String] AWS region. Full list: https://goo.gl/Ys5XMi def initialize(access_key:, secret_access_key:, region: "us-east-1") @access_key = access_key @secret_access_key = secret_access_key @region = region end # Sends sms using amazon web services # # @phone [String] Phone number in E.164 format # @text [String] Sms text def send_sms(phone, text) resp = sns_client.publish(phone_number: phone, message: text) if resp.error.nil? && resp.message_id respond_with_status :success else respond_with_status :unknown_failure end end protected def sns_client Aws::SNS::Client.new( access_key_id: @access_key, secret_access_key: @secret_access_key, region: @region ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_sms-backend-aws-0.0.1 | lib/active_sms/backend/aws.rb |