Class: PdfServices::HtmlToPdf::Internal

Inherits:
Operation show all
Defined in:
lib/pdfservices/operations/html_to_pdf/internal.rb

Constant Summary collapse

INTERNAL_OPTIONS =
%i[input_url json include_header_footer page_layout notifiers].freeze
PAGE_LAYOUT_OPTIONS =
%i[page_width page_height].freeze

Constants inherited from Operation

Operation::OPERATION_ENDPOINT

Constants inherited from Base::Operation

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

Instance Method Summary collapse

Methods inherited from Operation

#external_class, #internal_class, #request_headers

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(html_file_path, options = {}, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pdfservices/operations/html_to_pdf/internal.rb', line 9

def execute(html_file_path, options = {}, &block)
  validate_options(options, html_file_path)

  asset = upload_asset(html_file_path) unless options[:input_url]

  asset_id = asset.id if asset

  response = @api.post(OPERATION_ENDPOINT,
                       body: request_body(asset_id, options),
                       headers: request_headers)

  handle_response(response, asset, &block)
end