three_sixty 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG ADDED
@@ -0,0 +1 @@
1
+ 3/22/2010 - Bundled existing code into formal gem hosted on Sorenson's gemcutter
data/Manifest ADDED
@@ -0,0 +1,25 @@
1
+ CHANGELOG
2
+ README
3
+ Rakefile
4
+ lib/sorenson/threesixty.rb
5
+ lib/sorenson/threesixty/account.rb
6
+ lib/sorenson/threesixty/account_summary.rb
7
+ lib/sorenson/threesixty/asset.rb
8
+ lib/sorenson/threesixty/asset_metrics.rb
9
+ lib/sorenson/threesixty/base.rb
10
+ lib/sorenson/threesixty/format_constraint.rb
11
+ lib/sorenson/threesixty/rate_plan.rb
12
+ lib/sorenson/threesixty/subaccount.rb
13
+ lib/sorenson/threesixty/uploader.rb
14
+ spec/account_spec.rb
15
+ spec/account_summary_spec.rb
16
+ spec/asset_metrics_spec.rb
17
+ spec/asset_spec.rb
18
+ spec/base_spec.rb
19
+ spec/format_constraint_spec.rb
20
+ spec/rate_plan_spec.rb
21
+ spec/spec.opts
22
+ spec/spec_helper.rb
23
+ spec/uploader_spec.rb
24
+ tasks/rspec.rake
25
+ Manifest
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require 'rake'
5
+ require 'rubygems'
6
+ require 'cucumber'
7
+ require 'cucumber/rake/task'
8
+ require 'echoe'
9
+
10
+ Echoe.new('three_sixty', '1.0.0') do |p|
11
+ p.description = "Ruby bindings for Sorenson 360 Backend"
12
+ p.url = "https://github.com/sorenson/ThreeSixtyServices-Internal"
13
+ p.author = "Sorenson Media"
14
+ p.email = "video@sorensonmedia.com"
15
+ p.ignore_pattern = ["tmp/*", "script/*"]
16
+ p.development_dependencies = %w(echoe rspec)
17
+ end
18
+
19
+ Dir['tasks/**/*.rake'].each { |t| load t }
20
+
21
+ task :default => :spec
@@ -0,0 +1,183 @@
1
+ module Sorenson
2
+ module ThreeSixty
3
+ class Account < Base
4
+
5
+ # Attributes
6
+ attr_accessor :sessionId, :token, :gotoJuiceURL, :username, :status, :customerId, :id, :ratePlanExpirationDate, :dateLastModified, :sorensonId, :lastLoginTime, :dateRetrieved, :totalAssetCount, :ratePlan, :goto360URL, :subaccountId
7
+
8
+ # Class Methods
9
+
10
+ def self._login(url)
11
+ new(post_to(url))
12
+ end
13
+
14
+ def self.login(username, password)
15
+ _login("/api/loginApi?username=#{CGI.escape(username.to_s)}&password=#{CGI.escape(password.to_s)}")
16
+ end
17
+
18
+ def self.find(accountId, sessionId)
19
+ new(post_to("/api/getAccount?accountId=#{accountId}&sessionId=#{sessionId}"), sessionId)
20
+ end
21
+
22
+ def self.loginWithAccountId(accountId, sessionId)
23
+ _login("/api/loginApi?accountId=#{accountId}&sessionId=#{sessionId}")
24
+ end
25
+
26
+ def self.doesAccountExist(username)
27
+ data = post_to("/api/doesAccountExist?username=#{username}")
28
+ !!data['accountExists']
29
+ end
30
+
31
+ # Alias for doesAccountExist
32
+ def self.exists?(username)
33
+ doesAccountExist(username)
34
+ end
35
+
36
+ def self.activateAccount(username)
37
+ data = post_to("/api/activateAccount?username=#{username}&vToken=#{token_for(username)}")
38
+ !!data['success']
39
+ end
40
+
41
+ def self.activate!(username)
42
+ activateAccount(username)
43
+ end
44
+
45
+ def self.deactivate!(username)
46
+ deactivateAccount(username)
47
+ end
48
+
49
+ def self.deactivateAccount(username)
50
+ data = post_to("/api/deactivateAccount?username=#{username}&vToken=#{token_for(username)}")
51
+ !!data['success']
52
+ end
53
+
54
+ def self.createAccount(username, password, ratePlanId, activate = false)
55
+ data = post_to("/api/createAccount?vToken=#{token_for(username)}&username=#{username}&password=#{password}&ratePlanId=#{ratePlanId}")
56
+ result = !!data['success']
57
+
58
+ if (result)
59
+ updatePasswordHack(username, password)
60
+ end
61
+
62
+ if (result && activate && activate!(username))
63
+ result = login(username, password)
64
+ end
65
+ result
66
+ end
67
+
68
+ def self.updatePasswordHack(username, password)
69
+ data = post_to("/api/updatePassword?username=#{username}&password=#{password}&sessionId=blah")
70
+ !!data['success']
71
+ end
72
+
73
+ def self.allAccounts
74
+ data = post_to("/api/getAllAccounts")
75
+ end
76
+
77
+
78
+ # Instance Methods
79
+
80
+ def initialize(data, sessionId = nil)
81
+ self.sessionId = data['sessionId'] || sessionId
82
+ self.token = data['token']
83
+ self.subaccountId = data['subaccountId']
84
+ self.goto360URL = data['gotoJuiceURL']
85
+
86
+ # depricated
87
+ self.gotoJuiceURL = data['gotoJuiceURL']
88
+
89
+ # account specific data
90
+ account = data['account']
91
+ if account
92
+ self.username = account['username']
93
+ self.status = account['status']
94
+ self.customerId = account['id']
95
+ self.id = account['id']
96
+ self.ratePlanExpirationDate = account['ratePlanExpirationDate']
97
+ self.dateLastModified = account['dateLastModified']
98
+ self.sorensonId = account['sorensonId']
99
+ self.lastLoginTime = account['lastLoginTime']
100
+ self.dateRetrieved = account['dateRetrieved']
101
+ self.totalAssetCount = getAssetCount
102
+
103
+ self.ratePlan = RatePlan.new(account['ratePlan']) if account['ratePlan']
104
+ end
105
+ end
106
+
107
+ def getAssets(offset = nil, quantity = nil)
108
+ assets = Asset.find_all(self, offset, quantity)
109
+ return assets if self.subaccountId.blank?
110
+
111
+ assets.select {|a| a.subaccountId == self.subaccountId}
112
+ end
113
+
114
+ def getAsset(id)
115
+ Asset.find(self, id)
116
+ end
117
+
118
+ def getAssetCount
119
+ data = post_to("/api/getMediaListSummary?accountId=#{id}&sessionId=#{sessionId}")
120
+ data['totalMediaCount']
121
+ end
122
+
123
+ def getTotalStorageUsed
124
+ data = post_to("/api/getTotalStorageUsed?accountId=#{id}&sessionId=#{sessionId}")
125
+ data['storageUsed']
126
+ end
127
+
128
+ def getTotalPlays
129
+ data = post_to("/api/getTotalPlays?accountId=#{id}&sessionId=#{sessionId}")
130
+ data['totalPlays']
131
+ end
132
+
133
+ def getStorageUsed(startDate, endDate)
134
+ data = post_to("/api/getStorageUsed?accountId=#{id}&startDate=#{startDate}&endDate=#{endDate}&sessionId=#{sessionId}")
135
+ data['storageUsed']
136
+ end
137
+
138
+ def getOverageAction
139
+ data = post_to("/api/getOverageAction?accountId=#{id}&sessionId=#{sessionId}")
140
+ data['overageAction']
141
+ end
142
+
143
+ def updatePassword(password)
144
+ data = post_to("/api/updatePassword?username=#{username}&password=#{password}&sessionId=#{sessionId}")
145
+ !!data['success']
146
+ end
147
+
148
+ def updateUsername(newUsername)
149
+ data = post_to("/api/updateUsername?username=#{username}&newUsername=#{newUsername}&sessionId=#{sessionId}")
150
+ !!data['success']
151
+ end
152
+
153
+ def getAccountMetrics
154
+ data = post_to("/api/getAccountMetrics?accountId=#{id}&sessionId=#{sessionId}")
155
+ data['accountMetricsList']
156
+ end
157
+
158
+ def getAssetMetrics(startDate, endDate)
159
+ AssetMetrics.find(self, startDate, endDate)
160
+ end
161
+
162
+ def emptyTrash
163
+ data = post_to("/api/emptyTrash?accountId=#{id}&sessionId=#{sessionId}")
164
+ data
165
+ end
166
+
167
+ def createSubaccount(username, email, password)
168
+ data = post_to("/api/createSubaccount?accountId=#{id}&sessionId=#{sessionId}&username=#{username}&email=#{email}&password=#{password}")
169
+ data['success'] == 1
170
+ end
171
+
172
+ def getSubaccounts
173
+ data = post_to("/api/getAllSubaccounts?accountId=#{id}&sessionId=#{sessionId}")
174
+ subaccounts = []
175
+ data['subaccounts'].each do |data|
176
+ subaccounts << Sorenson::ThreeSixty::Subaccount.new(self, data)
177
+ end
178
+ subaccounts
179
+ end
180
+
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,30 @@
1
+ module Sorenson
2
+ module ThreeSixty
3
+ class AccountSummary < Base
4
+
5
+ # Attributes
6
+ attr_accessor :username, :status, :id, :ratePlanExpirationDate, :chosenRatePlan, :lastLoginTime
7
+
8
+ # Class Methods
9
+ def self.getAccountSummaries
10
+ data = post_to("/api/getAllAccounts")
11
+ summaries = []
12
+ data['accounts'].each do |account|
13
+ summaries << AccountSummary.new(account)
14
+ end
15
+ summaries
16
+ end
17
+
18
+ # Instance Methods
19
+
20
+ def initialize(data)
21
+ self.username = data['username']
22
+ self.status = data['status']
23
+ self.id = data['id']
24
+ self.ratePlanExpirationDate = data['ratePlanExpirationDate']
25
+ self.chosenRatePlan = data['chosenRatePlan']
26
+ self.lastLoginTime = data['lastLoginTime']
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,152 @@
1
+ module Sorenson
2
+ module ThreeSixty
3
+ class Asset < Base
4
+
5
+ # Attributes
6
+ attr_accessor :account, :encodeDate, :frameRate, :height, :dateLastModified, :videoBitrateMode, :mediaType, :id, :accountId, :numberOfViews, :presetXml, :application, :audioCodec, :permalinkLocation, :status, :description, :videoDuration, :abstractFileId, :versionId, :dateRetrieved, :audioDataRate, :audioBitrateMode, :videoCodec, :displayName, :name, :videoDataRate, :authorId, :width, :fileSize, :defaultEmbed, :thumbnailImageUrl, :filters, :embedList, :httpLocation, :directAssetUrl, :subaccountId, :videoGuid
7
+
8
+ # Class Methods
9
+ def self.find_all(account, offset = nil, quantity = nil)
10
+ data = post_to("/api/getMediaList?offset=#{offset}&quantity=#{quantity}&accountId=#{account.id}&sessionId=#{account.sessionId}&status=Live&sort=uploadDate")
11
+
12
+ assets = []
13
+
14
+ data['mediaList'].each do |entry|
15
+ assets << Asset.new(account, entry) if account.subaccountId.blank? || account.subaccountId == entry['subaccountId']
16
+ end
17
+
18
+ assets
19
+ end
20
+
21
+ def self.find(account, id)
22
+ data = post_to("/api/getAsset?mguid=#{id}&sessionId=#{account.sessionId}")
23
+ Asset.new(account, data['media'].merge({'thumbLocation' => data['thumbLocation'], 'permalink' => data['permalinkLocation']}))
24
+ end
25
+
26
+ def self.get_embed_codes(video_guid, sessionId, account)
27
+ data = post_to("/api/getAllEmbedcodes?vguid=#{video_guid}&sessionId=#{account.sessionId}")
28
+ data['embedList']
29
+ end
30
+
31
+ def self.get_streaming_server_url
32
+ "rtmp://cdnstreamingvideos.sorensonmedia.com/cfx/st"
33
+ end
34
+
35
+ # Instance Methods
36
+ def initialize(account, data)
37
+ self.account = account
38
+ self.presetXml = data['presetXml']
39
+ self.subaccountId = data['subaccountId']
40
+ self.encodeDate = data['encodeDate']
41
+ self.frameRate = data['frameRate']
42
+ self.height = data['height']
43
+ self.dateLastModified = data['dateLastModified']
44
+ self.videoBitrateMode = data['videoBitrateMode']
45
+ self.mediaType = data['mediaType']
46
+ self.id = data['id']
47
+ self.accountId = data['accountId']
48
+ self.numberOfViews = data['numberOfViews']
49
+ self.application = data['application']
50
+ self.audioCodec = data['audioCodec']
51
+ self.permalinkLocation = data['permalink']
52
+ self.status = data['status']
53
+ self.description = data['description']
54
+ self.videoDuration = data['videoDuration']
55
+ self.abstractFileId = data['abstractFileId']
56
+ self.versionId = data['versionId']
57
+ self.dateRetrieved = data['dateRetrieved']
58
+ self.audioDataRate = data['audioDataRate']
59
+ self.audioBitrateMode = data['audioBitrateMode']
60
+ self.videoCodec = data['videoCodec']
61
+ self.displayName = data['displayName']
62
+ self.name = data['name']
63
+ self.videoDataRate = data['videoDataRate']
64
+ self.authorId = data['authorId']
65
+ self.width = data['width']
66
+ self.fileSize = data['fileSize']
67
+ self.thumbnailImageUrl = data['thumbnail']['httpLocation'] if data['thumbnail']
68
+ self.thumbnailImageUrl = data['thumbLocation'] if data['thumbLocation']
69
+ self.httpLocation = data['httpLocation']
70
+ self.directAssetUrl = "http://360.sorensonmedia.com/redirector/fetchFile?vguid=#{self.id}"
71
+ self.videoGuid
72
+
73
+ self.filters = []
74
+ if data['filters']
75
+ data['filters'].each do |filter|
76
+ self.filters << filter['filterDescription']
77
+ end
78
+ end
79
+
80
+ self.embedList = {}
81
+ get_embed_codes
82
+
83
+ self.videoGuid = self.embedList.empty? ? nil : self.embedList.first[1].match(/videoGUID=(.*?)&/)[1]
84
+ end
85
+
86
+ def get_streaming_video_path
87
+ data = post_to("/api/getPlayerData?vguid=#{self.videoGuid}&cms=true")
88
+ data['media']['accessLocation']['s3KeyName']
89
+ end
90
+
91
+ def delete
92
+ data = post_to("/api/deleteAsset?fileVersionId=#{id}&sessionId=#{account.sessionId}")
93
+ end
94
+
95
+ def deactivate
96
+ data = post_to("/api/deactivateAsset?fileVersionId=#{id}&sessionId=#{account.sessionId}")
97
+ end
98
+
99
+ def activate
100
+ data = post_to("/api/activateAsset?fileVersionId=#{id}&sessionId=#{account.sessionId}")
101
+ end
102
+
103
+ def setName(name)
104
+ data = post_to("/api/setAssetName?fileVersionId=#{id}&newName=#{name}&sessionId=#{account.sessionId}")
105
+ end
106
+
107
+ def setDescription(description)
108
+ data = post_to("/api/setAssetDescription?fileVersionId=#{id}&newDescription=#{description}&sessionId=#{account.sessionId}")
109
+ end
110
+
111
+ def setPassword(password)
112
+ data = nil
113
+ if password == '' || password.nil?
114
+ data = post_to("/api/removeAssetSecurity?fileVersionId=#{id}&security=#{password}&sessionId=#{account.sessionId}")
115
+ else
116
+ data = post_to("/api/setAssetSecurity?fileVersionId=#{id}&security=#{password}&sessionId=#{account.sessionId}")
117
+ end
118
+ data
119
+ end
120
+
121
+ def getAllSubaccounts
122
+ data = post_to("/api/getAllSubaccount?accountId=#{id}&sessionId=#{sessionId}")
123
+ data
124
+ end
125
+
126
+ private
127
+ def get_embed_codes
128
+ data = post_to("/api/getAllEmbedcodes?vguid=#{id}&sessionId=#{account.sessionId}")
129
+
130
+ if data['embedList']
131
+ data['embedList'].each do |embed|
132
+ embed =~ /width="(\d+)"/
133
+ width = $1
134
+
135
+ embed =~ /height="(\d+)"/
136
+ height = $1
137
+
138
+ ratio = (width.to_f / height.to_f)
139
+
140
+ aspect = (ratio <= 1.33 ? 'Full Screen' : 'Widescreen')
141
+
142
+ self.embedList["#{width}x#{height} - #{aspect}"] = embed
143
+
144
+ end
145
+ end
146
+
147
+ self.defaultEmbed = data['defaultEmbed']
148
+ end
149
+
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,26 @@
1
+ module Sorenson
2
+ module ThreeSixty
3
+ class AssetMetrics < Base
4
+
5
+ attr_accessor :playTotal, :filePlayData, :playData
6
+
7
+ # Class Methods
8
+ def self.find(account, startDate, endDate)
9
+ data = post_to("/api/getAccountDashboardMetrics?accountId=#{account.id}&startDate=#{startDate}&endDate=#{endDate}")
10
+ AssetMetrics.new(data)
11
+ end
12
+
13
+ # Instance Methods
14
+ def initialize(data)
15
+ self.playTotal = data['playTotal']
16
+ self.filePlayData = data['filePlayData']
17
+
18
+ self.playData = {}
19
+ data['playData'].each do |playData|
20
+ self.playData[playData['eventDay']] = playData['plays']
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,76 @@
1
+ module Sorenson
2
+ module ThreeSixty
3
+ class InvalidServerResponse < Exception
4
+ end
5
+
6
+ class Base
7
+ TOKEN_SALT = 'beachfr0nt'
8
+ @@debug = false
9
+ @@use_ssl = false
10
+
11
+ # Class Methods
12
+ def self.use_ssl?
13
+ !!@@use_ssl
14
+ end
15
+
16
+ def self.debug?
17
+ !!@@debug
18
+ end
19
+
20
+ def self.use_ssl=(value)
21
+ @@use_ssl = value
22
+ end
23
+
24
+ def self.debug=(value)
25
+ @@debug = value
26
+ end
27
+
28
+ def self.host
29
+ host = '360.sorensonmedia.com'
30
+ filename = '/var/tmp/360host'
31
+ if File.exist?(filename)
32
+ data = File.read(filename)
33
+ if data && data != ''
34
+ env = data.split("\n").first.strip
35
+ response = RestClient.get("http://www.sorensonmedia.com/internal/apis/360Env.php?env=#{env}").strip
36
+ host = response unless response == 'invalid option specified'
37
+ end
38
+ end
39
+
40
+ host
41
+ end
42
+
43
+ def self.protocol
44
+ use_ssl? ? 'https://' : 'http://'
45
+ end
46
+
47
+ def self.token_for(username)
48
+ Digest::SHA1.hexdigest(TOKEN_SALT + username)
49
+ end
50
+
51
+ def self.post_to(url)
52
+ post_to_url = protocol + host + url
53
+ result = RestClient.post(post_to_url, {}).body
54
+
55
+ if debug?
56
+ puts '/// URL //////////////////////////////'
57
+ puts post_to_url
58
+ puts '/// DATA //////////////////////////////'
59
+ puts result
60
+ end
61
+
62
+ begin
63
+ JSON.parse(result)
64
+ rescue JSON::ParserError => e
65
+ raise InvalidServerResponse.new(e.message)
66
+ end
67
+ end
68
+
69
+ # Instance Methods
70
+ def post_to(url)
71
+ self.class.post_to(url)
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,36 @@
1
+ module Sorenson
2
+ module ThreeSixty
3
+ class FormatConstraint < Base
4
+
5
+ attr_accessor :id, :name, :displayName, :defaultVideoDuration, :maxVideoDuration, :defaultFrameRate, :maxFrameRate, :maxWidth, :defaultWidth, :ratePlanId, :maxHeight, :defaultHeight, :defaultAudioDataRate, :maxAudioDataRate, :dateRetrieved, :defaultVideoDataRate, :maxVideoDataRate, :thumbnailGenerationMethod, :defaultAudioCodec, :defaultVideoCodec, :audioBitRateMode, :videoBitRateMode, :mediaType, :ratePlan
6
+
7
+ def initialize(ratePlan, data)
8
+ self.ratePlan = ratePlan
9
+ self.id = data['id']
10
+ self.name = data['name']
11
+ self.displayName = data['displayName']
12
+ self.defaultVideoDuration = data['defaultVideoDuration']
13
+ self.maxVideoDuration = data['maxVideoDuration']
14
+ self.defaultFrameRate = data['defaultFrameRate']
15
+ self.maxFrameRate = data['maxFrameRate']
16
+ self.maxWidth = data['maxWidth']
17
+ self.defaultWidth = data['defaultWidth']
18
+ self.ratePlanId = data['ratePlanId']
19
+ self.maxHeight = data['maxHeight']
20
+ self.defaultHeight = data['defaultHeight']
21
+ self.defaultAudioDataRate = data['defaultAudioDataRate']
22
+ self.maxAudioDataRate = data['maxAudioDataRate']
23
+ self.dateRetrieved = data['dateRetrieved']
24
+ self.defaultVideoDataRate = data['defaultVideoDataRate']
25
+ self.maxVideoDataRate = data['maxVideoDataRate']
26
+ self.thumbnailGenerationMethod = data['thumbnailGenerationMethod']
27
+ self.defaultAudioCodec = data['defaultAudioCodec']
28
+ self.defaultVideoCodec = data['defaultVideoCodec']
29
+ self.audioBitRateMode = data['audioBitRateMode']
30
+ self.videoBitRateMode = data['videoBitRateMode']
31
+ self.mediaType = data['mediaType']
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,63 @@
1
+ module Sorenson
2
+ module ThreeSixty
3
+ class RatePlan < Base
4
+
5
+ attr_accessor :id, :displayName, :ratePlanType, :maxThumbnailsPerVideo, :setupCost, :monthlyCost, :allowedStreams, :basePlan, :dateLastModified, :dateRetrieved, :streamingOverageAllowed, :storageOverageAllowed, :allowedStreamingMBytes, :allowedStorageMBytes, :allowedSourceMediaTypes, :allowedOutputMediaTypes, :annualCost, :formatConstraints, :sorensonSku
6
+
7
+ # Class Methods
8
+ def self.getBaseRatePlans
9
+ data = post_to('/api/getBaseRatePlans')
10
+ rate_plans = []
11
+ data['baseRatePlans'].each do |rate_plan|
12
+ rate_plans << RatePlan.new(rate_plan)
13
+ end
14
+ rate_plans
15
+ end
16
+
17
+ def self.getAllRatePlans
18
+ data = post_to("/api/getAllRatePlans")
19
+ rate_plans = []
20
+ data['ratePlans'].each do |rate_plan|
21
+ rate_plans << RatePlan.new(rate_plan)
22
+ end
23
+ rate_plans
24
+ end
25
+
26
+ def self.getRatePlan(id)
27
+ data = post_to("/api/getRatePlan?ratePlanId=#{id}")
28
+ RatePlan.new(data['ratePlanData'])
29
+ end
30
+
31
+ # Instance Methods
32
+ def initialize(data)
33
+ self.id = data['id']
34
+ self.displayName = data['displayName']
35
+ self.ratePlanType = data['ratePlanType']
36
+ self.maxThumbnailsPerVideo = data['maxThumbnailsPerVideo']
37
+ self.setupCost = data['setupCost']
38
+ self.monthlyCost = data['monthlyCost']
39
+ self.annualCost = data['annualCost']
40
+ self.allowedStreams = data['allowedStreams']
41
+ self.basePlan = data['basePlan']
42
+ self.dateLastModified = data['dateLastModified']
43
+ self.dateRetrieved = data['dateRetrieved']
44
+ self.streamingOverageAllowed = data['streamingOverageAllowed']
45
+ self.storageOverageAllowed = data['storageOverageAllowed']
46
+ self.allowedStreamingMBytes = data['allowedStreamingMBytes']
47
+ self.allowedStorageMBytes = data['allowedStorageMBytes']
48
+ self.allowedSourceMediaTypes = data['allowedSourceMediaTypes'] # multi param
49
+ self.allowedOutputMediaTypes = data['allowedOutputMediaTypes'] # multi param
50
+ self.sorensonSku = data['sorensonSku']
51
+
52
+ self.formatConstraints = []
53
+
54
+ if data['formatConstraints']
55
+ data['formatConstraints'].each do |f|
56
+ self.formatConstraints << FormatConstraint.new(self, f)
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,34 @@
1
+ module Sorenson
2
+ module ThreeSixty
3
+ class Subaccount < Base
4
+
5
+ # Attributes
6
+ attr_accessor :account, :id, :username, :status, :accountId, :email, :dateRetrieved
7
+
8
+ # Class Methods
9
+
10
+ # Instance Methods
11
+
12
+ def initialize(account, data)
13
+ self.account = account
14
+ self.username = data['username']
15
+ self.id = data['id']
16
+ self.status = data['status']
17
+ self.accountId = data['accountId']
18
+ self.email = data['email']
19
+ self.dateRetrieved = data['dateRetrieved']
20
+ end
21
+
22
+ def activate!
23
+ data = post_to("/api/setSubaccountStatus?subaccountId=#{id}&status=Live&sessionId=#{account.sessionId}")
24
+ data['success'] == 1
25
+ end
26
+
27
+ def deactivate!
28
+ data = post_to("/api/setSubaccountStatus?subaccountId=#{id}&status=Retired&sessionId=#{account.sessionId}")
29
+ data['success'] == 1
30
+ end
31
+
32
+ end
33
+ end
34
+ end