animoto 1.0.0 → 1.1.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.
Files changed (40) hide show
  1. data/README.md +95 -27
  2. data/lib/animoto/client.rb +48 -26
  3. data/lib/animoto/http_engines/base.rb +2 -14
  4. data/lib/animoto/http_engines/curl_adapter.rb +11 -2
  5. data/lib/animoto/http_engines/net_http_adapter.rb +15 -7
  6. data/lib/animoto/http_engines/patron_adapter.rb +1 -2
  7. data/lib/animoto/http_engines/rest_client_adapter.rb +2 -2
  8. data/lib/animoto/http_engines/typhoeus_adapter.rb +4 -3
  9. data/lib/animoto/manifests/base.rb +53 -3
  10. data/lib/animoto/manifests/directing.rb +6 -19
  11. data/lib/animoto/manifests/directing_and_rendering.rb +6 -19
  12. data/lib/animoto/manifests/rendering.rb +3 -16
  13. data/lib/animoto/manifests/storyboard_bundling.rb +40 -0
  14. data/lib/animoto/manifests/storyboard_unbundling.rb +39 -0
  15. data/lib/animoto/resources/base.rb +2 -2
  16. data/lib/animoto/resources/jobs/base.rb +8 -0
  17. data/lib/animoto/resources/jobs/directing.rb +0 -2
  18. data/lib/animoto/resources/jobs/directing_and_rendering.rb +0 -2
  19. data/lib/animoto/resources/jobs/rendering.rb +0 -2
  20. data/lib/animoto/resources/jobs/storyboard_bundling.rb +29 -0
  21. data/lib/animoto/resources/jobs/storyboard_unbundling.rb +34 -0
  22. data/lib/animoto/support/content_type.rb +1 -1
  23. data/lib/animoto/support/dynamic_class_loader.rb +1 -1
  24. data/lib/animoto/support/errors.rb +29 -0
  25. data/lib/animoto/support/hash.rb +2 -2
  26. data/lib/animoto/support/standard_envelope.rb +4 -2
  27. data/lib/animoto/support/string.rb +2 -2
  28. data/lib/animoto/support/visual.rb +1 -1
  29. data/lib/animoto.rb +1 -1
  30. data/spec/animoto/client_spec.rb +221 -9
  31. data/spec/animoto/http_engines/base_spec.rb +1 -14
  32. data/spec/animoto/manifests/rendering_spec.rb +1 -1
  33. data/spec/animoto/manifests/storyboard_bundling_spec.rb +73 -0
  34. data/spec/animoto/manifests/storyboard_unbundling_spec.rb +71 -0
  35. data/spec/animoto/resources/base_spec.rb +2 -2
  36. data/spec/animoto/resources/jobs/storyboard_bundling_spec.rb +43 -0
  37. data/spec/animoto/resources/jobs/storyboard_unbundling_spec.rb +48 -0
  38. data/spec/spec_helper.rb +4 -3
  39. metadata +14 -7
  40. data/integration/test.rb +0 -49
@@ -16,17 +16,9 @@ module Animoto
16
16
  attr_accessor :format
17
17
 
18
18
  # The storyboard this rendering targets.
19
- # @return [Assets::Storyboard]
19
+ # @return [Resources::Storyboard]
20
20
  attr_accessor :storyboard
21
21
 
22
- # A URL to receive a callback after directing is finished.
23
- # @return [String]
24
- attr_accessor :http_callback_url
25
-
26
- # The format of the callback; either 'xml' or 'json'.
27
- # @return [String]
28
- attr_accessor :http_callback_format
29
-
30
22
  # Creates a new rendering manifest.
31
23
  #
32
24
  # @param [Resources::Storyboard] storyboard the storyboard for this rendering
@@ -39,12 +31,11 @@ module Animoto
39
31
  # @return [Manifests::Rendering] the manifest
40
32
  def initialize *args
41
33
  options = args.last.is_a?(Hash) ? args.pop : {}
34
+ super(options)
42
35
  @storyboard = args.shift
43
36
  @resolution = options[:resolution]
44
37
  @framerate = options[:framerate]
45
38
  @format = options[:format]
