Class: Gotenberg::Rails::Client
- Inherits:
-
Object
- Object
- Gotenberg::Rails::Client
- Defined in:
- lib/gotenberg/rails/client.rb
Constant Summary collapse
- HTML_PATH =
"/forms/chromium/convert/html"- URL_PATH =
"/forms/chromium/convert/url"
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#open_timeout ⇒ Object
readonly
Returns the value of attribute open_timeout.
-
#request_timeout ⇒ Object
readonly
Returns the value of attribute request_timeout.
Instance Method Summary collapse
-
#initialize(endpoint:, open_timeout:, request_timeout:, headers: {}) ⇒ Client
constructor
A new instance of Client.
- #render_pdf(html: nil, url: nil, pdf_options: {}, filename: nil, trace: nil) ⇒ Object
Constructor Details
#initialize(endpoint:, open_timeout:, request_timeout:, headers: {}) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 |
# File 'lib/gotenberg/rails/client.rb', line 16 def initialize(endpoint:, open_timeout:, request_timeout:, headers: {}) @endpoint = endpoint.to_s.delete_suffix("/") @open_timeout = open_timeout @request_timeout = request_timeout @headers = headers end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
14 15 16 |
# File 'lib/gotenberg/rails/client.rb', line 14 def endpoint @endpoint end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
14 15 16 |
# File 'lib/gotenberg/rails/client.rb', line 14 def headers @headers end |
#open_timeout ⇒ Object (readonly)
Returns the value of attribute open_timeout.
14 15 16 |
# File 'lib/gotenberg/rails/client.rb', line 14 def open_timeout @open_timeout end |
#request_timeout ⇒ Object (readonly)
Returns the value of attribute request_timeout.
14 15 16 |
# File 'lib/gotenberg/rails/client.rb', line 14 def request_timeout @request_timeout end |
Instance Method Details
#render_pdf(html: nil, url: nil, pdf_options: {}, filename: nil, trace: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gotenberg/rails/client.rb', line 23 def render_pdf(html: nil, url: nil, pdf_options: {}, filename: nil, trace: nil) if html && url raise ArgumentError, "Provide either :html or :url, not both" elsif html post(HTML_PATH, html_form(html, ), filename:, trace:) elsif url post(URL_PATH, url_form(url, ), filename:, trace:) else raise ArgumentError, "Provide :html or :url" end end |