Class: Sem::API::Orgs
Constant Summary
Constants inherited from Base
Class Method Summary collapse
- .api ⇒ Object
- .info(name) ⇒ Object
- .list ⇒ Object
- .list_admins(org_name) ⇒ Object
- .list_owners(org_name) ⇒ Object
- .list_teams(org_name) ⇒ Object
- .list_users(org_name) ⇒ Object
- .to_hash(org) ⇒ Object
Methods inherited from Base
Class Method Details
.api ⇒ Object
40 41 42 |
# File 'lib/sem/api/orgs.rb', line 40 def self.api client.orgs end |
.info(name) ⇒ Object
10 11 12 13 14 |
# File 'lib/sem/api/orgs.rb', line 10 def self.info(name) org = api.get(name) to_hash(org) end |
.list ⇒ Object
4 5 6 7 8 |
# File 'lib/sem/api/orgs.rb', line 4 def self.list orgs = api.list orgs.map { |org| to_hash(org) } end |
.list_admins(org_name) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/sem/api/orgs.rb', line 24 def self.list_admins(org_name) admin_teams = list_teams(org_name).select { |team| team[:permission] == "admin" } admins = admin_teams.map { |team| client.users.list_for_team(team[:id]) }.flatten admins.map { |admin| Sem::API::Users.to_hash(admin) } end |
.list_owners(org_name) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/sem/api/orgs.rb', line 32 def self.list_owners(org_name) owners_team = list_teams(org_name).find { |team| team[:name] == "Owners" } owners = client.users.list_for_team(owners_team[:id]) owners.map { |owner| Sem::API::Users.to_hash(owner) } end |
.list_teams(org_name) ⇒ Object
16 17 18 |
# File 'lib/sem/api/orgs.rb', line 16 def self.list_teams(org_name) Sem::API::Teams.list_for_org(org_name) end |
.list_users(org_name) ⇒ Object
20 21 22 |
# File 'lib/sem/api/orgs.rb', line 20 def self.list_users(org_name) Sem::API::Users.list_for_org(org_name) end |
.to_hash(org) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/sem/api/orgs.rb', line 44 def self.to_hash(org) { :id => org.id, :username => org.username, :created_at => org.created_at, :updated_at => org.updated_at } end |