Class: PdfServices::ExtractPdf::Operation

Inherits:
Base::Operation show all
Defined in:
lib/pdfservices/operations/extract_pdf.rb

Constant Summary collapse

OPERATION_ENDPOINT =
"#{BASE_ENDPOINT}extractpdf".freeze
VALID_EXTRACT_ELEMENTS =
%w[tables text].freeze
TABLE_OUTPUT_FORMATS =
%w[csv xlsx].freeze
RENDITIONS_EXTRACTS =
%w[tables figures].freeze

Constants inherited from Base::Operation

Base::Operation::ASSETS_ENDPOINT, Base::Operation::BASE_ENDPOINT, Base::Operation::STATUS

Instance Method Summary collapse

Methods inherited from Base::Operation

#handle_response, #initialize, #poll_document_result, #upload_asset

Constructor Details

This class inherits a constructor from PdfServices::Base::Operation

Instance Method Details

#execute(source_pdf_path = nil, options = {}, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/pdfservices/operations/extract_pdf.rb', line 11

def execute(source_pdf_path = nil, options = {}, &block)
  validate_options(options)
  @download_zip = options.delete(:download_zip) || false
  asset = upload_asset(source_pdf_path)

  response = @api.post(OPERATION_ENDPOINT,
                       body: extract_pdf_request_body(asset.id, options),
                       headers: extract_pdf_request_headers)
  handle_response(response, asset, &block)
end