Module: Ingenia::Api::Remote

Extended by:
Remote
Included in:
Remote
Defined in:
lib/ingenia_api/remote.rb

Constant Summary collapse

ENDPOINT =
'api.ingeniapi.com'
DEFAULT_VERSION =
2.0
MAX_ATTEMPTS =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#portObject (readonly)

Returns the value of attribute port.



11
12
13
# File 'lib/ingenia_api/remote.rb', line 11

def port
  @port
end

Instance Method Details

#delete(path, opts = {}) ⇒ Object



43
44
45
46
47
48
# File 'lib/ingenia_api/remote.rb', line 43

def delete(path, opts = {})
  handle_request do
    uri = build_uri(path, opts)
    JSON.parse( RestClient.delete uri.to_s, opts )
  end
end

#endpointObject



69
70
71
# File 'lib/ingenia_api/remote.rb', line 69

def endpoint
  @endpoint || ENDPOINT
end

#endpoint=(str) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/ingenia_api/remote.rb', line 50

def endpoint=(str)
  if str[ ':' ]
    parts = str.split(':')
    @endpoint = parts[0]
    @port     = parts[1].to_i
    return str
  end

  @endpoint = str
end

#get(path, opts = {}) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/ingenia_api/remote.rb', line 15

def get(path, opts = {})
  check_params opts

  handle_request do
    uri = build_uri(path, opts)
    JSON.parse( RestClient.get uri.to_s, :params => opts )
  end
end

#post(path, opts = {}) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/ingenia_api/remote.rb', line 25

def post(path, opts = {})
  check_params opts

  handle_request do
    uri = build_uri(path, opts)
    JSON.parse( RestClient.post uri.to_s, opts )
  end
end

#put(path, opts = {}) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/ingenia_api/remote.rb', line 34

def put(path, opts = {})
  check_params opts

  handle_request do
    uri = build_uri(path, opts)
    JSON.parse( RestClient.put uri.to_s, opts )
  end
end

#versionObject



77
78
79
# File 'lib/ingenia_api/remote.rb', line 77

def version
  @version || DEFAULT_VERSION
end

#version=(str) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/ingenia_api/remote.rb', line 61

def version=(str)
  # safety checking on version number
  if str.class == String
    raise 'Please set version to a float, eg 2.0'
  end
  @version = str
end

#version_stringObject



73
74
75
# File 'lib/ingenia_api/remote.rb', line 73

def version_string
  "v#{version.round}"
end