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(**options) ⇒ Client

Returns a new instance of Client.



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

def initialize(**options)
  options = ATM.config.to_hash.merge(options)
  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



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

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

#set_access_tokenObject



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

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

#TestCaseObject



34
35
36
37
38
39
40
41
# File 'lib/atm_ruby/client.rb', line 34

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

#TestPlanObject



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

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

#TestRunObject



43
44
45
46
47
48
49
50
# File 'lib/atm_ruby/client.rb', line 43

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