Sha256: b2a6be6f35d1cb277b1bd66d3756d162d94cfeb1b64368e6b361bded3394ff69

Contents?: true

Size: 1.36 KB

Versions: 23

Compression:

Stored size: 1.36 KB

Contents

# == Schema Information
#
# Endpoint:
#  - /v1/teams
#  - /v1/organizations/:organization_id/teams
#
#  id              :integer         not null, primary key
#  name            :string(255)
#  created_at      :datetime        not null
#  updated_at      :datetime        not null
#  organization_id :integer
#

module MnoEnterprise
  class Team < BaseResource
    
    attributes :id, :name, :organization_id
    
    #=====================================
    # Associations
    #=====================================
    belongs_to :organization, class_name: 'MnoEnterprise::Organization'
    has_many :users, class_name: 'MnoEnterprise::User'
    has_many :app_instances, class_name: 'MnoEnterprise::AppInstance'
    
    
    # Add a user to the team
    # TODO: specs
    def add_user(user)
      self.users.create(id: user.id)
    end
    
    # Remove a user from the team
    # TODO: specs
    def remove_user(user)
      self.users.destroy(id: user.id)
    end
    
    # Set the app_instance permissions of this team
    # Accept a collection of hashes or an array of ids
    # TODO: specs
    def set_access_to(collection_or_array)
      # Empty arrays do not seem to be passed in the request. Force value in this case
      list = collection_or_array.empty? ? [""] : collection_or_array
      self.put(data: { set_access_to: list })
      self.reload
      self
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
mno-enterprise-core-3.1.4 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.0.7 app/models/mno_enterprise/team.rb
mno-enterprise-core-2.0.9 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.1.3 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.0.6 app/models/mno_enterprise/team.rb
mno-enterprise-core-2.0.8 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.1.2 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.0.5 app/models/mno_enterprise/team.rb
mno-enterprise-core-2.0.7 app/models/mno_enterprise/team.rb
mno-enterprise-core-2.0.6 app/models/mno_enterprise/team.rb
mno-enterprise-core-2.0.5 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.1.1 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.0.4 app/models/mno_enterprise/team.rb
mno-enterprise-core-2.0.4 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.1.0 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.0.3 app/models/mno_enterprise/team.rb
mno-enterprise-core-2.0.3 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.0.2 app/models/mno_enterprise/team.rb
mno-enterprise-core-2.0.2 app/models/mno_enterprise/team.rb
mno-enterprise-core-3.0.1 app/models/mno_enterprise/team.rb