Ruby
Official Ruby SDK for TemplateFox.
Installation
Add to your Gemfile:
gem 'templatefox'Then run:
bundle installOr install directly:
gem install templatefoxGenerate a PDF
require 'templatefox'
# Initialize the client
TemplateFox.configure do |config|
config.api_key['ApiKeyAuth'] = 'your-api-key'
end
api = TemplateFox::PDFApi.new
# Generate a PDF
request = TemplateFox::CreatePdfRequest.new(
template_id: 'YOUR_TEMPLATE_ID',
data: {
name: 'John Doe',
invoice_number: 'INV-001',
total_amount: 150.00
}
)
begin
response = api.create_pdf(request)
puts "PDF URL: #{response.url}"
puts "Credits remaining: #{response.credits_remaining}"
rescue TemplateFox::ApiError => e
puts "Error: #{e.message}"
endConfiguration
TemplateFox.configure do |config|
config.api_key['ApiKeyAuth'] = ENV['TEMPLATEFOX_API_KEY']
endFull SDK Reference
For the complete API coverage including templates, account, S3 integration, and error handling, see the GitHub repository README .
Last updated on