46
- @http_callback_url = options[:http_callback_url]
47
- @http_callback_format = options[:http_callback_format]
48
39
  end
49
40
 
50
41
  # Returns a representation of this manifest as a Hash.
@@ -54,11 +45,7 @@ module Animoto
54
45
  def to_hash
55
46
  hash = { 'rendering_job' => { 'rendering_manifest' => { 'rendering_parameters' => {} } } }
56
47
  job = hash['rendering_job']
57
- if http_callback_url
58
- raise ArgumentError, "You must specify a http_callback_format (either 'xml' or 'json')" if http_callback_format.nil?
59
- job['http_callback'] = http_callback_url
60
- job['http_callback_format'] = http_callback_format
61
- end
48
+ add_callback_information job
62
49
  manifest = job['rendering_manifest']
63
50
  manifest['storyboard_url'] = storyboard.url if storyboard
64
51
  params = manifest['rendering_parameters']
@@ -0,0 +1,40 @@
1
+ module Animoto
2
+ module Manifests
3
+ class StoryboardBundling < Animoto::Manifests::Base
4
+
5
+ # The storyboard to be bundled
6
+ # @return [Resources::Storyboard]
7
+ attr_accessor :storyboard
8
+
9
+ # Creates a new storyboard bundling manifest.
10
+ # A storyboard bundle is a archive of the assets and directorial decisions associated
11
+ # with this project. Once a storyboard is bundled, if the original storyboard on Animoto's
12
+ # servers expires or is deleted, the storyboard can be reconstructed from the bundle and
13
+ # the video can be rendered.
14
+ #
15
+ # @param [Resources::Storyboard] storyboard the storyboard to bundle
16
+ # @param [Hash{Symbol=>Object}] options
17
+ # @option options [String] :http_callback_url a URL to receive a callback when this job is done
18
+ # @option options [String] :http_callback_format the format of the callback
19
+ def initialize *args
20
+ options = args.last.is_a?(Hash) ? args.pop : {}
21
+ super(options)
22
+ @storyboard = args.shift
23
+ end
24
+
25
+ # Returns a representation of this manifest as a Hash.
26
+ #
27
+ # @return [Hash{String=>Object}] this manifest as a Hash
28
+ # @raise [ArgumentError] if a callback URL is specified but not the format
29
+ def to_hash
30
+ hash = { 'storyboard_bundling_job' => { 'storyboard_bundling_manifest' => {} } }
31
+ job = hash['storyboard_bundling_job']
32
+ add_callback_information job
33
+ manifest = job['storyboard_bundling_manifest']
34
+ manifest['storyboard_url'] = storyboard.url if storyboard
35
+ hash
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,39 @@
1
+ module Animoto
2
+ module Manifests
3
+ class StoryboardUnbundling < Animoto::Manifests::Base
4
+
5
+ # The URL to the storyboard bundle
6
+ # @return [String]
7
+ attr_accessor :bundle_url
8
+
9
+ # Creates a new storyboard unbundling manifest
10
+ # Unbundling a storyboard "rehydrates" the assets and directorial decisions associated with
11
+ # this project, allowing the video to be rendered even if the original storyboard or visual
12
+ # assets have expired or been deleted on Animoto's servers since they were created the first
13
+ # time.
14
+ #
15
+ # @param [Hash{Symbol=>Object}] options
16
+ # @option options [String] :bundle_url the URL pointing to a storyboard bundle
17
+ # @option options [String] :http_callback_url a URL to receive a callback when this job is done
18
+ # @option options [String] :http_callback_format the format of the callback
19
+ def initialize options = {}
20
+ super
21
+ @bundle_url = options[:bundle_url]
22
+ end
23
+
24
+ # Returns a representation of this manifest as a Hash.
25
+ #
26
+ # @return [Hash{String=>Object}] this manifest as a Hash
27
+ # @raise [ArgumentError] if a callback URL is specified but not the format
28
+ def to_hash
29
+ hash = { 'storyboard_unbundling_job' => { 'storyboard_unbundling_manifest' => {} } }
30
+ job = hash['storyboard_unbundling_job']
31
+ add_callback_information job
32
+ manifest = job['storyboard_unbundling_manifest']
33
+ manifest['bundle_url'] = bundle_url
34
+ hash
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -48,8 +48,8 @@ module Animoto
48
48
  #
