Class: Keen::HTTP::Sync

Inherits:
Object
  • Object
show all
Defined in:
lib/keen/http.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_url, options = {}) ⇒ Sync

Returns a new instance of Sync.



4
5
6
7
8
9
10
11
# File 'lib/keen/http.rb', line 4

def initialize(base_url, options={})
  require 'uri'
  require 'net/https'

  uri = URI.parse(base_url)
  @http = Net::HTTP.new(uri.host, uri.port)
  options.each_pair { |key, value| @http.send "#{key}=", value }
end

Instance Method Details

#get(options) ⇒ Object



19
20
21
22
23
# File 'lib/keen/http.rb', line 19

def get(options)
  path, headers = options.values_at(
    :path, :headers)
  @http.get(path, headers)
end

#post(options) ⇒ Object



13
14
15
16
17
# File 'lib/keen/http.rb', line 13

def post(options)
  path, headers, body = options.values_at(
    :path, :headers, :body)
  @http.post(path, body, headers)
end