Class: TestrailRspecFormatter::APIClient
- Inherits:
-
Object
- Object
- TestrailRspecFormatter::APIClient
- Defined in:
- lib/testrail_rspec_formatter/client.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#password ⇒ Object
Returns the value of attribute password.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#get(uri) ⇒ Object
Send Get.
-
#initialize(base_url) ⇒ APIClient
constructor
A new instance of APIClient.
-
#post(uri, data) ⇒ Object
Send POST.
Constructor Details
#initialize(base_url) ⇒ APIClient
Returns a new instance of APIClient.
21 22 23 24 25 26 27 |
# File 'lib/testrail_rspec_formatter/client.rb', line 21 def initialize(base_url) if !base_url.match(/\/$/) base_url += '/' end @base_url = base_url @url = base_url + 'index.php?/api/v2/' end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
17 18 19 |
# File 'lib/testrail_rspec_formatter/client.rb', line 17 def base_url @base_url end |
#password ⇒ Object
Returns the value of attribute password.
19 20 21 |
# File 'lib/testrail_rspec_formatter/client.rb', line 19 def password @password end |
#user ⇒ Object
Returns the value of attribute user.
18 19 20 |
# File 'lib/testrail_rspec_formatter/client.rb', line 18 def user @user end |
Instance Method Details
#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)
40 41 42 |
# File 'lib/testrail_rspec_formatter/client.rb', line 40 def get(uri) _send_request('GET', uri, nil) end |
#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)
57 58 59 |
# File 'lib/testrail_rspec_formatter/client.rb', line 57 def post(uri, data) _send_request('POST', uri, data) end |