Class: Ey::Core::Client::Account

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/ey-core/models/account.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #to_s, #update!, #url

Instance Attribute Details

#name_prefixObject

only used on account create



39
40
41
# File 'lib/ey-core/models/account.rb', line 39

def name_prefix
  @name_prefix
end

#planObject

only used on account create



39
40
41
# File 'lib/ey-core/models/account.rb', line 39

def plan
  @plan
end

Instance Method Details

#cancel!(params = {}) ⇒ Object



41
42
43
44
# File 'lib/ey-core/models/account.rb', line 41

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

#save!Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ey-core/models/account.rb', line 46

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. if self.
  params["account"]["type"]       = self.type       if self.type

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