Class: Pageflow::ZencoderApi Private

Inherits:
Object
  • Object
show all
Defined in:
lib/pageflow/zencoder_api.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Error, RecoverableError, UnrecoverableError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instanceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
# File 'lib/pageflow/zencoder_api.rb', line 60

def self.instance
  ZencoderApi.new
end

Instance Method Details

#create_job(definition) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
# File 'lib/pageflow/zencoder_api.rb', line 8

def create_job(definition)
  with_exception_translation do
    response = Zencoder::Job.create(input: definition.input_s3_url,
                                    outputs: definition.outputs)
    raise translate_zencoder_errors(response.errors) unless response.success?

    response.body['id']
  end
end

#get_details(job_id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:todo Metrics/AbcSize



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pageflow/zencoder_api.rb', line 37

def get_details(job_id) # rubocop:todo Metrics/AbcSize
  with_exception_translation do
    response = Zencoder::Job.details(job_id)

    raise translate_zencoder_errors(response.errors) unless response.success?

    input_details = response.body['job']['input_media_file']
    outputs_details = response.body['job']['output_media_files']

    output_presences = outputs_details.each_with_object({}) do |output, presences|
      presences[output['label'].to_sym] = output['state'] if output['label'].present?
    end

    {
      format: input_details['format'],
      duration_in_ms: input_details['duration_in_ms'],
      width: input_details['width'],
      height: input_details['height'],
      output_presences:
    }
  end
end

#get_info(job_id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pageflow/zencoder_api.rb', line 18

def get_info(job_id)
  with_exception_translation do
    response = Zencoder::Job.progress(job_id)

    raise translate_zencoder_errors(response.errors) unless response.success?

    {
      state: response.body['state'],
      progress: response.body['progress'],
      finished: response.body['state'] == 'finished'
    }
  end
end

#get_input_details(job_id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.

Use ‘get_details(job_id)` instead.



33
34
35
# File 'lib/pageflow/zencoder_api.rb', line 33

def get_input_details(job_id)
  get_details(job_id)
end