360_services 0.0.1
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/360_services.gemspec +42 -0
- data/Manifest +48 -0
- data/Rakefile +30 -0
- data/fakeweb_cache +6650 -0
- data/features/manage_accounts.feature +32 -0
- data/features/manage_assets.feature +58 -0
- data/features/manage_categories.feature +87 -0
- data/features/manage_flags.feature +44 -0
- data/features/manage_group_assets.feature +33 -0
- data/features/manage_groups.feature +29 -0
- data/features/manage_metadata.feature +28 -0
- data/features/manage_metrics.feature +22 -0
- data/features/manage_sites.feature +17 -0
- data/features/manage_tags.feature +37 -0
- data/features/mange_rate_plan.feature +9 -0
- data/features/step_definitions/manage_accounts_steps.rb +19 -0
- data/features/step_definitions/manage_assets_steps.rb +62 -0
- data/features/step_definitions/manage_categories_steps.rb +56 -0
- data/features/step_definitions/manage_flags_steps.rb +19 -0
- data/features/step_definitions/manage_group_assets_steps.rb +15 -0
- data/features/step_definitions/manage_groups_steps.rb +27 -0
- data/features/step_definitions/manage_metadata_steps.rb +29 -0
- data/features/step_definitions/manage_metrics_steps.rb +15 -0
- data/features/step_definitions/manage_sites_steps.rb +15 -0
- data/features/step_definitions/manage_tags_steps.rb +23 -0
- data/features/step_definitions/mange_rate_plan_steps.rb +3 -0
- data/features/step_definitions/utility_steps.rb +33 -0
- data/features/step_definitions/web_steps.rb +259 -0
- data/features/support/document_steps.rb +46 -0
- data/features/support/env.rb +13 -0
- data/features/support/netrecorder.rb +20 -0
- data/features/support/paths.rb +27 -0
- data/lib/sorenson/services/account.rb +50 -0
- data/lib/sorenson/services/array.rb +5 -0
- data/lib/sorenson/services/asset.rb +155 -0
- data/lib/sorenson/services/base.rb +71 -0
- data/lib/sorenson/services/category.rb +52 -0
- data/lib/sorenson/services/core_ext/attribute_accessors.rb +40 -0
- data/lib/sorenson/services/core_ext/hash.rb +9 -0
- data/lib/sorenson/services/core_ext/object.rb +16 -0
- data/lib/sorenson/services/core_ext.rb +3 -0
- data/lib/sorenson/services/event.rb +28 -0
- data/lib/sorenson/services/flag.rb +14 -0
- data/lib/sorenson/services/group.rb +41 -0
- data/lib/sorenson/services/metric.rb +21 -0
- data/lib/sorenson/services/rate_plan.rb +30 -0
- data/lib/sorenson/services/site.rb +25 -0
- data/lib/sorenson/services/tag.rb +17 -0
- data/lib/sorenson/services.rb +18 -0
- metadata +161 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
When /^I get all tags$/ do
|
2
|
+
@tags = Sorenson::Services::Tag.all
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^the tag count should be "([^\"]*)"$/ do |count|
|
6
|
+
Sorenson::Services::Tag.count.should == count.to_i
|
7
|
+
end
|
8
|
+
|
9
|
+
When /^I assign the (?:tag|tags) "([^\"]*)" to the asset$/ do |arg1|
|
10
|
+
@tags = @asset.add_tags(arg1)
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I find all assets with the tag "([^\"]*)"$/ do |arg1|
|
14
|
+
@assets = Sorenson::Services::Asset.find_all_by_tag(arg1)
|
15
|
+
end
|
16
|
+
|
17
|
+
When /^I get the tags for the asset$/ do
|
18
|
+
@tags = @asset.tags
|
19
|
+
end
|
20
|
+
|
21
|
+
When /^I find the tag named "([^\"]*)"$/ do |name|
|
22
|
+
@tag = Sorenson::Services::Tag.find(name)
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Then "show me the $object" do |object|
|
2
|
+
raise instance_variable_get("@#{object}").inspect
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^the ([^\"]*) list should contain "([^\"]*)"$/ do |object, value|
|
6
|
+
instance_variable_get("@#{object}").should include(value)
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^the ([^\"]*) list should not contain "([^\"]*)"$/ do |object, arg1|
|
10
|
+
instance_variable_get("@#{object}").should_not include(arg1)
|
11
|
+
end
|
12
|
+
|
13
|
+
# the group attribute "name" should be "George"
|
14
|
+
Then /^the ([^\"]*) attribute "([^\"]*)" should be "([^\"]*)"$/ do |object, field, arg1|
|
15
|
+
instance_variable_get("@#{text_to_variable(object)}").send(text_to_variable(field)).should == arg1
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^I change the ([^\"]*) attribute "([^\"]*)" to "([^\"]*)"$/ do |object, field, value|
|
19
|
+
instance_variable_get("@#{text_to_variable(object)}").send("#{text_to_variable(field)}=", value)
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /^the ([^\"]*) list should contain the ([^\"]*) id$/ do |list, object|
|
23
|
+
instance_variable_get("@#{list}").should include(instance_variable_get("@#{object}").id)
|
24
|
+
end
|
25
|
+
|
26
|
+
Then /^the ([^\"]*) list should not contain the ([^\"]*) id$/ do |list, object|
|
27
|
+
instance_variable_get("@#{list}").should_not include(instance_variable_get("@#{object}").id)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def text_to_variable(object)
|
32
|
+
object.gsub(" ", "_")
|
33
|
+
end
|
@@ -0,0 +1,259 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
9
|
+
|
10
|
+
# Commonly used webrat steps
|
11
|
+
# http://github.com/brynary/webrat
|
12
|
+
|
13
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
14
|
+
visit path_to(page_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
18
|
+
visit path_to(page_name)
|
19
|
+
end
|
20
|
+
|
21
|
+
When /^(?:|I )press "([^\"]*)"$/ do |button|
|
22
|
+
click_button(button)
|
23
|
+
end
|
24
|
+
|
25
|
+
When /^(?:|I )follow "([^\"]*)"$/ do |link|
|
26
|
+
click_link(link)
|
27
|
+
end
|
28
|
+
|
29
|
+
When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
|
30
|
+
click_link_within(parent, link)
|
31
|
+
end
|
32
|
+
|
33
|
+
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
34
|
+
fill_in(field, :with => value)
|
35
|
+
end
|
36
|
+
|
37
|
+
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
|
38
|
+
fill_in(field, :with => value)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Use this to fill in an entire form with data from a table. Example:
|
42
|
+
#
|
43
|
+
# When I fill in the following:
|
44
|
+
# | Account Number | 5002 |
|
45
|
+
# | Expiry date | 2009-11-01 |
|
46
|
+
# | Note | Nice guy |
|
47
|
+
# | Wants Email? | |
|
48
|
+
#
|
49
|
+
# TODO: Add support for checkbox, select og option
|
50
|
+
# based on naming conventions.
|
51
|
+
#
|
52
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
53
|
+
fields.rows_hash.each do |name, value|
|
54
|
+
When %{I fill in "#{name}" with "#{value}"}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
|
59
|
+
select(value, :from => field)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
63
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
64
|
+
When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
|
65
|
+
select_datetime(time)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
69
|
+
# you want to specify which datetime to select. Given the following view:
|
70
|
+
# <%= f.label :preferred %><br />
|
71
|
+
# <%= f.datetime_select :preferred %>
|
72
|
+
# <%= f.label :alternative %><br />
|
73
|
+
# <%= f.datetime_select :alternative %>
|
74
|
+
# The following steps would fill out the form:
|
75
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
|
76
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
|
77
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
78
|
+
select_datetime(datetime, :from => datetime_label)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
82
|
+
# When I select "2:20PM" as the time
|
83
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
84
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
85
|
+
When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
|
86
|
+
select_time(time)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
90
|
+
# specify the name of the time on the form. For example:
|
91
|
+
# When I select "7:30AM" as the "Gym" time
|
92
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
|
93
|
+
select_time(time, :from => time_label)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
97
|
+
# When I select "February 20, 1981" as the date
|
98
|
+
When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
|
99
|
+
select_date(date)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Use this step when using multiple date_select helpers on one page or
|
103
|
+
# you want to specify the name of the date on the form. For example:
|
104
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
105
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
|
106
|
+
select_date(date, :from => date_label)
|
107
|
+
end
|
108
|
+
|
109
|
+
When /^(?:|I )check "([^\"]*)"$/ do |field|
|
110
|
+
check(field)
|
111
|
+
end
|
112
|
+
|
113
|
+
When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
|
114
|
+
uncheck(field)
|
115
|
+
end
|
116
|
+
|
117
|
+
When /^(?:|I )choose "([^\"]*)"$/ do |field|
|
118
|
+
choose(field)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Adds support for validates_attachment_content_type. Without the mime-type getting
|
122
|
+
# passed to attach_file() you will get a "Photo file is not one of the allowed file types."
|
123
|
+
# error message
|
124
|
+
When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
125
|
+
type = path.split(".")[1]
|
126
|
+
|
127
|
+
case type
|
128
|
+
when "jpg"
|
129
|
+
type = "image/jpg"
|
130
|
+
when "jpeg"
|
131
|
+
type = "image/jpeg"
|
132
|
+
when "png"
|
133
|
+
type = "image/png"
|
134
|
+
when "gif"
|
135
|
+
type = "image/gif"
|
136
|
+
end
|
137
|
+
|
138
|
+
attach_file(field, path, type)
|
139
|
+
end
|
140
|
+
|
141
|
+
Then /^(?:|I )should see "([^\"]*)"$/ do |text|
|
142
|
+
if defined?(Spec::Rails::Matchers)
|
143
|
+
response.should contain(text)
|
144
|
+
else
|
145
|
+
assert_contain text
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
150
|
+
within(selector) do |content|
|
151
|
+
if defined?(Spec::Rails::Matchers)
|
152
|
+
content.should contain(text)
|
153
|
+
else
|
154
|
+
assert content.include?(text)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
160
|
+
regexp = Regexp.new(regexp)
|
161
|
+
if defined?(Spec::Rails::Matchers)
|
162
|
+
response.should contain(regexp)
|
163
|
+
else
|
164
|
+
assert_contain regexp
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
169
|
+
within(selector) do |content|
|
170
|
+
regexp = Regexp.new(regexp)
|
171
|
+
if defined?(Spec::Rails::Matchers)
|
172
|
+
content.should contain(regexp)
|
173
|
+
else
|
174
|
+
assert content =~ regexp
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
|
180
|
+
if defined?(Spec::Rails::Matchers)
|
181
|
+
response.should_not contain(text)
|
182
|
+
else
|
183
|
+
assert_not_contain text
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
188
|
+
within(selector) do |content|
|
189
|
+
if defined?(Spec::Rails::Matchers)
|
190
|
+
content.should_not contain(text)
|
191
|
+
else
|
192
|
+
assert !content.include?(text)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
198
|
+
regexp = Regexp.new(regexp)
|
199
|
+
if defined?(Spec::Rails::Matchers)
|
200
|
+
response.should_not contain(regexp)
|
201
|
+
else
|
202
|
+
assert_not_contain regexp
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
207
|
+
within(selector) do |content|
|
208
|
+
regexp = Regexp.new(regexp)
|
209
|
+
if defined?(Spec::Rails::Matchers)
|
210
|
+
content.should_not contain(regexp)
|
211
|
+
else
|
212
|
+
assert content !~ regexp
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
218
|
+
if defined?(Spec::Rails::Matchers)
|
219
|
+
field_labeled(field).value.should =~ /#{value}/
|
220
|
+
else
|
221
|
+
assert_match(/#{value}/, field_labeled(field).value)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
|
226
|
+
if defined?(Spec::Rails::Matchers)
|
227
|
+
field_labeled(field).value.should_not =~ /#{value}/
|
228
|
+
else
|
229
|
+
assert_no_match(/#{value}/, field_labeled(field).value)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
234
|
+
if defined?(Spec::Rails::Matchers)
|
235
|
+
field_labeled(label).should be_checked
|
236
|
+
else
|
237
|
+
assert field_labeled(label).checked?
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
|
242
|
+
if defined?(Spec::Rails::Matchers)
|
243
|
+
field_labeled(label).should_not be_checked
|
244
|
+
else
|
245
|
+
assert !field_labeled(label).checked?
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
250
|
+
if defined?(Spec::Rails::Matchers)
|
251
|
+
URI.parse(current_url).path.should == path_to(page_name)
|
252
|
+
else
|
253
|
+
assert_equal path_to(page_name), URI.parse(current_url).path
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
Then /^show me the page$/ do
|
258
|
+
save_and_open_page
|
259
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
if ENV['SHOW_STEPS']
|
4
|
+
module Cucumber
|
5
|
+
module RbSupport
|
6
|
+
class RbStepDefinition
|
7
|
+
alias :alias_for_invoke :invoke
|
8
|
+
def invoke(args)
|
9
|
+
$scenario_names ||= {}
|
10
|
+
scenario_name = @rb_language.instance_variable_get("@step_mother").instance_variable_get("@current_scenario").name
|
11
|
+
$scenario_names[scenario_name] ||= []
|
12
|
+
|
13
|
+
step_file_name = File.join("#{File.dirname(__FILE__)}/../../", file_colon_line.split(":").first)
|
14
|
+
line_num = file_colon_line.split(":").last
|
15
|
+
|
16
|
+
source = File.open(step_file_name, "r") do |f|
|
17
|
+
f.readlines
|
18
|
+
end
|
19
|
+
|
20
|
+
source.each_with_index do |line, i|
|
21
|
+
if i >= line_num.to_i
|
22
|
+
break if line.match(/^end\s+/)
|
23
|
+
$scenario_names[scenario_name] << line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
alias_for_invoke(args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
at_exit do
|
32
|
+
doc_lines = []
|
33
|
+
$scenario_names.each do |name, lines|
|
34
|
+
doc_lines << "# #{name}\n"
|
35
|
+
lines.each do |line|
|
36
|
+
doc_lines << line
|
37
|
+
end
|
38
|
+
doc_lines << "\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
File.open(File.join(File.dirname(__FILE__), '..', '..', 'doc', 'steps_code.rb'), 'w') do |f|
|
42
|
+
f.write doc_lines.join("")
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
ENV['SORENSON_ENV'] = "cucumber"
|
2
|
+
require 'rubygems'
|
3
|
+
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
4
|
+
require 'webrat'
|
5
|
+
require 'webrat/core/matchers'
|
6
|
+
require 'fakeweb'
|
7
|
+
require 'netrecorder'
|
8
|
+
require "#{File.dirname(__FILE__)}/../../lib/sorenson/services.rb"
|
9
|
+
|
10
|
+
Webrat.configure do |config|
|
11
|
+
config.mode = :rails
|
12
|
+
config.open_error_files = false # Set to true if you want error pages to pop up in the browser
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
NetRecorder.config do |config|
|
2
|
+
config.cache_file = "fakeweb_cache"
|
3
|
+
if ENV['RECORD_WEB']
|
4
|
+
config.record_net_calls = true
|
5
|
+
else
|
6
|
+
config.fakeweb = true
|
7
|
+
FakeWeb.allow_net_connect = false
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
at_exit {NetRecorder.cache! if NetRecorder.recording?}
|
12
|
+
|
13
|
+
Before do |scenario|
|
14
|
+
if NetRecorder.recording?
|
15
|
+
NetRecorder.scope = scenario.name
|
16
|
+
else
|
17
|
+
FakeWeb.clean_registry
|
18
|
+
NetRecorder.register_scope(scenario.name)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
# Maps a name to a path. Used by the
|
3
|
+
#
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
5
|
+
#
|
6
|
+
# step definition in web_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when /the home\s?page/
|
12
|
+
'/'
|
13
|
+
|
14
|
+
# Add more mappings here.
|
15
|
+
# Here is an example that pulls values out of the Regexp:
|
16
|
+
#
|
17
|
+
# when /^(.*)'s profile page$/i
|
18
|
+
# user_profile_path(User.find_by_login($1))
|
19
|
+
|
20
|
+
else
|
21
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
22
|
+
"Now, go and add a mapping in #{__FILE__}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Sorenson
|
2
|
+
module Services
|
3
|
+
class Account < Base
|
4
|
+
attr_accessor :rate_plan, :username, :status, :customer_id, :id, :rate_plan_expiration_date, :date_last_modified,
|
5
|
+
:last_login_time, :date_retrieved, :total_asset_count, :token
|
6
|
+
|
7
|
+
def self.login(username, password)
|
8
|
+
account = Account.new(JSON.parse(login_no_resource(username, password)))
|
9
|
+
self.account_token = account.token
|
10
|
+
self.account_id = account.id
|
11
|
+
return account if account.token
|
12
|
+
end
|
13
|
+
|
14
|
+
# Get Accout
|
15
|
+
def self.get_account
|
16
|
+
new(get_from("/accounts/#{account_id}"))
|
17
|
+
end
|
18
|
+
|
19
|
+
def rate_plan
|
20
|
+
RatePlan.new(Base.get_from("/accounts/#{account_id}/rate_plan"))
|
21
|
+
end
|
22
|
+
|
23
|
+
def overage_action
|
24
|
+
Base.get_from("/accounts/#{account_id}/overage_action")["overage_action"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_password(password, old_password)
|
28
|
+
Base.put_to("/accounts/#{account_id}", :account => {:password => password, :old_password => old_password})[:status]
|
29
|
+
end
|
30
|
+
|
31
|
+
def empty_trash
|
32
|
+
Base.post_to("/accounts/#{account_id}/empty_trash")['status']
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(data)
|
36
|
+
self.username = data['username']
|
37
|
+
self.status = data['status']
|
38
|
+
self.customer_id = data['id']
|
39
|
+
self.id = data['id']
|
40
|
+
self.rate_plan_expiration_date = data['rate_plan_expiration_date']
|
41
|
+
self.date_last_modified = data['date_last_modified']
|
42
|
+
self.last_login_time = data['last_login_time']
|
43
|
+
self.date_retrieved = data['date_retrieved']
|
44
|
+
self.total_asset_count = data['total_asset_count']
|
45
|
+
self.token = data['token']
|
46
|
+
self.id = data['account_id'] if data['account_id']
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# Sorenson Namespace
|
2
|
+
module Sorenson
|
3
|
+
# Sorenson Services Namespace
|
4
|
+
module Services
|
5
|
+
# Allows you to access the resources associated with a sorenson services asset. An asset currently refers to video content.
|
6
|
+
class Asset < Base
|
7
|
+
|
8
|
+
|
9
|
+
attr_accessor :encode_date, :frame_rate, :height, :date_last_modified, :video_bitrate_mode,
|
10
|
+
:media_type, :id, :account_id, :number_of_views, :application, :audio_codec,
|
11
|
+
:permalink_location, :status, :description, :video_duration, :abstract_file_id, :version_id,
|
12
|
+
:date_retrieved, :audio_data_rate, :audio_bitrate_mode, :video_codec, :display_name, :name,
|
13
|
+
:video_data_rate, :author_id, :width, :file_size, :thumbnail_image_url, :direct_asset_url,
|
14
|
+
:password, :metadata, :groups
|
15
|
+
|
16
|
+
# Get all of the assets as a list of guids. Use offset and quantity to return subsets.
|
17
|
+
# Sorenson::Services::Account.login('username', 'password')
|
18
|
+
# assets = Sorenson::Services::Asset.all
|
19
|
+
# names = assets.collect {|asset| asset.name}
|
20
|
+
# => names = ["name1", "name2"]
|
21
|
+
def self.all(offset = nil, quantity = nil)
|
22
|
+
get_from("/assets", :offset => offset, :quantity => quantity)["asset_list"]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get a list of asset guids by passing a tag name
|
26
|
+
def self.find_all_by_tag(tag_name)
|
27
|
+
get_from("/tags/#{tag_name}/assets")
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.find_all_by_flag(flag_name)
|
31
|
+
get_from("/flags/#{flag_name}/assets")
|
32
|
+
end
|
33
|
+
|
34
|
+
def tags
|
35
|
+
Base.get_from("/assets/#{id}/tags")
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.count
|
39
|
+
Base.get_from("/assets/count")["count"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.find(id)
|
43
|
+
new(get_from("/assets/#{id}"), id)
|
44
|
+
end
|
45
|
+
|
46
|
+
def preset_xml
|
47
|
+
Base.get_from("/assets/#{id}/preset_xml")["preset_xml"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def deactivate
|
51
|
+
Base.post_to("/assets/#{id}/deactivate")["status"]
|
52
|
+
end
|
53
|
+
|
54
|
+
def activate
|
55
|
+
Base.post_to("/assets/#{id}/activate")["status"]
|
56
|
+
end
|
57
|
+
|
58
|
+
def destroy
|
59
|
+
Base.delete_from("/assets/#{id}")["status"]
|
60
|
+
end
|
61
|
+
|
62
|
+
def save
|
63
|
+
Base.put_to("/assets/#{id}", :asset => {:name => name, :password => password, :description => description})
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_category(name)
|
67
|
+
Category.new(Base.post_to("/assets/#{id}/categories", :category => {:name => name}))
|
68
|
+
end
|
69
|
+
|
70
|
+
def remove_category
|
71
|
+
category = self.category
|
72
|
+
Base.delete_from("/assets/#{id}/categories/#{category.id}")
|
73
|
+
end
|
74
|
+
|
75
|
+
def category
|
76
|
+
data = Base.get_from("/assets/#{id}/categories")
|
77
|
+
return nil if data["result"] == 'failure'
|
78
|
+
Category.new(data)
|
79
|
+
end
|
80
|
+
|
81
|
+
def embed_codes
|
82
|
+
Base.get_from("/assets/#{id}/embed_codes")['embed_codes']
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_tags(tags)
|
86
|
+
Base.post_to("/assets/#{id}/tags", { :tag_list => tags })
|
87
|
+
end
|
88
|
+
|
89
|
+
def flags
|
90
|
+
Base.get_from("/assets/#{id}/flags")
|
91
|
+
end
|
92
|
+
|
93
|
+
def add_flags(flags)
|
94
|
+
Base.post_to("/assets/#{id}/flags", {:flag_list => flags})
|
95
|
+
end
|
96
|
+
|
97
|
+
def delete_metadata(key)
|
98
|
+
Base.delete_from("/assets/#{id}/metadata/#{key}")[:status]
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_metadata_value(key)
|
102
|
+
data = Base.get_from("/assets/#{id}/metadata/#{key}")
|
103
|
+
return nil if data["status"] == 404
|
104
|
+
data["result"]
|
105
|
+
end
|
106
|
+
|
107
|
+
def set_metadata(key, value)
|
108
|
+
data = Base.post_to("/assets/#{id}/metadata", {:key => key, :value => value})
|
109
|
+
end
|
110
|
+
|
111
|
+
def metadata
|
112
|
+
Base.get_from("/assets/#{id}/metadata")
|
113
|
+
end
|
114
|
+
|
115
|
+
def group
|
116
|
+
Group.new(Base.get_from("/groups/#{@group_id}")) if group_id
|
117
|
+
end
|
118
|
+
|
119
|
+
def initialize(data, id)
|
120
|
+
@encode_date = data['encode_date']
|
121
|
+
@frame_rate = data['frame_rate']
|
122
|
+
@height = data['height']
|
123
|
+
@date_last_modified = data['date_last_modified']
|
124
|
+
@video_bitrate_mode = data['video_bitrate_mode']
|
125
|
+
@media_type = data['media_type']
|
126
|
+
@id = data['account_id']
|
127
|
+
@account_id = data['account_id']
|
128
|
+
@number_of_views = data['number_of_views']
|
129
|
+
@application = data['application']
|
130
|
+
@audio_codec = data['audio_codec']
|
131
|
+
@permalink_location = data['permalink_location']
|
132
|
+
@status = data['status']
|
133
|
+
@description = data['description']
|
134
|
+
@video_duration = data['video_duration']
|
135
|
+
@abstract_file_id = data['abstract_file_id']
|
136
|
+
@version_id = data['version_id']
|
137
|
+
@date_retrieved = data['date_retrieved']
|
138
|
+
@audio_data_rate = data['audio_data_rate']
|
139
|
+
@audio_bitrate_mode = data['audio_bitrate_mode']
|
140
|
+
@video_codec = data['video_codec']
|
141
|
+
@display_name = data['display_name']
|
142
|
+
@name = data['name']
|
143
|
+
@video_data_rate = data['video_data_rate']
|
144
|
+
@author_id = data['author_id']
|
145
|
+
@width = data['width']
|
146
|
+
@file_size = data['file_size']
|
147
|
+
@thumbnail_image_url = data['thumbnail_image_url']
|
148
|
+
@direct_asset_url = data['direct_asset_url']
|
149
|
+
@groups = data['groups']
|
150
|
+
@id = id
|
151
|
+
@metadata = id
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|