Class: SelectPdf::WebElementsClient

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

Overview

Get the locations of certain web elements. This is retrieved if pdf_web_elements_selectors parameter was set during the initial conversion call and elements were found to match the selectors.

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) ⇒ WebElementsClient

Construct the web elements client.

Parameters:

  • api_key

    API Key.

  • job_id

    Job ID.



1483
1484
1485
1486
1487
1488
# File 'lib/selectpdf.rb', line 1483

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

Instance Method Details

#web_elementsObject

Get the locations of certain web elements. This is retrieved if pdf_web_elements_selectors parameter is set and elements were found to match the selectors.

Returns:

  • List of web elements locations.



1494
1495
1496
1497
1498
1499
1500
1501
# File 'lib/selectpdf.rb', line 1494

def web_elements
  @headers['Accept'] = 'text/json'

  result = perform_post
  return JSON.parse(result) unless result.nil? || result.empty?

  []
end