Sha256: 7cbd0a8619c1b27614be15f896c1c264b30c8e860df978354bbb905f1753fe66

Contents?: true

Size: 1.77 KB

Versions: 14

Compression:

Stored size: 1.77 KB

Contents

class Ey::Core::Client::Account < Ey::Core::Model
  extend Ey::Core::Associations

  identity :id

  attribute :cancelled_at, type: :time
  attribute :created_at, type: :time
  attribute :emergency_contact
  attribute :fraudulent
  attribute :legacy_id
  attribute :name
  attribute :plan_type
  attribute :signup_via
  attribute :support_plan
  attribute :type
  attribute :updated_at, type: :time

  has_many :addresses
  has_many :applications
  has_many :deis_clusters
  has_many :environments
  has_many :features
  has_many :projects
  has_many :providers
  has_many :addons
  has_many :users
  has_many :owners, key: :users
  has_many :ssl_certificates
  has_many :referrals, key: :account_referrals
  has_many :costs
  has_many :memberships

  has_one :cancellation, assoc_name: 'account_cancellation', collection: :account_cancellations
  has_one :account_trial
  has_one :support_trial

  assoc_writer :owner

  attr_accessor :name_prefix, :plan  #only used on account create

  def cancel!(params = {})
    result = self.connection.cancel_account(self.id, params[:requested_by].id).body
    Ey::Core::Client::AccountCancellation.new(result["cancellation"])
  end

  def save!
    requires_one :name, :name_prefix

    params = {
      "account" => {
        "plan" => self.plan || "standard-20140130",
      },
      "owner" => self.owner_id,
    }

    if self.name
      params["account"]["name"] = self.name
    elsif self.name_prefix
      params["account"]["name_prefix"] = self.name_prefix
    end

    params["account"]["signup_via"] = self.signup_via if self.signup_via
    params["account"]["type"]       = self.type       if self.type

    if new_record?
      merge_attributes(self.connection.create_account(params).body["account"])
    else raise NotImplementedError # update
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ey-core-3.6.0.autoscaling1 lib/ey-core/models/account.rb
ey-core-3.5.0 lib/ey-core/models/account.rb
ey-core-3.4.4 lib/ey-core/models/account.rb
ey-core-3.4.2 lib/ey-core/models/account.rb
ey-core-3.4.1 lib/ey-core/models/account.rb
ey-core-3.4.0 lib/ey-core/models/account.rb
ey-core-3.3.1 lib/ey-core/models/account.rb
ey-core-3.3.0 lib/ey-core/models/account.rb
ey-core-3.2.6 lib/ey-core/models/account.rb
ey-core-3.2.5 lib/ey-core/models/account.rb
ey-core-3.2.4 lib/ey-core/models/account.rb
ey-core-3.2.3 lib/ey-core/models/account.rb
ey-core-3.2.2 lib/ey-core/models/account.rb
ey-core-3.2.1 lib/ey-core/models/account.rb