Class: TestObjectRestClient

Inherits:
Object
  • Object
show all
Defined in:
lib/test_object_rest_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ TestObjectRestClient

Returns a new instance of TestObjectRestClient.



6
7
8
9
# File 'lib/test_object_rest_client.rb', line 6

def initialize(parameters)
  @api_url = parameters[:api_url]
  @api_key = parameters[:api_key]
end

Instance Method Details

#basic_authorizationObject



19
20
21
# File 'lib/test_object_rest_client.rb', line 19

def basic_authorization
  { username: @api_key, password: '' }
end

#build_path(session_id) ⇒ Object



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

def build_path(session_id)
  @path = "#{@api_url}session/#{session_id}/test/"
end

#headersObject



23
24
25
# File 'lib/test_object_rest_client.rb', line 23

def headers
  { 'Content-Type' => 'application/json' }
end

#put_test_outcome(outcome) ⇒ Object



15
16
17
# File 'lib/test_object_rest_client.rb', line 15

def put_test_outcome(outcome)
  HTTParty.put(@path, basic_auth: basic_authorization, body: { passed: outcome }.to_json, headers: headers, debug_output: $stdout)
end