Class: VpsbClient::Api::GetCurrentTrialRequest

Inherits:
GetRequest show all
Defined in:
lib/vpsb_client/api/get_current_trial_request.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GetRequest

#run

Methods inherited from Request

#accept, #post_params, #put_params

Constructor Details

#initialize(http_client, params) ⇒ GetCurrentTrialRequest

Returns a new instance of GetCurrentTrialRequest.



4
5
6
7
# File 'lib/vpsb_client/api/get_current_trial_request.rb', line 4

def initialize(http_client, params)
  super(http_client)
  @client_hostname = params.fetch(:client_hostname)
end

Class Method Details

.trial(http_response) ⇒ Object



19
20
21
22
# File 'lib/vpsb_client/api/get_current_trial_request.rb', line 19

def self.trial(http_response)
  return nil if http_response.parsed_response.empty?
  http_response.parsed_response.first
end

.trial_id(http_response) ⇒ Object



24
25
26
27
# File 'lib/vpsb_client/api/get_current_trial_request.rb', line 24

def self.trial_id(http_response)
  t = trial(http_response)
  t ? t['id'] : nil
end

Instance Method Details

#query_paramsObject



13
14
15
16
17
# File 'lib/vpsb_client/api/get_current_trial_request.rb', line 13

def query_params
  {
    client_hostname: @client_hostname
  }
end

#url_pathObject



9
10
11
# File 'lib/vpsb_client/api/get_current_trial_request.rb', line 9

def url_path
  "/api/trials/current"
end