Class: SemaphoreClient::Api::User

Inherits:
Object
  • Object
show all
Defined in:
lib/semaphore_client/api/user.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ User

Returns a new instance of User.



4
5
6
# File 'lib/semaphore_client/api/user.rb', line 4

def initialize(http_client)
  @http_client = http_client
end

Instance Method Details

#attach_to_team(user_id, team_id, params = nil, options = {}) ⇒ Object



35
36
37
38
# File 'lib/semaphore_client/api/user.rb', line 35

def attach_to_team(user_id, team_id, params = nil, options = {})
  attach_to_team!(user_id, team_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#attach_to_team!(user_id, team_id, params = nil, options = {}) ⇒ Object



40
41
42
43
44
# File 'lib/semaphore_client/api/user.rb', line 40

def attach_to_team!(user_id, team_id, params = nil, options = {})
  path = "/teams/#{team_id}/users/#{user_id}"

  @http_client.post(path, params, options)
end

#detach_from_team(user_id, team_id, params = nil, options = {}) ⇒ Object



48
49
50
51
# File 'lib/semaphore_client/api/user.rb', line 48

def detach_from_team(user_id, team_id, params = nil, options = {})
  detach_from_team!(user_id, team_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#detach_from_team!(user_id, team_id, params = nil, options = {}) ⇒ Object



53
54
55
56
57
# File 'lib/semaphore_client/api/user.rb', line 53

def detach_from_team!(user_id, team_id, params = nil, options = {})
  path = "/teams/#{team_id}/users/#{user_id}"

  @http_client.delete(path, params, options)
end

#list_for_org(org_id, params = nil, options = {}) ⇒ Object



9
10
11
12
# File 'lib/semaphore_client/api/user.rb', line 9

def list_for_org(org_id, params = nil, options = {})
  list_for_org!(org_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#list_for_org!(org_id, params = nil, options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/semaphore_client/api/user.rb', line 14

def list_for_org!(org_id, params = nil, options = {})
  path = "/orgs/#{org_id}/users"

  @http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::User.load(e) }
end

#list_for_project(project_id, params = nil, options = {}) ⇒ Object



61
62
63
64
# File 'lib/semaphore_client/api/user.rb', line 61

def list_for_project(project_id, params = nil, options = {})
  list_for_project!(project_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#list_for_project!(project_id, params = nil, options = {}) ⇒ Object



66
67
68
69
70
# File 'lib/semaphore_client/api/user.rb', line 66

def list_for_project!(project_id, params = nil, options = {})
  path = "/projects/#{project_id}/users"

  @http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::User.load(e) }
end

#list_for_team(team_id, params = nil, options = {}) ⇒ Object



22
23
24
25
# File 'lib/semaphore_client/api/user.rb', line 22

def list_for_team(team_id, params = nil, options = {})
  list_for_team!(team_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#list_for_team!(team_id, params = nil, options = {}) ⇒ Object



27
28
29
30
31
# File 'lib/semaphore_client/api/user.rb', line 27

def list_for_team!(team_id, params = nil, options = {})
  path = "/teams/#{team_id}/users"

  @http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::User.load(e) }
end