Class: Sorenson::ThreeSixty::Account
- Inherits:
-
Base
- Object
- Base
- Sorenson::ThreeSixty::Account
show all
- Defined in:
- lib/sorenson/threesixty/account.rb
Constant Summary
Constants inherited
from Base
Base::TOKEN_SALT
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
debug=, debug?, host, #post_to, post_to, protocol, token_for, use_ssl=, use_ssl?
Constructor Details
#initialize(data, sessionId = nil) ⇒ Account
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/sorenson/threesixty/account.rb', line 80
def initialize(data, sessionId = nil)
self.sessionId = data['sessionId'] || sessionId
self.token = data['token']
self.subaccountId = data['subaccountId']
self.goto360URL = data['gotoJuiceURL']
self.gotoJuiceURL = data['gotoJuiceURL']
account = data['account']
if account
self.username = account['username']
self.status = account['status']
self.customerId = account['id']
self.id = account['id']
self.ratePlanExpirationDate = account['ratePlanExpirationDate']
self.dateLastModified = account['dateLastModified']
self.sorensonId = account['sorensonId']
self.lastLoginTime = account['lastLoginTime']
self.dateRetrieved = account['dateRetrieved']
self.totalAssetCount = getAssetCount
self.ratePlan = RatePlan.new(account['ratePlan']) if account['ratePlan']
end
end
|
Instance Attribute Details
#customerId ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def customerId
@customerId
end
|
#dateLastModified ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def dateLastModified
@dateLastModified
end
|
#dateRetrieved ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def dateRetrieved
@dateRetrieved
end
|
#goto360URL ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def goto360URL
@goto360URL
end
|
#gotoJuiceURL ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def gotoJuiceURL
@gotoJuiceURL
end
|
#id ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def id
@id
end
|
#lastLoginTime ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def lastLoginTime
@lastLoginTime
end
|
#ratePlan ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def ratePlan
@ratePlan
end
|
#ratePlanExpirationDate ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def ratePlanExpirationDate
@ratePlanExpirationDate
end
|
#sessionId ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def sessionId
@sessionId
end
|
#sorensonId ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def sorensonId
@sorensonId
end
|
#status ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def status
@status
end
|
#subaccountId ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def subaccountId
@subaccountId
end
|
#token ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def token
@token
end
|
#totalAssetCount ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def totalAssetCount
@totalAssetCount
end
|
#username ⇒ Object
6
7
8
|
# File 'lib/sorenson/threesixty/account.rb', line 6
def username
@username
end
|
Class Method Details
._login(url) ⇒ Object
10
11
12
|
# File 'lib/sorenson/threesixty/account.rb', line 10
def self._login(url)
new(post_to(url))
end
|
.activate!(username) ⇒ Object
41
42
43
|
# File 'lib/sorenson/threesixty/account.rb', line 41
def self.activate!(username)
activateAccount(username)
end
|
.activateAccount(username) ⇒ Object
36
37
38
39
|
# File 'lib/sorenson/threesixty/account.rb', line 36
def self.activateAccount(username)
data = post_to("/api/activateAccount?username=#{username}&vToken=#{token_for(username)}")
!!data['success']
end
|
.allAccounts ⇒ Object
73
74
75
|
# File 'lib/sorenson/threesixty/account.rb', line 73
def self.allAccounts
data = post_to("/api/getAllAccounts")
end
|
.createAccount(username, password, ratePlanId, activate = false) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/sorenson/threesixty/account.rb', line 54
def self.createAccount(username, password, ratePlanId, activate = false)
data = post_to("/api/createAccount?vToken=#{token_for(username)}&username=#{username}&password=#{password}&ratePlanId=#{ratePlanId}")
result = !!data['success']
if (result)
updatePasswordHack(username, password)
end
if (result && activate && activate!(username))
result = login(username, password)
end
result
end
|
.deactivate!(username) ⇒ Object
45
46
47
|
# File 'lib/sorenson/threesixty/account.rb', line 45
def self.deactivate!(username)
deactivateAccount(username)
end
|
.deactivateAccount(username) ⇒ Object
49
50
51
52
|
# File 'lib/sorenson/threesixty/account.rb', line 49
def self.deactivateAccount(username)
data = post_to("/api/deactivateAccount?username=#{username}&vToken=#{token_for(username)}")
!!data['success']
end
|
.doesAccountExist(username) ⇒ Object
26
27
28
29
|
# File 'lib/sorenson/threesixty/account.rb', line 26
def self.doesAccountExist(username)
data = post_to("/api/doesAccountExist?username=#{username}")
!!data['accountExists']
end
|
.exists?(username) ⇒ Boolean
Alias for doesAccountExist
32
33
34
|
# File 'lib/sorenson/threesixty/account.rb', line 32
def self.exists?(username)
doesAccountExist(username)
end
|
.find(accountId, sessionId) ⇒ Object
18
19
20
|
# File 'lib/sorenson/threesixty/account.rb', line 18
def self.find(accountId, sessionId)
new(post_to("/api/getAccount?accountId=#{accountId}&sessionId=#{sessionId}"), sessionId)
end
|
.login(username, password) ⇒ Object
14
15
16
|
# File 'lib/sorenson/threesixty/account.rb', line 14
def self.login(username, password)
_login("/api/loginApi?username=#{CGI.escape(username.to_s)}&password=#{CGI.escape(password.to_s)}")
end
|
.loginWithAccountId(accountId, sessionId) ⇒ Object
22
23
24
|
# File 'lib/sorenson/threesixty/account.rb', line 22
def self.loginWithAccountId(accountId, sessionId)
_login("/api/loginApi?accountId=#{accountId}&sessionId=#{sessionId}")
end
|
.updatePasswordHack(username, password) ⇒ Object
68
69
70
71
|
# File 'lib/sorenson/threesixty/account.rb', line 68
def self.updatePasswordHack(username, password)
data = post_to("/api/updatePassword?username=#{username}&password=#{password}&sessionId=blah")
!!data['success']
end
|
Instance Method Details
#createSubaccount(username, email, password) ⇒ Object
167
168
169
170
|
# File 'lib/sorenson/threesixty/account.rb', line 167
def createSubaccount(username, email, password)
data = post_to("/api/createSubaccount?accountId=#{id}&sessionId=#{sessionId}&username=#{username}&email=#{email}&password=#{password}")
data['success'] == 1
end
|
#emptyTrash ⇒ Object
162
163
164
165
|
# File 'lib/sorenson/threesixty/account.rb', line 162
def emptyTrash
data = post_to("/api/emptyTrash?accountId=#{id}&sessionId=#{sessionId}")
data
end
|
#getAccountMetrics ⇒ Object
153
154
155
156
|
# File 'lib/sorenson/threesixty/account.rb', line 153
def getAccountMetrics
data = post_to("/api/getAccountMetrics?accountId=#{id}&sessionId=#{sessionId}")
data['accountMetricsList']
end
|
#getAsset(id) ⇒ Object
114
115
116
|
# File 'lib/sorenson/threesixty/account.rb', line 114
def getAsset(id)
Asset.find(self, id)
end
|
#getAssetCount ⇒ Object
118
119
120
121
|
# File 'lib/sorenson/threesixty/account.rb', line 118
def getAssetCount
data = post_to("/api/getMediaListSummary?accountId=#{id}&sessionId=#{sessionId}")
data['totalMediaCount']
end
|
#getAssetMetrics(startDate, endDate) ⇒ Object
158
159
160
|
# File 'lib/sorenson/threesixty/account.rb', line 158
def getAssetMetrics(startDate, endDate)
AssetMetrics.find(self, startDate, endDate)
end
|
#getAssets(offset = nil, quantity = nil) ⇒ Object
107
108
109
110
111
112
|
# File 'lib/sorenson/threesixty/account.rb', line 107
def getAssets(offset = nil, quantity = nil)
assets = Asset.find_all(self, offset, quantity)
return assets if self.subaccountId.blank?
assets.select {|a| a.subaccountId == self.subaccountId}
end
|
#getOverageAction ⇒ Object
138
139
140
141
|
# File 'lib/sorenson/threesixty/account.rb', line 138
def getOverageAction
data = post_to("/api/getOverageAction?accountId=#{id}&sessionId=#{sessionId}")
data['overageAction']
end
|
#getStorageUsed(startDate, endDate) ⇒ Object
133
134
135
136
|
# File 'lib/sorenson/threesixty/account.rb', line 133
def getStorageUsed(startDate, endDate)
data = post_to("/api/getStorageUsed?accountId=#{id}&startDate=#{startDate}&endDate=#{endDate}&sessionId=#{sessionId}")
data['storageUsed']
end
|
#getSubaccounts ⇒ Object
172
173
174
175
176
177
178
179
|
# File 'lib/sorenson/threesixty/account.rb', line 172
def getSubaccounts
data = post_to("/api/getAllSubaccounts?accountId=#{id}&sessionId=#{sessionId}")
subaccounts = []
data['subaccounts'].each do |data|
subaccounts << Sorenson::ThreeSixty::Subaccount.new(self, data)
end
subaccounts
end
|
#getTotalPlays ⇒ Object
128
129
130
131
|
# File 'lib/sorenson/threesixty/account.rb', line 128
def getTotalPlays
data = post_to("/api/getTotalPlays?accountId=#{id}&sessionId=#{sessionId}")
data['totalPlays']
end
|
#getTotalStorageUsed ⇒ Object
123
124
125
126
|
# File 'lib/sorenson/threesixty/account.rb', line 123
def getTotalStorageUsed
data = post_to("/api/getTotalStorageUsed?accountId=#{id}&sessionId=#{sessionId}")
data['storageUsed']
end
|
#updatePassword(password) ⇒ Object
143
144
145
146
|
# File 'lib/sorenson/threesixty/account.rb', line 143
def updatePassword(password)
data = post_to("/api/updatePassword?username=#{username}&password=#{password}&sessionId=#{sessionId}")
!!data['success']
end
|
#updateUsername(newUsername) ⇒ Object
148
149
150
151
|
# File 'lib/sorenson/threesixty/account.rb', line 148
def updateUsername(newUsername)
data = post_to("/api/updateUsername?username=#{username}&newUsername=#{newUsername}&sessionId=#{sessionId}")
!!data['success']
end
|