Sha256: beb036d0dcd610c209a15163bbf705f709a51dbe9e36ec4e5766cf9e8b06752b

Contents?: true

Size: 871 Bytes

Versions: 4

Compression:

Stored size: 871 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::FilestackFilelink]
  def to_filelink
    return 'Video conversion incomplete' unless status == 'completed'
    response = UploadUtils.make_call(@url, 'get').body
    handle = response['data']['url'].split('/').last
    FilestackFilelink.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

4 entries across 4 versions & 1 rubygems

Version Path
filestack-2.3.0 lib/filestack/models/filestack_av.rb
filestack-2.2.1 lib/filestack/models/filestack_av.rb
filestack-2.2.0 lib/filestack/models/filestack_av.rb
filestack-2.1.0 lib/filestack/models/filestack_av.rb