module QTest::REST::API
Constants
- BASE_PATH
Attributes
token[RW]
The API
token passed in the Authorization header after successfully using the `auth` method.
Public Class Methods
included(base)
click to toggle source
# File lib/qtest/rest/api.rb, line 25 def self.included(base) base.include HTTParty end
Public Instance Methods
all(type, opts = {})
click to toggle source
# File lib/qtest/rest/api.rb, line 67 def all(type, opts = {}) self.send(methodize(type).pluralize, opts) end
auth(opts = {})
click to toggle source
Authenticate with the QTest
REST
API
using credentials.
If successful, an API
token is returned and used on future requests.
@param opts [Hash] @option username [String] qTest username @option password [String] qTest password @return [String] authorization token
# File lib/qtest/rest/api.rb, line 42 def auth(opts = {}) query = QueryBuilder.new .options(:without_api_path) .with('/api/login') .header(:content_type, 'application/x-www-form-urlencoded') .data(j_username: opts[:username]) .data(j_password: opts[:password]) .build @token = post(query, raw: true) self.class.send(:headers, 'Authorization' => @token) @token end
create(type, opts = {})
click to toggle source
# File lib/qtest/rest/api.rb, line 75 def create(type, opts = {}) self.send("create_#{methodize(type)}", opts) end
fields(opts = {})
click to toggle source
# File lib/qtest/rest/api.rb, line 58 def fields(opts = {}) query = QueryBuilder.new .project(opts[:project]) .with(:settings, opts[:type], :fields) .build get(query) end
move(type, opts = {})
click to toggle source
# File lib/qtest/rest/api.rb, line 79 def move(type, opts = {}) self.send("move_#{methodize(type)}", opts) end
unique(type, opts = {})
click to toggle source
# File lib/qtest/rest/api.rb, line 71 def unique(type, opts = {}) self.send(methodize(type), opts) end
Private Instance Methods
methodize(type)
click to toggle source
# File lib/qtest/rest/api.rb, line 85 def methodize(type) type.to_s.demodulize.underscore end