49
49
  # @example
50
50
  # client = Animoto::Client.new
51
- # storyboard1 = Animoto::Resources::Storyboard.new :url => "https://api.animoto.com/storyboards/1"
52
- # storyboard2 = client.find! Animoto::Resources::Storyboard, "https://api.animoto.com/storyboards/1"
51
+ # storyboard1 = Animoto::Resources::Storyboard.new :url => "https://platform.animoto.com/storyboards/1"
52
+ # storyboard2 = client.find! Animoto::Resources::Storyboard, "https://platform.animoto.com/storyboards/1"
53
53
  # storyboard1.equal?(storyboard2) # => true
54
54
  #
55
55
  # @param [Hash{String=>Object}] attributes a hash of attributes for this resource
@@ -15,6 +15,14 @@ module Animoto
15
15
  super + '_job'
16
16
  end
17
17
 
18
+ def self.endpoint path = nil
19
+ super || infer_endpoint
20
+ end
21
+
22
+ def self.infer_endpoint
23
+ "/jobs/#{name.split('::').last.underscore}"
24
+ end
25
+
18
26
  # The URL for this job.
19
27
  # @return [String]
20
28
  attr_reader :url
@@ -2,8 +2,6 @@ module Animoto
2
2
  module Resources
3
3
  module Jobs
4
4
  class Directing < Animoto::Resources::Jobs::Base
5
-
6
- endpoint '/jobs/directing'
7
5
 
8
6
  # @return [Hash{Symbol=>Object}]
9
7
  # @see Animoto::Support::StandardEnvelope::ClassMethods#unpack_standard_envelope
@@ -3,8 +3,6 @@ module Animoto
3
3
  module Jobs
4
4
  class DirectingAndRendering < Animoto::Resources::Jobs::Base
5
5
 
6
- endpoint '/jobs/directing_and_rendering'
7
-
8
6
  # @return [Hash{Symbol=>Object}]
9
7
  # @see Animoto::Support::StandardEnvelope::ClassMethods#unpack_standard_envelope
10
8
  def self.unpack_standard_envelope body = {}
@@ -3,8 +3,6 @@ module Animoto
3
3
  module Jobs
4
4
  class Rendering < Animoto::Resources::Jobs::Base
5
5
 
6
- endpoint '/jobs/rendering'
7
-
8
6
  # @return [Hash{Symbol=>Object}]
9
7
  # @see Animoto::Support::StandardEvelope::ClassMethods#unpack_standard_envelope
10
8
  def self.unpack_standard_envelope body
@@ -0,0 +1,29 @@
1
+ module Animoto
2
+ module Resources
3
+ module Jobs
4
+ class StoryboardBundling < Animoto::Resources::Jobs::Base
5
+
6
+ # @return [Hash{Symbol=>Object}]
7
+ # @see Animoto::Support::StandardEvelope::ClassMethods#unpack_standard_envelope
8
+ def self.unpack_standard_envelope body
9
+ links = unpack_links(body)
10
+ super.merge({
11
+ :bundle_url => links['bundle']
12
+ })
13
+ end
14
+
15
+ # The URL to the storyboard resource.
16
+ # @return [String]
17
+ attr_reader :bundle_url
18
+
19
+ # @return [Jobs::StoryboardBundling]
20
+ # @see Animoto::Jobs::Base#instantiate
21
+ def instantiate attributes = {}
22
+ @bundle_url = attributes[:bundle_url]
23
+ super
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,34 @@
1
+ module Animoto
2
+ module Resources
3
+ module Jobs
4
+ class StoryboardUnbundling < Animoto::Resources::Jobs::Base
5
+
6
+ # @return [Hash{Symbol=>Object}]
7
+ # @see Animoto::Support::StandardEvelope::ClassMethods#unpack_standard_envelope
8
+ def self.unpack_standard_envelope body
9
+ links = unpack_links(body)
10
+ super.merge({
11
+ :storyboard_url => links['storyboard']
12
+ })
13
+ end
14
+
15
+ # The storyboard created by this job.
16
+ # @return [Resources::Storyboard]
17
+ attr_reader :storyboard
18
+
19
+ # The URL to the storyboard resource.
20
+ # @return [String]
21
+ attr_reader :storyboard_url
22
+
23
+ # @return [Jobs::StoryboardUnbundling]
24
+ # @see Animoto::Jobs::Base#instantiate
25
+ def instantiate attributes = {}
26
+ @storyboard_url = attributes[:storyboard_url]
27
+ @storyboard = Animoto::Resources::Storyboard.new(:url => @storyboard_url) if @storyboard_url
28
+ super
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -42,7 +42,7 @@ module Animoto
42
42
  #
