Class: TestRail::APIClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url) ⇒ APIClient

Returns a new instance of APIClient.



30
31
32
33
34
# File 'lib/itriagetestrail/testrail_binding.rb', line 30

def initialize(base_url)
  valid_regex = %r{/\/$/}
  base_url += '/' unless valid_regex.match(base_url)
  @url = base_url + 'index.php?/api/v2/'
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



27
28
29
# File 'lib/itriagetestrail/testrail_binding.rb', line 27

def password
  @password
end

#response_codeObject (readonly)

Returns the value of attribute response_code.



28
29
30
# File 'lib/itriagetestrail/testrail_binding.rb', line 28

def response_code
  @response_code
end

#userObject

Returns the value of attribute user.



26
27
28
# File 'lib/itriagetestrail/testrail_binding.rb', line 26

def user
  @user
end

Instance Method Details

#send_get(uri, read_cache = true) ⇒ Object

Send Get

Issues a GET request (read) against the API and returns the result (as Ruby hash).

Arguments:

uri The API method to call including parameters

(e.g. get_case/1)


47
48
49
50
# File 'lib/itriagetestrail/testrail_binding.rb', line 47

def send_get(uri, read_cache = true)
  res = read_cache(uri) if read_cache
  res || _send_request('GET', uri, nil, true)
end

#send_post(uri, data) ⇒ Object

Send POST

Issues a POST request (write) against the API and returns the result (as Ruby hash).

Arguments:

uri The API method to call including parameters

(e.g. add_case/1)

data The data to submit as part of the request (as

Ruby hash, strings must be UTF-8 encoded)


65
66
67
# File 'lib/itriagetestrail/testrail_binding.rb', line 65

def send_post(uri, data)
  _send_request('POST', uri, data)
end