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.



1702
1703
1704
1705
1706
1707
# File 'lib/selectpdf.rb', line 1702

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.



1713
1714
1715
1716
1717
1718
1719
1720
# File 'lib/selectpdf.rb', line 1713

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

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

  []
end