43
43
  # @return [String] the inferred content type
44
44
  def infer_content_type
45
- name.split('::').last.gsub(/(^)?([A-Z])/) { "#{'_' unless $1}#{$2.downcase}" }
45
+ name.split('::').last.underscore
46
46
  end
47
47
  end
48
48
  end
@@ -2,7 +2,7 @@ module Animoto
2
2
  module Support
3
3
  module DynamicClassLoader
4
4
 
5
- # Retrieves the adapter class that the name corresponds to. The name in case- and
5
+ # Retrieves the adapter class that the name corresponds to. The name is case- and
6
6
  # punctuation-insensitive, meaning "SomeModule", "some_module", and "somemodule"
7
7
  # are all treated as the same.
8
8
  #
@@ -6,4 +6,33 @@ module Animoto
6
6
  # Raised when an abstract method is called.
7
7
  class AbstractMethodError < Animoto::Error
8
8
  end
9
+
10
+ # Raised when something goes wrong over HTTP
11
+ class HTTPError < Animoto::Error
12
+ CODE_STRINGS = Hash.new("Error").merge({
13
+ 400 => "Bad Request",
14
+ 401 => "Unauthorized",
15
+ 403 => "Forbidden",
16
+ 404 => "Not Found",
17
+ 405 => "Method Not Allowed",
18
+ 406 => "Not Acceptable",
19
+ 410 => "Gone",
20
+ 411 => "Length Required",
21
+ 413 => "Request Entity Too Large",
22
+ 415 => "Unsupported Media Type",
23
+ 500 => "Internal Server Error",
24
+ 501 => "Not Implemented",
25
+ 503 => "Service Unavailable"
26
+ })
27
+
28
+ attr_reader :url, :code, :details
29
+
30
+ def initialize url, code, body
31
+ @url, @code = url, code
32
+ @details = body['response']['status']['errors'] rescue []
33
+ str = "HTTP #{@code} (#{CODE_STRINGS[@code]}) when requesting #{@url.inspect}"
34
+ str += "\n#{@details.join("\n")}" unless @details.empty?
35
+ super str
36
+ end
37
+ end
9
38
  end
@@ -8,7 +8,7 @@ module Animoto
8
8
  # @return [Hash{Object=>Object}] a new hash with only the listed keys
9
9
  def only *keys
10
10
  self.delete_if { |k,v| !keys.include?(k) }
11
- end
11
+ end unless {}.respond_to?(:only)
12
12
 
13
13
  # Returns a new hash with all keys from this hash except the listed ones.
14
14
  #
@@ -16,7 +16,7 @@ module Animoto
16
16
  # @return [Hash{Object=>Object}] a new hash without the listed keys
17
17
  def except *keys
18
18
  self.delete_if { |k,v| keys.include?(v) }
19
- end
19
+ end unless {}.respond_to?(:except)
20
20
 
21
21
  end
22
22
  end
@@ -22,10 +22,10 @@ module Animoto
22
22
  # @param [Hash{String=>Object}] envelope a 'standard envelope' hash
23
23
  # @return [Class, nil] the class, or nil if either the payload key or the class couldn't be found
24
24
  def self.find_class_for envelope
25
- if payload_key = ((envelope['response'] || {})['payload'] || {}).keys.first
25
+ if payload_key = unpack_base_payload(envelope).keys.first
26
26
  klass_name = payload_key.camelize
27
27
  if /(?:Job|Callback)$/ === klass_name
28
- Animoto::Jobs::const_get(klass_name) if Animoto::Jobs::const_defined?(klass_name)
28
+ Animoto::Resources::Jobs::const_get(klass_name) if Animoto::Resources::Jobs::const_defined?(klass_name)
29
29
  else
