Class: Bl::Users

Inherits:
Command show all
Defined in:
lib/bl/users.rb

Constant Summary

Constants inherited from Command

Command::ACTIVITY_TYPES, Command::CATEGORY_FIELDS, Command::FILE_FIELDS, Command::GIT_REPO_FIELDS, Command::ISSUES_PARAMS, Command::ISSUE_BASE_ATTRIBUTES, Command::ISSUE_FIELDS, Command::MILESTONE_FIELDS, Command::MILESTONE_PARAMS, Command::PROJECT_FIELDS, Command::PROJECT_PARAMS, Command::ROLES, Command::SPACE_DISK_USAGE, Command::SPACE_DISK_USAGE_DETAILS_FIELDS, Command::SPACE_FIELDS, Command::SPACE_NOTIFICATION_FIELDS, Command::TYPE_COLORS, Command::USER_FIELDS, Command::USER_PARAMS, Command::WATCHINGS_PARAMS, Command::WEBHOOK_FIELDS, Command::WEBHOOK_PARAMS, Command::WIKI_FIELDS

Instance Method Summary collapse

Methods included from Formatting

colorize_priority, colorize_status, colorize_type

Methods included from Requestable

client, formatter

Constructor Details

#initializeUsers

Returns a new instance of Users.



4
5
6
7
8
# File 'lib/bl/users.rb', line 4

def initialize(*)
  @config = Bl::Config.instance
  @url = 'users'
  super
end

Instance Method Details

#activities(user_id) ⇒ Object



58
59
60
61
# File 'lib/bl/users.rb', line 58

def activities(user_id)
  res = client.get("/users/#{user_id}/activities")
  res.body.map { |a| print_activity(a) }
end

#add(id, pass, name, mail_address, role_type) ⇒ Object



23
24
25
26
27
# File 'lib/bl/users.rb', line 23

def add(id, pass, name, mail_address, role_type)
  res = client.post("#{@url}", userId: id, password: pass, name: name, mailAddress: mail_address, roleType: role_type)
  puts 'user added'
  print_response(res)
end

#delete(id) ⇒ Object



38
39
40
41
42
# File 'lib/bl/users.rb', line 38

def delete(id)
  res = client.delete("#{@url}/#{id}")
  puts 'user deleted'
  print_response(res)
end

#icon(id) ⇒ Object



51
52
53
54
# File 'lib/bl/users.rb', line 51

def icon(id)
  # res = client.get("#{@url}/#{id}/icon")
  # TODO fix nil error
end

#listObject



11
12
13
14
# File 'lib/bl/users.rb', line 11

def list
  res = client.get('users')
  print_response(res)
end

#myselfObject



45
46
47
48
# File 'lib/bl/users.rb', line 45

def myself
  res = client.get("#{@url}/myself")
  print_response(res)
end

#show(id) ⇒ Object



17
18
19
20
# File 'lib/bl/users.rb', line 17

def show(id)
  res = client.get("#{@url}/#{id}")
  puts formatter.render(res.body, fields: USER_FIELDS)
end

#stars(*user_ids) ⇒ Object



65
66
67
68
69
70
# File 'lib/bl/users.rb', line 65

def stars(*user_ids)
  user_ids.each do |user_id|
    res = client.get("/users/#{user_id}/stars", options.to_h)
    res.body.map { |s| p s }
  end
end

#stars_count(*user_ids) ⇒ Object



74
75
76
77
78
# File 'lib/bl/users.rb', line 74

def stars_count(*user_ids)
  user_ids.each do |user_id|
    p client.get("/users/#{user_id}/stars/count", options.to_h).body.count
  end
end

#update(id) ⇒ Object



31
32
33
34
35
# File 'lib/bl/users.rb', line 31

def update(id)
  res = client.patch("#{@url}/#{id}", delete_class_options(options.to_h))
  puts 'user updated:'
  print_response(res)
end