Sha256: 2fef76ebebe40581ddb896a97171565f195e2821f4fa632a0262eb27e97135f1

Contents?: true

Size: 1.14 KB

Versions: 35

Compression:

Stored size: 1.14 KB

Contents

module Brightbox
  # These are collaborations from the perspective of the authenticated account
  # admins. This allows creating new invites, listing, viewing, cancelling or
  # resending emails
  #
  class Collaboration < Api
    def self.require_account?; true; end

    def self.invite(email, role)
      options = { :email => email, :role => role }
      data = conn.create_collaboration(options)
      model = Fog::Compute::Brightbox::Collaboration.new(data)
      new(model)
    end

    def self.all
      conn.collaborations
    end

    def self.get(id)
      conn.collaborations.get(id)
    end

    def self.default_field_order
      [:id, :status, :role, :email, :name]
    end

    def to_s
      @id
    end

    attr_reader :id

    def attributes
      fog_model.attributes
    end

    def to_row
      row_attributes = attributes
      row_attributes[:name] = invitee_name
      row_attributes
    end

    def invitee_name
      if attributes[:user].nil?
        "-"
      else
        attributes[:user]["name"]
      end
    end

    def resend
      data = service.resend_collaboration(id)
      fog_model.merge_attributes(data)
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
brightbox-cli-2.12.0 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.11.2 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.11.1 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.11.0 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.10.0 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.9.3 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.9.2 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.9.1 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.9.0 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.8.2 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.8.1 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.8.0 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.7.1 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.7.0 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.6.0 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.5.0 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.4.1 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.4.0 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.3.4 lib/brightbox-cli/collaboration.rb
brightbox-cli-2.3.3 lib/brightbox-cli/collaboration.rb