30
30
  Animoto::Resources::const_get(klass_name) if Animoto::Resources::const_defined?(klass_name)
31
31
  end
@@ -112,6 +112,8 @@ module Animoto
112
112
  }
113
113
  end
114
114
  end
115
+
116
+ extend ClassMethods
115
117
  end
116
118
  end
117
119
  end
@@ -11,7 +11,7 @@ module Animoto
11
11
  # @return [String] the camel case form of this string
12
12
  def camelize
13
13
  self.gsub(/(?:^|_)(.)/) { $1.upcase }
14
- end
14
+ end unless "".respond_to?(:camelize)
15
15
 
16
16
  # Transforms this string from camel case to underscore-form. Downcases the
17
17
  # entire string.
@@ -22,7 +22,7 @@ module Animoto
22
22
  # @return [String] the underscored form of this string
23
23
  def underscore
24
24
  self.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
25
- end
25
+ end unless "".respond_to?(:underscore)
26
26
 
27
27
  end
28
28
  end
@@ -23,7 +23,7 @@ module Animoto
23
23
  def to_hash
24
24
  hash = super rescue {}
25
25
  hash['spotlit'] = spotlit? unless @spotlit.nil?
26
- hash['type'] = self.class.name.split('::').last.gsub(/(^)?([A-Z])/) { "#{'_' unless $1}#{$2.downcase}" }
26
+ hash['type'] = self.class.name.split('::').last.underscore
27
27
  hash
28
28
  end
29
29
 
data/lib/animoto.rb CHANGED
@@ -6,6 +6,6 @@ module Animoto
6
6
  #
7
7
  # @return [String]
8
8
  def self.version
9
- "1.0.0"
9
+ "1.1.0"
10
10
  end
11
11
  end
@@ -19,8 +19,8 @@ describe Animoto::Client do
19
19
  end
20
20
 
21
21
  it "should accept an endpoint as an option" do
22
- c = Animoto::Client.new "key", "secret", :endpoint => "https://api.animoto.com/"
23
- c.endpoint.should == "https://api.animoto.com/"
22
+ c = Animoto::Client.new "key", "secret", :endpoint => "https://platform.animoto.com/"
23
+ c.endpoint.should == "https://platform.animoto.com/"
24
24
  end
25
25
 
26
26
  describe "when the secret isn't specified (i.e. only 1 parameter was passed)" do
@@ -46,7 +46,7 @@ describe Animoto::Client do
46
46
  @here_path = File.expand_path("./.animotorc")
47
47
  @home_path = File.expand_path("~/.animotorc")
48
48
  @etc_path = "/etc/.animotorc"
49
- @config = "key: joe\nsecret: secret\nendpoint: https://api.animoto.com/"
49
+ @config = "key: joe\nsecret: secret\nendpoint: https://platform.animoto.com/"
50
50
  end
51
51
 
52
52
  describe "when ./.animotorc exists" do
@@ -59,7 +59,7 @@ describe Animoto::Client do
59
59
  c = Animoto::Client.new
60
60
  c.key.should == "joe"
61
61
  c.secret.should == "secret"
62
- c.endpoint.should == "https://api.animoto.com/"
62
+ c.endpoint.should == "https://platform.animoto.com/"
63
63
  end
64
64
  end
65
65
 
@@ -78,7 +78,7 @@ describe Animoto::Client do
78
78
  c = Animoto::Client.new
79
79
  c.key.should == "joe"
80
80
  c.secret.should == "secret"
81
- c.endpoint.should == "https://api.animoto.com/"
81
+ c.endpoint.should == "https://platform.animoto.com/"
82
82
  end
83
83
  end
84
84
 
@@ -112,7 +112,7 @@ describe Animoto::Client do
112
112
 
113
113
  describe "finding an instance by identifier" do
114
114
  before do
115
- @url = "https://joe:secret@api.animoto.com/storyboards/1"
115
+ @url = "https://joe:secret@platform.animoto.com/storyboards/1"
116
116
  hash = {'response'=>{'status'=>{'code'=>200},'payload'=>{'storyboard'=>{'links'=>{'self'=>@url,'preview'=>'http://animoto.com/preview/1.mp4'},'metadata'=>{'duration'=>100,'visuals_count'=>1}}}}}
