Class: Bugzilla::User

Inherits:
APITemplate show all
Defined in:
lib/bugzilla/user.rb

Overview

rdoc

Bugzilla::User

Bugzilla::User class is to access the Bugzilla::WebService::User API that allows you to create User Accounts and log in/out using an existing account.

Instance Method Summary collapse

Methods inherited from APITemplate

#initialize, #method_missing

Methods inherited from Skeleton

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Bugzilla::APITemplate

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bugzilla::APITemplate

Instance Method Details

#get_userinfo(user) ⇒ Object

rdoc

Bugzilla::User#get_userinfo(params)



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/bugzilla/user.rb', line 78

def get_userinfo(user)
  p = {}
  ids = []
  names = []

  if user.is_a?(Array)
    user.each do |u|
      names << u if u.is_a?(String)
      id << u if u.is_a?(Integer)
    end
  elsif user.is_a?(String)
    names << user
  elsif user.is_a?(Integer)
    ids << user
  else
    raise ArgumentError, format('Unknown type of arguments: %s', user.class)
  end

  result = get('ids' => ids, 'names' => names)

  result['users']
end

#session(user, password) ⇒ Object

rdoc

Bugzilla::User#session(user, password)

Keeps the bugzilla session during doing something in the block.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/bugzilla/user.rb', line 41

def session(user, password)
  key, fname = authentication_method

  # TODO
  # make those variables available
  host = @iface.instance_variable_get(:@xmlrpc).instance_variable_get(:@host)

  conf = load_authentication_token(fname)

  val = conf.fetch(host, nil)

  if !val.nil?
    if key == :token
      @iface.token = val
    else
      @iface.cookie = val
    end
    yield
  elsif user.nil? || password.nil?
    yield
    return
  else
    ('login' => user, 'password' => password, 'remember' => true)
    yield
  end

  conf[host] = @iface.send(key) if i[token cookie].include? key

  save_authentication_token(fname, conf)
  key
end