Class: Sently::Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/sently/sender.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Sender

Returns a new instance of Sender.



5
6
7
8
9
# File 'lib/sently/sender.rb', line 5

def initialize(options = {})
  [:protocol, :host, :port, :secure, :http_open_timeout, :http_read_timeout, :username, :password].each do |option|
    instance_variable_set("@#{option}", options[option])
  end
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



3
4
5
# File 'lib/sently/sender.rb', line 3

def host
  @host
end

#http_open_timeoutObject (readonly)

Returns the value of attribute http_open_timeout.



3
4
5
# File 'lib/sently/sender.rb', line 3

def http_open_timeout
  @http_open_timeout
end

#http_read_timeoutObject (readonly)

Returns the value of attribute http_read_timeout.



3
4
5
# File 'lib/sently/sender.rb', line 3

def http_read_timeout
  @http_read_timeout
end

#passwordObject (readonly)

Returns the value of attribute password.



3
4
5
# File 'lib/sently/sender.rb', line 3

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



3
4
5
# File 'lib/sently/sender.rb', line 3

def port
  @port
end

#protocolObject (readonly)

Returns the value of attribute protocol.



3
4
5
# File 'lib/sently/sender.rb', line 3

def protocol
  @protocol
end

#secureObject (readonly)

Returns the value of attribute secure.



3
4
5
# File 'lib/sently/sender.rb', line 3

def secure
  @secure
end

#usernameObject (readonly)

Returns the value of attribute username.



3
4
5
# File 'lib/sently/sender.rb', line 3

def username
  @username
end

Instance Method Details

#get(uri, additional_headers = {}) ⇒ Object

response = http.post(data) end



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sently/sender.rb', line 22

def get(uri, additional_headers = {})
  http  = RestClient::Resource.new(
            url(uri),
            :timeout => http_read_timeout,
            :open_timeout => http_open_timeout
          )
  headers = { :username => username, :password => password }

  p = { :params => headers.merge(additional_headers) }

  response = http.get p
end