class Brightbox::UserCollaboration
These are collaborations from the perspective of the invited user so all that is expected is listing, getting details, accepting, rejecting and destroying them.
Public Class Methods
Source
# File lib/brightbox-cli/user_collaboration.rb, line 7 def self.all conn.user_collaborations end
Source
# File lib/brightbox-cli/user_collaboration.rb, line 37 def self.default_field_order %i[id status account role] end
Source
# File lib/brightbox-cli/user_collaboration.rb, line 11 def self.get(id) conn.user_collaborations.get(id) end
Source
# File lib/brightbox-cli/user_collaboration.rb, line 25 def self.get_for_account(account_id) collaborations = conn.user_collaborations open_collaborations = collaborations.select { |col| %w[pending accepted].include?(col.status) } collaboration = open_collaborations.find do |col| col.account_id == account_id end return unless collaboration new(collaboration) end
This returns the OPEN collaboration based on an account ID to work in with the UI.
@todo Ensure filtering works when many collaborations exist between
accounts, and correct states are honoured.
@param [String] account_id The identifier of the account @return [Brightbox::UserCollaboration] if a valid collaboration is found @return [NilClass] if no collaboration exists for account
Public Instance Methods
Source
# File lib/brightbox-cli/user_collaboration.rb, line 46 def accept fog_model.accept end
Accepts the collaboration request
Source
# File lib/brightbox-cli/user_collaboration.rb, line 55 def destroy fog_model.destroy end
Source
# File lib/brightbox-cli/user_collaboration.rb, line 51 def reject fog_model.reject end
Rejects the collaboration request
Source
# File lib/brightbox-cli/user_collaboration.rb, line 61 def remove if status == "pending" reject else destroy end end
“removes” the invite by either rejecting or ending it based on the state of the collaboration
Source
# File lib/brightbox-cli/user_collaboration.rb, line 69 def to_row row_attributes = attributes row_attributes[:account] = attributes[:account]["id"] row_attributes.to_h end