Sha256: 541fd12247ce717b4983da09c6e03c8f63062d6542b0d1aeba95cc92ce127691

Contents?: true

Size: 984 Bytes

Versions: 8

Compression:

Stored size: 984 Bytes

Contents

module Videojuicer
  module Asset
    def self.all(options = {})
      proxy = Videojuicer::OAuth::RequestProxy.new(Videojuicer.current_scope)
      
      if options[:page]
        options[:offset] = Videojuicer::Resource::Collection.offset_from_page_number options.delete(:page), options[:limit]
      end
      
      response = proxy.get("/assets", "asset" => options)
      items, count, offset, limit = JSON.parse(response.body).values_at("items", "count", "offset", "limit")
      assets = items.map { |i| const_get(i.delete("type").capitalize).new(i) }
      
      # TODO: this should really be taken care of in VJ:Resource::initialize
      #       then VJ::Resource::CMs.all can also omit this step
      assets.each { |a| a.clean_dirty_attributes! }
      
      Videojuicer::Resource::Collection.new(assets, count, offset, limit)
    end
    
    TYPES = %w(Audio Document Image Flash Text Video)
    def self.types
      TYPES.map { |t| const_get(t) }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vj-sdk-0.8.2 lib/videojuicer/asset.rb
vj-sdk-0.8.0.1 lib/videojuicer/asset.rb
vj-sdk-0.7.14 lib/videojuicer/asset.rb
vj-sdk-0.7.13 lib/videojuicer/asset.rb
vj-sdk-0.7.11 lib/videojuicer/asset.rb
vj-sdk-0.7.10 lib/videojuicer/asset.rb
vj-sdk-0.7.9 lib/videojuicer/asset.rb
vj-sdk-0.7.8 lib/videojuicer/asset.rb