lib/sorenson/services/asset.rb in 360_services-0.0.1 vs lib/sorenson/services/asset.rb in 360_services-0.0.2

- old
+ new

@@ -9,19 +9,20 @@ attr_accessor :encode_date, :frame_rate, :height, :date_last_modified, :video_bitrate_mode, :media_type, :id, :account_id, :number_of_views, :application, :audio_codec, :permalink_location, :status, :description, :video_duration, :abstract_file_id, :version_id, :date_retrieved, :audio_data_rate, :audio_bitrate_mode, :video_codec, :display_name, :name, :video_data_rate, :author_id, :width, :file_size, :thumbnail_image_url, :direct_asset_url, - :password, :metadata, :groups + :password, :metadata, :groups, :embed_list # Get all of the assets as a list of guids. Use offset and quantity to return subsets. # Sorenson::Services::Account.login('username', 'password') # assets = Sorenson::Services::Asset.all # names = assets.collect {|asset| asset.name} # => names = ["name1", "name2"] def self.all(offset = nil, quantity = nil) - get_from("/assets", :offset => offset, :quantity => quantity)["asset_list"] + list = get_from("/assets", :offset => offset, :quantity => quantity)["asset_list"] + list.collect {|a| new(a) } end # Get a list of asset guids by passing a tag name def self.find_all_by_tag(tag_name) get_from("/tags/#{tag_name}/assets") @@ -38,11 +39,11 @@ def self.count Base.get_from("/assets/count")["count"] end def self.find(id) - new(get_from("/assets/#{id}"), id) + new(get_from("/assets/#{id}")) end def preset_xml Base.get_from("/assets/#{id}/preset_xml")["preset_xml"] end @@ -111,21 +112,21 @@ def metadata Base.get_from("/assets/#{id}/metadata") end def group - Group.new(Base.get_from("/groups/#{@group_id}")) if group_id - end - - def initialize(data, id) + Group.new(Base.get_from("/groups/#{@group_id}")) if @group_id + end + + def initialize(data) @encode_date = data['encode_date'] @frame_rate = data['frame_rate'] @height = data['height'] @date_last_modified = data['date_last_modified'] @video_bitrate_mode = data['video_bitrate_mode'] @media_type = data['media_type'] - @id = data['account_id'] + @id = data['id'] @account_id = data['account_id'] @number_of_views = data['number_of_views'] @application = data['application'] @audio_codec = data['audio_codec'] @permalink_location = data['permalink_location'] @@ -144,12 +145,11 @@ @author_id = data['author_id'] @width = data['width'] @file_size = data['file_size'] @thumbnail_image_url = data['thumbnail_image_url'] @direct_asset_url = data['direct_asset_url'] - @groups = data['groups'] - @id = id - @metadata = id + @group_id = data['group_id'] + @embed_list = data['embed_list'] end end end end \ No newline at end of file