Sha256: bc4795914437698451ef09293656b7e708c259e46fb7c2d835889d074aaa567f

Contents?: true

Size: 853 Bytes

Versions: 2

Compression:

Stored size: 853 Bytes

Contents

require 'filestack/models/filelink'
require 'filestack/utils/utils'

# Class for AV objects -- allows to check status
# and upgrade to filelink once completed
class AV
  include UploadUtils
  attr_reader :apikey, :security

  def initialize(url, apikey: nil, security: nil)
    @url = url
    @apikey = apikey
    @security = security
  end

  # Turns AV into filelink if video conversion is complete
  #
  # @return [Filestack::Filelink]
  def to_filelink
    return 'Video conversion incomplete' unless status == 'completed'
    response = UploadUtils.make_call(@url, 'get').body
    handle = response['data']['url'].split('/').last
    Filelink.new(handle, apikey: @apikey, security: @security)
  end

  # Checks the status of the video conversion
  #
  # @return [String]
  def status
    UploadUtils.make_call(@url, 'get').body['status']
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
filestack-2.0.1 lib/filestack/models/filestack_av.rb
filestack-2.0.0 lib/filestack/models/filestack_av.rb