Class: TempoIQ::LiveRemoter

Inherits:
Object
  • Object
show all
Defined in:
lib/tempoiq/remoter/live_remoter.rb

Constant Summary collapse

BASE_HEADERS =
{
  'User-Agent' => "tempoiq-ruby/#{TempoIQ::Constants::VERSION}",
  'Accept-Encoding' => "gzip"
}

Instance Method Summary collapse

Constructor Details

#initialize(key, secret, host, port, secure) ⇒ LiveRemoter



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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

Instance Method Details

#delete(route, body = nil, headers = {}) ⇒ Object



47
48
49
50
51
# 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 = {}) ⇒ Object



29
30
31
32
33
# 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 = {}) ⇒ Object



35
36
37
38
39
# 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 = {}) ⇒ Object



41
42
43
44
45
# 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) ⇒ Object



53
54
55
# File 'lib/tempoiq/remoter/live_remoter.rb', line 53

def stub(*args)
  # Live client. No op.
end