Class: TopNotify::Connection

Inherits:
Object
  • Object
show all
Includes:
Sign
Defined in:
lib/top_notify/connection.rb

Instance Method Summary collapse

Methods included from Sign

#sign

Constructor Details

#initializeConnection

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

#requestObject



25
26
27
# File 'lib/top_notify/connection.rb', line 25

def request
  @request
end

#uriObject



21
22
23
# File 'lib/top_notify/connection.rb', line 21

def uri
  @uri
end