Class: SelectPdf::AsyncJobClient

Inherits:
ApiClient show all
Defined in:
lib/selectpdf.rb

Overview

Get the result of an asynchronous call.

Instance Attribute Summary

Attributes inherited from ApiClient

#api_async_endpoint, #api_endpoint, #api_web_elements_endpoint, #async_calls_max_pings, #async_calls_ping_interval, #number_of_pages

Instance Method Summary collapse

Constructor Details

#initialize(api_key, job_id) ⇒ AsyncJobClient

Construct the async job client.

Parameters:

  • api_key

    API Key.

  • job_id

    Job ID.


1729
1730
1731
1732
1733
1734
# File 'lib/selectpdf.rb', line 1729

def initialize(api_key, job_id)
  super()
  @api_endpoint = 'https://selectpdf.com/api2/asyncjob/'
  @parameters['key'] = api_key
  @parameters['job_id'] = job_id
end

Instance Method Details

#resultObject

Get result of the asynchronous job.

Returns:

  • Byte array containing the resulted file if the job is finished. Returns nil if the job is still running. Throws an exception if an error occurred.


1739
1740
1741
1742
1743
1744
1745
# File 'lib/selectpdf.rb', line 1739

def result
  result = perform_post

  return result if @job_id.nil? || @job_id.empty?

  return nil
end