class TestRail::APIClient

Attributes

password[RW]
user[RW]

Public Class Methods

new(connection_data) click to toggle source
# File lib/test_rail_integration/generator/API_client.rb, line 24
def initialize(connection_data)
  base_url = connection_data[:url]
  unless base_url.match(/\/$/)
    base_url += '/'
  end
  @url = base_url + 'index.php?/api/v2/'
  @user = connection_data[:username]
  @password = connection_data[:password]
end

Public Instance Methods

send_get(uri) click to toggle source

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)
# File lib/test_rail_integration/generator/API_client.rb, line 45
def send_get(uri)
  _send_request('GET', uri, nil)
end
send_post(uri, data) click to toggle source

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)
# File lib/test_rail_integration/generator/API_client.rb, line 62
def send_post(uri, data)
  _send_request('POST', uri, data)
end