Class: ActiveSMS::Backend::AWS
- Inherits:
-
Base
- Object
- Base
- ActiveSMS::Backend::AWS
- Defined in:
- lib/active_sms/backend/aws.rb
Overview
ActiveSMS backend class to send sms using amazon web services
Instance Method Summary collapse
-
#initialize(access_key:, secret_access_key:, region: "us-east-1") ⇒ AWS
constructor
To use class, you need access key from AWS.
-
#send_sms(phone, text) ⇒ Object
Sends sms using amazon web services.
Constructor Details
#initialize(access_key:, secret_access_key:, region: "us-east-1") ⇒ AWS
To use class, you need access key from AWS. Go to README for instructions on how to obtain them.
13 14 15 16 17 |
# File 'lib/active_sms/backend/aws.rb', line 13 def initialize(access_key:, secret_access_key:, region: "us-east-1") @access_key = access_key @secret_access_key = secret_access_key @region = region end |
Instance Method Details
#send_sms(phone, text) ⇒ Object
Sends sms using amazon web services
23 24 25 26 27 28 29 30 31 |
# File 'lib/active_sms/backend/aws.rb', line 23 def send_sms(phone, text) resp = sns_client.publish(phone_number: phone, message: text) if resp.error.nil? && resp. respond_with_status :success else respond_with_status :unknown_failure end end |