Sha256: 38f6224ef3cef96a24b2aa33a71002b7f180fd03796df23c30340ab46702d0f3

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

require 'aptible/billing'

module Aptible
  module Auth
    class Organization < Resource
      has_many :roles
      has_many :users
      has_many :invitations
      belongs_to :security_officer

      field :id
      field :name
      field :handle
      field :created_at, type: Time
      field :updated_at, type: Time
      field :primary_phone
      field :emergency_phone
      field :city
      field :state
      field :zip
      field :address
      field :security_alert_email
      field :ops_alert_email
      field :security_officer_id

      def billing_detail
        @billing_detail ||= Aptible::Billing::BillingDetail.find(
          id, token: token, headers: headers
        )
      end

      def can_manage_compliance?
        return false unless billing_detail
        %w(production pilot).include?(billing_detail.plan)
      end

      def privileged_roles
        roles.select(&:privileged?)
      end

      def accounts
        return @accounts if @accounts
        require 'aptible/api'

        accounts = Aptible::Api::Account.all(token: token, headers: headers)
        @accounts = accounts.select do |account|
          (link = account.links[:organization]) && link.href == href
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
aptible-auth-1.0.1 lib/aptible/auth/organization.rb
aptible-auth-1.0.0 lib/aptible/auth/organization.rb
aptible-auth-0.12.0 lib/aptible/auth/organization.rb
aptible-auth-0.11.15 lib/aptible/auth/organization.rb
aptible-auth-0.11.14 lib/aptible/auth/organization.rb
aptible-auth-0.11.13 lib/aptible/auth/organization.rb
aptible-auth-0.11.12 lib/aptible/auth/organization.rb