117
117
  body = client.response_parser.unparse(hash)
118
118
  stub_request(:get, @url).to_return(:body => body, :status => [200,"OK"])
@@ -140,17 +140,229 @@ describe Animoto::Client do
140
140
 
141
141
  describe "reloading an instance" do
142
142
  before do
143
- @url = 'https://joe:secret@api.animoto.com/jobs/directing/1'
143
+ @url = 'https://joe:secret@platform.animoto.com/jobs/directing/1'
144
144
  @job = Animoto::Resources::Jobs::Directing.new :state => 'initial', :url => @url
145
- hash = {'response'=>{'status'=>{'code'=>200},'payload'=>{'directing_job'=>{'state'=>'retrieving_assets','links'=>{'self'=>@url,'storyboard'=>'http://api.animoto.com/storyboards/1'}}}}}
145
+ hash = {'response'=>{'status'=>{'code'=>200},'payload'=>{'directing_job'=>{'state'=>'retrieving_assets','links'=>{'self'=>@url,'storyboard'=>'https://platform.animoto.com/storyboards/1'}}}}}
146
146
  body = client.response_parser.unparse(hash)
147
147
  stub_request(:get, @url).to_return(:body => body, :status => [200,"OK"])
148
148
  @job.state.should == 'initial' # sanity check
149
149
  end
150
150
 
151
+ it "should make a GET request to the resource's url" do
152
+ client.reload!(@job)
153
+ WebMock.should have_requested(:get, @job.url)
154
+ end
155
+
156
+ it "should ask for a response in the proper format" do
157
+ client.reload!(@job)
158
+ WebMock.should have_requested(:get, @job.url).with(:headers => { 'Accept' => "application/vnd.animoto.directing_job-v1+json" })
159
+ end
160
+
161
+ it "should not send a request body" do
162
+ client.reload!(@job)
163
+ WebMock.should have_requested(:get, @job.url).with(:body => "")
164
+ end
165
+
151
166
  it "should update the resource's attributes" do
152
167
  client.reload!(@job)
153
168
  @job.state.should == 'retrieving_assets'
154
169
  end
