Sha256: 2ec105a223fff8078304d881681fcd0c0dc8898e2e905a3e7c265024e0018d9c

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

module VzaarApi
  class Video < Abstract
    ENDPOINT = 'videos'

    ATTR_READERS = [:id, :user_id, :account_id, :categories,
                    :renditions, :legacy_renditions, :url,
                    :thumbnail_url, :state,
                    :created_at, :updated_at].freeze

    ATTR_ACCESSORS = [:category_ids, :description, :private, :seo_url, :title].freeze

    prepend Lib::HasAttributes
    include Lib::HasResourceUrl
    include Lib::ActiveObject::Find
    include Lib::ActiveObject::Save
    include Lib::ActiveObject::Delete
    include Lib::WillPaginate

    def initialize(attrs = {})
      update_from_attributes attrs
    end

    def self.create(attrs = {})
      Strategy::Video::Create.new(attrs, self).execute
    end

    def self.set_image_frame(video_id, attrs = {})
      Strategy::Image::Update.new(video_id, attrs, self).execute
    end

    def self.upload_image_frame(video_id, attrs = {})
      Strategy::Image::Create.new(video_id, attrs, self).execute
    end

    private

    def update_from_attributes(attrs)
      @categories = Category.build(attrs[:categories])
      @category_ids = @categories.map(&:id)
      @renditions = Rendition.build(attrs[:renditions])
      @legacy_renditions = LegacyRendition.build(attrs[:renditions])
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vzaar_api-2.0.1 lib/vzaar_api/video.rb