Class: Sorenson::Services::Account

Inherits:
Base show all
Defined in:
lib/sorenson/services/account.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

delete_from, get_from, host, login_no_resource, parse_response, post_to, put_to, verify_account_settings

Constructor Details

#initialize(data) ⇒ Account

Returns a new instance of Account.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/sorenson/services/account.rb', line 46

def initialize(data)
  self.username                  = data['username']
  self.status                    = data['status']
  self.customer_id               = data['id']
  self.id                        = data['id']
  self.subaccount_id             = data['subaccount_id']
  self.session_id                = data['session_id']
  self.rate_plan_expiration_date = data['rate_plan_expiration_date']
  self.date_last_modified        = data['date_last_modified']
  self.           = data['last_login_time']
  self.date_retrieved            = data['date_retrieved']
  self.total_asset_count         = data['total_asset_count']
  self.token                     = data['token']
  self.id                        = data['account_id'] if data['account_id']
end

Instance Attribute Details

#customer_idObject

Returns the value of attribute customer_id.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def customer_id
  @customer_id
end

#date_last_modifiedObject

Returns the value of attribute date_last_modified.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def date_last_modified
  @date_last_modified
end

#date_retrievedObject

Returns the value of attribute date_retrieved.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def date_retrieved
  @date_retrieved
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def id
  @id
end

#last_login_timeObject

Returns the value of attribute last_login_time.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def 
  @last_login_time
end

#rate_planObject

Returns the value of attribute rate_plan.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def rate_plan
  @rate_plan
end

#rate_plan_expiration_dateObject

Returns the value of attribute rate_plan_expiration_date.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def rate_plan_expiration_date
  @rate_plan_expiration_date
end

#session_idObject

Returns the value of attribute session_id.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def session_id
  @session_id
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def status
  @status
end

#subaccount_idObject

Returns the value of attribute subaccount_id.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def subaccount_id
  @subaccount_id
end

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def token
  @token
end

#total_asset_countObject

Returns the value of attribute total_asset_count.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def total_asset_count
  @total_asset_count
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/sorenson/services/account.rb', line 4

def username
  @username
end

Class Method Details

.get_accountObject

Get Accout



17
18
19
# File 'lib/sorenson/services/account.rb', line 17

def self.
  new(get_from("/accounts/#{}"))
end

.login(username, password) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/sorenson/services/account.rb', line 8

def self.(username, password)
  data = JSON.parse((username, password))
   = Account.new(data)
  self.  = .token
  self.     = .id
  return  if .token
end

Instance Method Details

#create_subaccount(username_email, password) ⇒ Object



41
42
43
# File 'lib/sorenson/services/account.rb', line 41

def create_subaccount(username_email, password)
  Base.post_to("/subaccounts", :subaccount => {:username => username_email, :email => username_email, :password => password})
end

#empty_trashObject



33
34
35
# File 'lib/sorenson/services/account.rb', line 33

def empty_trash
  Base.post_to("/accounts/#{}/empty_trash")['status']
end

#get_subaccountsObject



37
38
39
# File 'lib/sorenson/services/account.rb', line 37

def get_subaccounts
  Base.get_from("/subaccounts")
end

#overage_actionObject



25
26
27
# File 'lib/sorenson/services/account.rb', line 25

def overage_action
  Base.get_from("/accounts/#{}/overage_action")["overage_action"]
end

#set_password(password, old_password) ⇒ Object



29
30
31
# File 'lib/sorenson/services/account.rb', line 29

def set_password(password, old_password)
  Base.put_to("/accounts/#{}", :account => {:password => password, :old_password => old_password})[:status]
end