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.



1510
1511
1512
1513
1514
1515
# File 'lib/selectpdf.rb', line 1510

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.



1520
1521
1522
1523
1524
1525
1526
# File 'lib/selectpdf.rb', line 1520

def result
  result = perform_post

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

  return nil
end