class TempoIQ::LiveRemoter
Constants
- BASE_HEADERS
Public Class Methods
new(key, secret, host, port, secure)
click to toggle source
# File lib/tempoiq/remoter/live_remoter.rb, line 13 def initialize(key, secret, host, port, secure) @key = key @secret = secret @host = host @port = port @secure = secure @http_client = HTTPClient.new @http_client.transparent_gzip_decompression = true @http_client.set_auth(nil, key, secret) if secure @http_client.ssl_config.clear_cert_store @http_client.ssl_config.set_trust_ca(TempoIQ::Constants::TRUSTED_CERT_FILE) @http_client.ssl_config.ssl_version = :TLSv1 end end
Public Instance Methods
delete(route, body = nil, headers = {})
click to toggle source
# File lib/tempoiq/remoter/live_remoter.rb, line 47 def delete(route, body = nil, headers = {}) execute_http(:delete, build_uri(route), :header => BASE_HEADERS.merge(headers), :body => body) end
get(route, body = nil, headers = {})
click to toggle source
# File lib/tempoiq/remoter/live_remoter.rb, line 29 def get(route, body = nil, headers = {}) execute_http(:get, build_uri(route), :header => BASE_HEADERS.merge(headers), :body => body) end
post(route, body = nil, headers = {})
click to toggle source
# File lib/tempoiq/remoter/live_remoter.rb, line 35 def post(route, body = nil, headers = {}) execute_http(:post, build_uri(route), :header => BASE_HEADERS.merge(headers), :body => body) end
put(route, body = nil, headers = {})
click to toggle source
# File lib/tempoiq/remoter/live_remoter.rb, line 41 def put(route, body = nil, headers = {}) execute_http(:put, build_uri(route), :header => BASE_HEADERS.merge(headers), :body => body) end
stub(*args)
click to toggle source
# File lib/tempoiq/remoter/live_remoter.rb, line 53 def stub(*args) # Live client. No op. end
Private Instance Methods
build_uri(route, query = {})
click to toggle source
# File lib/tempoiq/remoter/live_remoter.rb, line 64 def build_uri(route, query = {}) scheme = if @secure then "https" else "http" end params = nil # TODO: Generate real query params URI::HTTP.new(scheme, nil, @host, @port, nil, route, nil, params, nil) end
execute_http(method, uri, *args)
click to toggle source
# File lib/tempoiq/remoter/live_remoter.rb, line 59 def execute_http(method, uri, *args) response = @http_client.request(method, uri, *args) HttpResult.new(response.code, response.headers, response.body) end