Class: Gitlab::FogbugzImport::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.


10
11
12
13
14
15
16
17
18
# File 'lib/gitlab/fogbugz_import/client.rb', line 10

def initialize(options = {})
  if options[:uri] && options[:token]
    @api = ::Fogbugz::Interface.new(options)
  elsif options[:uri] && options[:email] && options[:password]
    @api = ::Fogbugz::Interface.new(options)
    @api.authenticate
    @api
  end
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api


8
9
10
# File 'lib/gitlab/fogbugz_import/client.rb', line 8

def api
  @api
end

Instance Method Details

#cases(project_id) ⇒ Object


46
47
48
49
50
51
52
# File 'lib/gitlab/fogbugz_import/client.rb', line 46

def cases(project_id)
  project_name = repo(project_id).name
  res = @api.command(:search, q: "project:'#{project_name}'", cols: 'ixPersonAssignedTo,ixPersonOpenedBy,ixPersonClosedBy,sStatus,sPriority,sCategory,fOpen,sTitle,sLatestTextSummary,dtOpened,dtClosed,dtResolved,dtLastUpdated,events')
  return [] unless res['cases']['count'].to_i > 0

  res['cases']['case']
end

#categoriesObject


54
55
56
# File 'lib/gitlab/fogbugz_import/client.rb', line 54

def categories
  @api.command(:listCategories)
end

#get_tokenObject


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

def get_token
  @api.token
end

#repo(id) ⇒ Object


42
43
44
# File 'lib/gitlab/fogbugz_import/client.rb', line 42

def repo(id)
  repos.find { |r| r.id.to_s == id.to_s }
end

#reposObject


37
38
39
40
# File 'lib/gitlab/fogbugz_import/client.rb', line 37

def repos
  res = @api.command(:listProjects)
  @repos ||= res['projects']['project'].map { |proj| FogbugzImport::Repository.new(proj) }
end

#user_mapObject


28
29
30
31
32
33
34
35
# File 'lib/gitlab/fogbugz_import/client.rb', line 28

def user_map
  users = {}
  res = @api.command(:listPeople)
  [res['people']['person']].flatten.each do |user|
    users[user['ixPerson']] = { name: user['sFullName'], email: user['sEmail'] }
  end
  users
end

#valid?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/gitlab/fogbugz_import/client.rb', line 24

def valid?
  !get_token.blank?
end