./lib/animoto/resources/video.rb in animoto-0.1.1.beta1 vs ./lib/animoto/resources/video.rb in animoto-1.0.0
- old
+ new
@@ -1,45 +1,67 @@
module Animoto
module Resources
class Video < Animoto::Resources::Base
+
+ # @private
+ # @return [Hash{String=>Object}]
+ # @see Animoto::Support::StandardEnvelope::ClassMethods#unpack_standard_envelope
+ def self.unpack_rendering_parameters body
+ (unpack_payload(body)['metadata'] || {})['rendering_parameters']
+ end
- # @return [Hash<Symbol,Object>]
+ # @return [Hash{Symbol=>Object}]
# @see Animoto::Support::StandardEnvelope::ClassMethods#unpack_standard_envelope
def self.unpack_standard_envelope body
+ links = unpack_links(body)
+ params = unpack_rendering_parameters(body)
super.merge({
- :download_url => body['response']['payload'][payload_key]['links']['file'],
- :storyboard_url => body['response']['payload'][payload_key]['links']['storyboard'],
- :duration => body['response']['payload'][payload_key]['metadata']['duration'],
- :format => body['response']['payload'][payload_key]['metadata']['format'],
- :framerate => body['response']['payload'][payload_key]['metadata']['framerate'],
- :resolution => body['response']['payload'][payload_key]['metadata']['vertical_resolution']
+ :download_url => links['file'],
+ :storyboard_url => links['storyboard'],
+ :format => params['format'],
+ :framerate => params['framerate'],
+ :resolution => params['resolution']
})
end
+ # The URL to the video file.
+ # @return [String]
attr_reader :download_url
+
+ # The URL to the storyboard resource this video was rendered from.
+ # @return [String]
attr_reader :storyboard_url
+
+ # The Storyboard object this video was rendered from.
+ # @return [Resources::Storyboard]
attr_reader :storyboard
- attr_reader :duration
+
+ # The format of the video.
+ # @return [String]
attr_reader :format
+
+ # The framerate of the video.
+ # @return [Integer]
attr_reader :framerate
+
+ # The resolution of the video.
+ # @return [String]
attr_reader :resolution
# Sets the attributes on a new video.
#
- # @param [Hash<Symbol,Object>] attributes
+ # @param [Hash{Symbol=>Object}] attributes
# @option attributes [String] :download_url the URL where this video can be downloaded
# @option attributes [String] :storyboard_url the URL for this video's storyboard
- # @option attributes [Integer] :duration the duration (in seconds) of this video
# @option attributes [String] :format the format of this video
# @option attributes [Integer] :framerate the framerate of this video
# @option attributes [String] :resolution the vertical resolution of this video
# @return [Resources::Video] the video
# @see Animoto::Resources::Base#instantiate
def instantiate attributes = {}
@download_url = attributes[:download_url]
@storyboard_url = attributes[:storyboard_url]
@storyboard = Animoto::Resources::Storyboard.new(:url => @storyboard_url) if @storyboard_url
- @duration = attributes[:duration]
@format = attributes[:format]
@framerate = attributes[:framerate]
@resolution = attributes[:resolution]
super
end
\ No newline at end of file