Class: Pdfx::Client
- Inherits:
-
Object
- Object
- Pdfx::Client
- Defined in:
- lib/pdfx/client.rb
Overview
Main client class for interacting with the pdfx.fr API
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
-
#generate_pdf(template_uuid:, data: {}) ⇒ String
Generate a PDF using a template and data.
-
#initialize(api_key: nil, base_url: nil) ⇒ Client
constructor
Initialize a new Pdfx client.
Constructor Details
#initialize(api_key: nil, base_url: nil) ⇒ Client
Initialize a new Pdfx client
16 17 18 19 20 21 |
# File 'lib/pdfx/client.rb', line 16 def initialize(api_key: nil, base_url: nil) @api_key = api_key || Pdfx.api_key @base_url = base_url || Pdfx.base_url raise ArgumentError, "API key is required" if @api_key.nil? || @api_key.empty? end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/pdfx/client.rb', line 10 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
10 11 12 |
# File 'lib/pdfx/client.rb', line 10 def base_url @base_url end |
Instance Method Details
#generate_pdf(template_uuid:, data: {}) ⇒ String
Generate a PDF using a template and data
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pdfx/client.rb', line 40 def generate_pdf(template_uuid:, data: {}) raise ArgumentError, "template_uuid is required" if template_uuid.nil? || template_uuid.empty? payload = { template_uuid: template_uuid, data: data } make_request(payload) end |