Class: YuiRestClient::Http::VersionController

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

Instance Method Summary collapse

Constructor Details

#initialize(host:, port:) ⇒ VersionController

Returns a new instance of VersionController.



6
7
8
9
10
11
# File 'lib/yui_rest_client/http/version_controller.rb', line 6

def initialize(host:, port:)
  @host = host
  @port = port
  @timeout = YuiRestClient.timeout
  @interval = YuiRestClient.interval
end

Instance Method Details

#api_versionObject

Gets server api version, so one could compare compatibility and detect if newer version was deployed

Returns:

  • server side REST API version



16
17
18
19
20
21
22
23
# File 'lib/yui_rest_client/http/version_controller.rb', line 16

def api_version
  Wait.until(timeout: @timeout, interval: @interval) do
    res = HttpClient.http_get(HttpClient.compose_uri(@host, @port, '/version'))
    raise Error::YuiRestClientError unless res.is_a?(Net::HTTPOK)

    JSON.parse(res.body)['api_version']
  end
end