Class: SmsSender::SmsApiSender
- Inherits:
-
Object
- Object
- SmsSender::SmsApiSender
- Defined in:
- lib/sms_api_sender.rb
Constant Summary collapse
- SMS_API_URL =
"https://ssl.smsapi.pl/send.do"
Instance Attribute Summary collapse
-
#eco ⇒ Object
writeonly
Sets the attribute eco.
-
#from ⇒ Object
writeonly
Sets the attribute from.
-
#login ⇒ Object
writeonly
Sets the attribute login.
-
#password ⇒ Object
writeonly
Sets the attribute password.
-
#test ⇒ Object
writeonly
Sets the attribute test.
Instance Method Summary collapse
-
#initialize(logger) ⇒ SmsApiSender
constructor
A new instance of SmsApiSender.
- #send_sms(message) ⇒ Object
Constructor Details
#initialize(logger) ⇒ SmsApiSender
Returns a new instance of SmsApiSender.
12 13 14 |
# File 'lib/sms_api_sender.rb', line 12 def initialize logger @logger = logger end |
Instance Attribute Details
#eco=(value) ⇒ Object (writeonly)
Sets the attribute eco
10 11 12 |
# File 'lib/sms_api_sender.rb', line 10 def eco=(value) @eco = value end |
#from=(value) ⇒ Object (writeonly)
Sets the attribute from
10 11 12 |
# File 'lib/sms_api_sender.rb', line 10 def from=(value) @from = value end |
#login=(value) ⇒ Object (writeonly)
Sets the attribute login
10 11 12 |
# File 'lib/sms_api_sender.rb', line 10 def login=(value) @login = value end |
#password=(value) ⇒ Object (writeonly)
Sets the attribute password
10 11 12 |
# File 'lib/sms_api_sender.rb', line 10 def password=(value) @password = value end |
#test=(value) ⇒ Object (writeonly)
Sets the attribute test
10 11 12 |
# File 'lib/sms_api_sender.rb', line 10 def test=(value) @test = value end |
Instance Method Details
#send_sms(message) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sms_api_sender.rb', line 16 def send_sms url = URI.parse(SMS_API_URL) req = Net::HTTP::Post.new(url.path) params = basic_params add_extra_params(params) req.set_form_data(params) @logger.info "Requesting sms api to send message: #{truncated_text()}" http = Net::HTTP.new(url.host, url.port) http.use_ssl = true res = http.start { |http| http.request(req) } @logger.info "Sms api request finished processing with response #{res.body}" if sms_not_sent? res raise SmsApiError.new(res.code) end end |