155
- end
170
+ end
171
+
172
+ describe "deleting an instance" do
173
+ before do
174
+ @url = 'https://joe:secret@platform.animoto.com/storyboards/1'
175
+ @storyboard = Animoto::Resources::Storyboard.new :url => @url
176
+ stub_request(:delete, @url).to_return(:body => nil, :status => [204,"No Content"])
177
+ end
178
+
179
+ it "should make a DELETE request to the resource's url" do
180
+ client.delete!(@storyboard)
181
+ WebMock.should have_requested(:delete, @storyboard.url)
182
+ end
183
+
184
+ it "should not send a request body" do
185
+ client.delete!(@storyboard)
186
+ WebMock.should have_requested(:delete, @storyboard.url).with(:body => "")
187
+ end
188
+
189
+ it "should return true if successful" do
190
+ client.delete!(@storyboard).should equal(true)
191
+ end
192
+
193
+ it "should raise an error if unsuccessful" do
194
+ stub_request(:delete, @url).to_return(:body => nil, :status => [404,"Not Found"])
195
+ lambda { client.delete!(@storyboard) }.should raise_error(Animoto::HTTPError)
196
+ end
197
+ end
198
+
199
+ describe "directing" do
200
+ before do
201
+ @manifest = Animoto::Manifests::Directing.new
202
+ hash = {'response'=>{'status'=>{'code'=>201},'payload'=>{'directing_job'=>{'state'=>'retrieving_assets','links'=>{'self'=>'https://platform.animoto.com/jobs/directing/1'}}}}}
203
+ body = client.response_parser.unparse(hash)
204
+ @endpoint = client.endpoint.sub('https://','https://joe:secret@').chomp('/') + Animoto::Resources::Jobs::Directing.endpoint
205
+ stub_request(:post, @endpoint).to_return(:body => body, :status => [201,"Created"])
206
+ end
207
+
208
+ it "should make a POST request to the directing jobs' endpoint" do
209
+ client.direct!(@manifest)
210
+ WebMock.should have_requested(:post, @endpoint)
211
+ end
212
+
213
+ it "should ask for a response in the proper format" do
214
+ client.direct!(@manifest)
215
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Accept" => "application/vnd.animoto.directing_job-v1+json" })
216
+ end
217
+
218
+ it "should send the serialized manifest as the request body" do
219
+ client.direct!(@manifest)
220
+ WebMock.should have_requested(:post, @endpoint).with(:body => client.response_parser.unparse(@manifest.to_hash))
221
+ end
222
+
223
+ it "should give the request body in the proper format" do
224
+ client.direct!(@manifest)
225
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Content-Type" => "application/vnd.animoto.directing_manifest-v1+json" })
226
+ end
227
+
228
+ it "should return a directing job" do
229
+ client.direct!(@manifest).should be_an_instance_of(Animoto::Resources::Jobs::Directing)
230
+ end
231
+ end
232
+
233
+ describe "rendering" do
234
+ before do
235
+ @manifest = Animoto::Manifests::Rendering.new
236
+ hash = {'response'=>{'status'=>{'code'=>201},'payload'=>{'rendering_job'=>{'state'=>'rendering','links'=>{'self'=>'https://platform.animoto.com/jobs/rendering/1'}}}}}
237
+ body = client.response_parser.unparse(hash)
238
+ @endpoint = client.endpoint.sub('https://','https://joe:secret@').chomp('/') + Animoto::Resources::Jobs::Rendering.endpoint
239
+ stub_request(:post, @endpoint).to_return(:body => body, :status => [201,"Created"])
240
+ end
241
+
242
+ it "should make a POST request to the rendering jobs' endpoint" do
243
+ client.render!(@manifest)
244
+ WebMock.should have_requested(:post, @endpoint)
245
+ end
246
+
247
+ it "should ask for a response in the proper format" do
248
+ client.render!(@manifest)
249
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Accept" => "application/vnd.animoto.rendering_job-v1+json" })
250
+ end
251
+
252
+ it "should send the serialized manifest as the request body" do
253
+ client.render!(@manifest)
254
+ WebMock.should have_requested(:post, @endpoint).with(:body => client.response_parser.unparse(@manifest.to_hash))
255
+ end
256
+
257
+ it "should give the request body in the proper format" do
258
+ client.render!(@manifest)
259
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Content-Type" => "application/vnd.animoto.rendering_manifest-v1+json" })
260
+ end
261
+
262
+ it "should return a rendering job" do
263
+ client.render!(@manifest).should be_an_instance_of(Animoto::Resources::Jobs::Rendering)
264
+ end
265
+ end
266
+
267
+ describe "directing and rendering" do
268
+ before do
269
+ @manifest = Animoto::Manifests::DirectingAndRendering.new
270
+ hash = {'response'=>{'status'=>{'code'=>201},'payload'=>{'directing_and_rendering_job'=>{'state'=>'retrieving_assets','links'=>{'self'=>'https://platform.animoto.com/jobs/directing_and_rendering/1'}}}}}
271
+ body = client.response_parser.unparse(hash)
272
+ @endpoint = client.endpoint.sub('https://','https://joe:secret@').chomp('/') + Animoto::Resources::Jobs::DirectingAndRendering.endpoint
273
+ stub_request(:post, @endpoint).to_return(:body => body, :status => [201,"Created"])
274
+ end
275
+
276
+ it "should make a POST request to the directing_and_rendering jobs' endpoint" do
277
+ client.direct_and_render!(@manifest)
278
+ WebMock.should have_requested(:post, @endpoint)
279
+ end
280
+
281
+ it "should ask for a response in the proper format" do
282
+ client.direct_and_render!(@manifest)
283
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Accept" => "application/vnd.animoto.directing_and_rendering_job-v1+json" })
284
+ end
285
+
286
+ it "should send the serialized manifest as the request body" do
287
+ client.direct_and_render!(@manifest)
288
+ WebMock.should have_requested(:post, @endpoint).with(:body => client.response_parser.unparse(@manifest.to_hash))
289
+ end
290
+
291
+ it "should give the request body in the proper format" do
292
+ client.direct_and_render!(@manifest)
293
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Content-Type" => "application/vnd.animoto.directing_and_rendering_manifest-v1+json" })
294
+ end
295
+
296
+ it "should return a directing job" do
297
+ client.direct_and_render!(@manifest).should be_an_instance_of(Animoto::Resources::Jobs::DirectingAndRendering)
298
+ end
299
+ end
300
+
301
+ describe "bundling" do
302
+ before do
303
+ @manifest = Animoto::Manifests::StoryboardBundling.new
304
+ hash = {'response'=>{'status'=>{'code'=>201},'payload'=>{'storyboard_bundling_job'=>{'state'=>'bundling','links'=>{'self'=>'https://platform.animoto.com/jobs/storyboard_bundling/1'}}}}}
305
+ body = client.response_parser.unparse(hash)
306
+ @endpoint = client.endpoint.sub('https://','https://joe:secret@').chomp('/') + Animoto::Resources::Jobs::StoryboardBundling.endpoint
307
+ stub_request(:post, @endpoint).to_return(:body => body, :status => [201,"Created"])
308
+ end
309
+
310
+ it "should make a POST request to the bundling jobs' endpoint" do
311
+ client.bundle!(@manifest)
312
+ WebMock.should have_requested(:post, @endpoint)
313
+ end
314
+
315
+ it "should ask for a response in the proper format" do
316
+ client.bundle!(@manifest)
317
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Accept" => "application/vnd.animoto.storyboard_bundling_job-v1+json" })
318
+ end
319
+
320
+ it "should send the serialized manifest as the request body" do
321
+ client.bundle!(@manifest)
322
+ WebMock.should have_requested(:post, @endpoint).with(:body => client.response_parser.unparse(@manifest.to_hash))
323
+ end
324
+
325
+ it "should give the request body in the proper format" do
326
+ client.bundle!(@manifest)
327
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Content-Type" => "application/vnd.animoto.storyboard_bundling_manifest-v1+json" })
328
+ end
329
+
330
+ it "should return a directing job" do
331
+ client.bundle!(@manifest).should be_an_instance_of(Animoto::Resources::Jobs::StoryboardBundling)
332
+ end
333
+ end
334
+
335
+ describe "unbundling" do
336
+ before do
337
+ @manifest = Animoto::Manifests::StoryboardUnbundling.new
338
+ hash = {'response'=>{'status'=>{'code'=>201},'payload'=>{'storyboard_unbundling_job'=>{'state'=>'unbundling','links'=>{'self'=>'https://platform.animoto.com/jobs/storyboard_unbundling/1'}}}}}
339
+ body = client.response_parser.unparse(hash)
340
+ @endpoint = client.endpoint.sub('https://','https://joe:secret@').chomp('/') + Animoto::Resources::Jobs::StoryboardUnbundling.endpoint
341
+ stub_request(:post, @endpoint).to_return(:body => body, :status => [201,"Created"])
342
+ end
343
+
344
+ it "should make a POST request to the storyboard unbundling jobs' endpoint" do
345
+ client.unbundle!(@manifest)
346
+ WebMock.should have_requested(:post, @endpoint)
347
+ end
348
+
349
+ it "should ask for a response in the proper format" do
350
+ client.unbundle!(@manifest)
351
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Accept" => "application/vnd.animoto.storyboard_unbundling_job-v1+json" })
352
+ end
353
+
354
+ it "should send the serialized manifest as the request body" do
355
+ client.unbundle!(@manifest)
356
+ WebMock.should have_requested(:post, @endpoint).with(:body => client.response_parser.unparse(@manifest.to_hash))
357
+ end
358
+
359
+ it "should give the request body in the proper format" do
360
+ client.unbundle!(@manifest)
361
+ WebMock.should have_requested(:post, @endpoint).with(:headers => { "Content-Type" => "application/vnd.animoto.storyboard_unbundling_manifest-v1+json" })
362
+ end
363
+
364
+ it "should return a directing job" do
365
+ client.unbundle!(@manifest).should be_an_instance_of(Animoto::Resources::Jobs::StoryboardUnbundling)
366
+ end
367
+ end
156
368
  end