Sha256: 1d91d3585abc1dadb2b7ccf25c55bbd4c0f66dca933a09ca32815845a153459c

Contents?: true

Size: 1002 Bytes

Versions: 26

Compression:

Stored size: 1002 Bytes

Contents

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

# 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')
    response_body = JSON.parse(response.body)
    handle = response_body['data']['url'].split('/').last
    FilestackFilelink.new(handle, apikey: @apikey, security: @security)
  end

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
filestack-3.0.0 lib/filestack/models/filestack_av.rb
filestack-2.9.7 lib/filestack/models/filestack_av.rb
filestack-2.9.6 lib/filestack/models/filestack_av.rb
filestack-2.9.5 lib/filestack/models/filestack_av.rb
filestack-2.9.4 lib/filestack/models/filestack_av.rb
filestack-2.9.3 lib/filestack/models/filestack_av.rb
filestack-2.9.2 lib/filestack/models/filestack_av.rb
filestack-2.9.1 lib/filestack/models/filestack_av.rb
filestack-2.9.0 lib/filestack/models/filestack_av.rb
filestack-2.8.1 lib/filestack/models/filestack_av.rb
filestack-2.8.0 lib/filestack/models/filestack_av.rb
filestack-2.7.0 lib/filestack/models/filestack_av.rb
filestack-2.6.7 lib/filestack/models/filestack_av.rb
filestack-2.6.6 lib/filestack/models/filestack_av.rb
filestack-2.6.5 lib/filestack/models/filestack_av.rb
filestack-2.6.4 lib/filestack/models/filestack_av.rb
filestack-2.6.3 lib/filestack/models/filestack_av.rb
filestack-2.6.2 lib/filestack/models/filestack_av.rb
filestack-2.6.1 lib/filestack/models/filestack_av.rb
filestack-2.6.0 lib/filestack/models/filestack_av.rb