Module: SmsKit::HTTP
- Included in:
- Provider
- Defined in:
- lib/sms_kit/http.rb
Constant Summary collapse
- USER_AGENT =
"SmsKit/#{VERSION} (https://rubygems.org/gems/sms_kit)"
Instance Method Summary collapse
Instance Method Details
#connection ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sms_kit/http.rb', line 20 def connection if 'https' != uri.scheme warn "[SmsKit] Provider '#{self.class.name}' is using an unencrypted connection: #{uri}" end @conn ||= Faraday.new "#{uri.scheme}://#{uri.host}" do |f| f.headers[:user_agent] = USER_AGENT f.response :logger, SmsKit.logger f.adapter Faraday.default_adapter yield f if block_given? end end |
#get(data) ⇒ Object
16 17 18 |
# File 'lib/sms_kit/http.rb', line 16 def get data connection.get uri.path, data end |
#post(data) ⇒ Object
12 13 14 |
# File 'lib/sms_kit/http.rb', line 12 def post data connection.post uri.path, data end |
#uri ⇒ Object
8 9 10 |
# File 'lib/sms_kit/http.rb', line 8 def uri @uri ||= URI.parse self.class.const_get 'HTTP_ENDPOINT' end |