Class: TestRail::Client
- Inherits:
-
Object
- Object
- TestRail::Client
- Includes:
- API
- Defined in:
- lib/testrail_api/api.rb,
lib/testrail_api/client.rb,
lib/testrail_api/client/runs.rb,
lib/testrail_api/client/cases.rb,
lib/testrail_api/client/plans.rb,
lib/testrail_api/client/tests.rb,
lib/testrail_api/client/users.rb,
lib/testrail_api/client/suites.rb,
lib/testrail_api/client/results.rb,
lib/testrail_api/client/projects.rb,
lib/testrail_api/client/sections.rb,
lib/testrail_api/client/statuses.rb,
lib/testrail_api/client/case_types.rb,
lib/testrail_api/client/milestones.rb,
lib/testrail_api/client/priorities.rb,
lib/testrail_api/client/case_fields.rb,
lib/testrail_api/client/result_fields.rb
Defined Under Namespace
Modules: API, CaseFields, CaseTypes, Cases, Milestones, Plans, Priorities, Projects, ResultFields, Results, Runs, Sections, Statuses, Suites, Tests, Users
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #api_endpoint ⇒ Object
- #credentials ⇒ Object
- #get(path, opts = {}) ⇒ Object
-
#initialize(server, email, password, secure: true, verbose: false) ⇒ Client
constructor
A new instance of Client.
- #post(path, opts = {}) ⇒ Object
- #request(method, path, opts = {}) ⇒ Object
- #scheme ⇒ Object
- #user_agent ⇒ Object
- #verbose ⇒ Object
- #verbose=(bool) ⇒ Object
Methods included from Users
Methods included from Tests
#test, #test_by_title, #test_id_by_title, #tests
Methods included from Suites
#add_suite, #suite, #suite_by_name, #suites, #suites_by_project_name
Methods included from Statuses
Methods included from Sections
#add_section, #delete_section, #section, #section_by_name, #sections, #update_section
Methods included from Runs
#add_run, #close_run, #delete_run, #run, #runs, #update_run
Methods included from Results
#add_result, #add_result_for_case, #add_results, #add_results_for_cases, #results, #results_for_case, #results_for_run
Methods included from Projects
#project, #project_by_name, #projects, #projects_ids
Methods included from Priorities
Methods included from Cases
#add_case, #case, #cases, #cases_by_title, #cases_ids, #delete_case, #update_case
Methods included from CaseTypes
Methods included from CaseFields
Constructor Details
#initialize(server, email, password, secure: true, verbose: false) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/testrail_api/client.rb', line 18 def initialize(server, email, password, secure: true, verbose: false) # required @server = server @email = email @password = password # optional @secure = secure self.verbose = verbose end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
11 12 13 |
# File 'lib/testrail_api/client.rb', line 11 def email @email end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
11 12 13 |
# File 'lib/testrail_api/client.rb', line 11 def password @password end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
11 12 13 |
# File 'lib/testrail_api/client.rb', line 11 def server @server end |
Instance Method Details
#api_endpoint ⇒ Object
41 42 43 |
# File 'lib/testrail_api/client.rb', line 41 def api_endpoint @api_endpoint ||= File.join("#{scheme}://#{@server}", 'index.php?api/v2') end |
#credentials ⇒ Object
57 58 59 |
# File 'lib/testrail_api/client.rb', line 57 def credentials "#{@email}:#{@password}" end |
#get(path, opts = {}) ⇒ Object
49 50 51 |
# File 'lib/testrail_api/client.rb', line 49 def get(path, opts = {}) request(:get, path, opts) end |
#post(path, opts = {}) ⇒ Object
53 54 55 |
# File 'lib/testrail_api/client.rb', line 53 def post(path, opts = {}) request(:post, path, opts) end |
#request(method, path, opts = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/testrail_api/client.rb', line 61 def request(method, path, opts = {}) body = Typhoeus::Request.new( File.join(api_endpoint, path), { method: method, headers: Default::HEADERS, userpwd: credentials }.merge(opts) ).run.body JSON.parse(body) rescue JSON::ParserError body end |
#scheme ⇒ Object
37 38 39 |
# File 'lib/testrail_api/client.rb', line 37 def scheme @scheme ||= @secure ? 'https' : 'http' end |
#user_agent ⇒ Object
45 46 47 |
# File 'lib/testrail_api/client.rb', line 45 def user_agent @user_agent ||= "TestRail API v2 Gem #{TestRail::VERSION}" end |
#verbose ⇒ Object
33 34 35 |
# File 'lib/testrail_api/client.rb', line 33 def verbose Typhoeus::Config.verbose end |
#verbose=(bool) ⇒ Object
29 30 31 |
# File 'lib/testrail_api/client.rb', line 29 def verbose=(bool) Typhoeus::Config.verbose = bool end |