Class: ATM::Client

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

Overview

ATM::Client client for working with Adaptavist Test Management.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/atm_ruby/client.rb', line 8

def initialize(**args)
  options = ATM.config.to_hash.merge(args)
  options.each do |key, value|
    singleton_class.class_eval { attr_accessor key }
    send("#{key}=", value)
  end
  case options[:auth_type]
  when :basic then @auth_header = set_access_token
  else raise 'Currently only supports basic authentication'
  end
end

Instance Attribute Details

#auth_headerObject

Returns the value of attribute auth_header.



6
7
8
# File 'lib/atm_ruby/client.rb', line 6

def auth_header
  @auth_header
end

Instance Method Details

#gen_auth_tokenObject



20
21
22
# File 'lib/atm_ruby/client.rb', line 20

def gen_auth_token
  (Base64.encode64(username + ':' + password)[0..-2]).to_s
end

#set_access_tokenObject



24
25
26
27
# File 'lib/atm_ruby/client.rb', line 24

def set_access_token
  { 'Authorization' => "Basic #{gen_auth_token}",
    'Content-Type' => 'application/json' }
end

#TestCaseObject



33
34
35
36
# File 'lib/atm_ruby/client.rb', line 33

def TestCase
  ATM::Services::TestCase.new(auth_header: auth_header, base_url: base_url,
                              environment: environment, project_id: project_id)
end

#TestPlanObject



29
30
31
# File 'lib/atm_ruby/client.rb', line 29

def TestPlan
  ATM::Services::TestPlan.new(auth_header: auth_header, base_url: base_url)
end

#TestRunObject



38
39
40
41
# File 'lib/atm_ruby/client.rb', line 38

def TestRun
  ATM::Services::TestRun.new(auth_header: auth_header, base_url: base_url,
                              environment: environment, test_run_id: test_run_id)    
end