Class: AV

Inherits:
Object
  • Object
show all
Includes:
UploadUtils
Defined in:
lib/filestack/models/filestack_av.rb

Overview

Class for AV objects – allows to check status and upgrade to filelink once completed

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UploadUtils

#build_store_task, #get_url, #make_call, #send_upload

Constructor Details

#initialize(url, apikey: nil, security: nil) ⇒ AV

Returns a new instance of AV.



11
12
13
14
15
# File 'lib/filestack/models/filestack_av.rb', line 11

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

Instance Attribute Details

#apikeyObject (readonly)

Returns the value of attribute apikey.



9
10
11
# File 'lib/filestack/models/filestack_av.rb', line 9

def apikey
  @apikey
end

#securityObject (readonly)

Returns the value of attribute security.



9
10
11
# File 'lib/filestack/models/filestack_av.rb', line 9

def security
  @security
end

Instance Method Details

#statusString

Checks the status of the video conversion

Returns:

  • (String)


31
32
33
34
35
# File 'lib/filestack/models/filestack_av.rb', line 31

def status
  response = UploadUtils.make_call(@url, 'get')
  response_body = JSON.parse(response.body)
  response_body['status']
end

Turns AV into filelink if video conversion is complete

Returns:

  • (Filestack::FilestackFilelink)


20
21
22
23
24
25
26
# File 'lib/filestack/models/filestack_av.rb', line 20

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