Class: TopNotify::Connection
- Inherits:
-
Object
- Object
- TopNotify::Connection
- Includes:
- Sign
- Defined in:
- lib/top_notify/connection.rb
Instance Method Summary collapse
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
- #request ⇒ Object
- #uri ⇒ Object
Methods included from Sign
Constructor Details
#initialize ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/top_notify/connection.rb', line 10 def initialize if TopNotify.app_key.to_s.empty? || TopNotify.app_secret.to_s.empty? raise ConfigurationNotFoundError.new('You need to set app_key and app_secret first before use top_notfiy.') end @params = {:app_key => TopNotify.app_key, :timestamp => Time.now.strftime('%F %T'), :sign_method => 'md5'} @params.merge!(:sign => sign(@params)) @uri = URI.parse(TopNotify.service_url) @request = Net::HTTP::Post.new(uri.request_uri) @request.set_form_data(@params) end |
Instance Method Details
#request ⇒ Object
25 26 27 |
# File 'lib/top_notify/connection.rb', line 25 def request @request end |
#uri ⇒ Object
21 22 23 |
# File 'lib/top_notify/connection.rb', line 21 def uri @uri end |