Class: Testrail::APIClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url) ⇒ APIClient

Returns a new instance of APIClient.



167
168
169
170
171
172
# File 'lib/testrail_export/client.rb', line 167

def initialize(base_url)
  if !base_url.match(/\/$/)
    base_url += '/'
  end
  @url = base_url + 'index.php?/api/v2/'
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



165
166
167
# File 'lib/testrail_export/client.rb', line 165

def password
  @password
end

#userObject

Returns the value of attribute user.



164
165
166
# File 'lib/testrail_export/client.rb', line 164

def user
  @user
end

Instance Method Details

#send_get(uri) ⇒ 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)


185
186
187
# File 'lib/testrail_export/client.rb', line 185

def send_get(uri)
  _send_request('GET', uri, nil)
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)


202
203
204
# File 'lib/testrail_export/client.rb', line 202

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