
Security News
Critical Security Vulnerability in React Server Components
React disclosed a CVSS 10.0 RCE in React Server Components and is advising users to upgrade affected packages and frameworks to patched versions now.
hybiscus_pdf_report
Advanced tools
A Ruby client library for the Hybiscus PDF Reports API, providing an easy way to generate PDF reports from JSON data.
Add this line to your application's Gemfile:
gem 'hybiscus_pdf_report'
And then execute:
bundle install
Or install it yourself as:
gem install hybiscus_pdf_report
Set your API key and optionally the API URL as environment variables:
export HYBISCUS_API_KEY="your_api_key_here"
export HYBISCUS_API_URL="https://api.hybiscus.dev/api/v1/" # Optional, defaults to this URL
You can also configure the gem programmatically:
HybiscusPdfReport.configure do |config|
config.api_key = "your_api_key_here"
config.api_url = "https://api.hybiscus.dev/api/v1/" # Optional
config.timeout = 30 # Optional, defaults to 10 seconds
end
# Using environment variables (recommended)
client = HybiscusPdfReport::Client.new
# Or passing the API key directly
client = HybiscusPdfReport::Client.new(api_key: "your_api_key_here")
# With custom timeout
client = HybiscusPdfReport::Client.new(
api_key: "your_api_key_here",
timeout: 30
)
# With custom API URL (for private cloud instances)
client = HybiscusPdfReport::Client.new(
api_key: "your_api_key_here",
api_url: "https://your-private-hybiscus-instance.com/api/v1/"
)
Submit a report request for processing:
# Your report JSON data
report_data = { _JSON_structure }
response = client.request.build_report(report_data)
# Access response data
puts response.task_id
puts response.status
Generate a preview of your report without consuming your quota:
response = client.request.preview_report(report_data)
puts response.task_id
puts response.status
Monitor the status of a report generation task:
# Using a specific task ID
response = client.request.get_task_status("task_id_here")
# Or check the status of the last submitted task
response = client.request.get_last_task_status
puts response.status # "pending", "processing", "completed", "failed"
Retrieve the generated PDF report:
# Using a specific task ID
response = client.request.get_report("task_id_here")
# Or get the last generated report
response = client.request.get_last_report
# The report is base64 encoded
pdf_content = Base64.decode64(response.report)
# Save to file
File.open("report.pdf", "wb") do |file|
file.write(pdf_content)
end
Check your remaining API quota:
response = client.request.get_remaining_quota
puts response.remaining_single_page_reports
puts response.remaining_multi_page_reports
require 'hybiscus_pdf_report'
require 'base64'
# Initialize client
client = HybiscusPdfReport::Client.new
# Prepare report data
report_data = { _SOME_JSON_STRUCTURE_ }
begin
# Submit report for processing
response = client.request.build_report(report_data)
task_id = response.task_id
puts "Report submitted. Task ID: #{task_id}"
# Poll for completion
loop do
status_response = client.request.get_task_status(task_id)
status = status_response.status
puts "Current status: #{status}"
case status
when "completed"
puts "Report generation completed!"
break
when "failed"
puts "Report generation failed!"
exit 1
when "pending", "processing"
puts "Still processing... waiting 5 seconds"
sleep 5
end
end
# Download the completed report
report_response = client.request.get_report(task_id)
pdf_content = Base64.decode64(report_response.report)
# Save to file
File.open("generated_report.pdf", "wb") do |file|
file.write(pdf_content)
end
puts "Report saved as generated_report.pdf"
rescue HybiscusPdfReport::ApiErrors::ApiRequestsQuotaReachedError => e
puts "API quota reached: #{e.message}"
rescue HybiscusPdfReport::ApiErrors::PaymentRequiredError => e
puts "Payment required: #{e.message}"
rescue HybiscusPdfReport::ApiErrors::RateLimitError => e
puts "Rate limit error persisted after automatic retries: #{e.message}"
rescue HybiscusPdfReport::ApiErrors::ApiError => e
puts "API error: #{e.message}"
rescue ArgumentError => e
puts "Argument error: #{e.message}"
end
The gem includes specific error classes for different API error conditions and automatically handles transient errors like rate limits and network timeouts with exponential backoff retry logic.
The gem automatically retries the following errors up to 5 times with exponential backoff (1s, 2s, 4s, 8s, 16s):
RateLimitError (HTTP 503) - When the API is temporarily overloadedFaraday::TimeoutError - Network timeout errorsFaraday::ConnectionFailed - Network connection failuresYou don't need to handle these errors manually - the gem will automatically retry and only raise an exception if all retry attempts are exhausted.
For other API errors, you should handle them explicitly in your code:
begin
response = client.request.build_report(report_data)
rescue HybiscusPdfReport::ApiErrors::ApiRequestsQuotaReachedError => e
puts "API quota reached (HTTP 429). Please upgrade your plan."
rescue HybiscusPdfReport::ApiErrors::PaymentRequiredError => e
puts "Payment required (HTTP 402). Please check your account."
rescue HybiscusPdfReport::ApiErrors::UnauthorizedError => e
puts "Unauthorized (HTTP 401). Please check your API key."
rescue HybiscusPdfReport::ApiErrors::BadRequestError => e
puts "Bad request (HTTP 400). Please check your request data."
rescue HybiscusPdfReport::ApiErrors::RateLimitError => e
puts "Rate limit error persisted after retries. Please try again later."
rescue HybiscusPdfReport::ApiErrors::ApiError => e
puts "API error: #{e.message} (HTTP #{e.status_code})"
end
BadRequestError (HTTP 400) - Invalid request dataUnauthorizedError (HTTP 401) - Invalid or missing API keyPaymentRequiredError (HTTP 402) - Payment required for the accountForbiddenError (HTTP 403) - Access forbiddenNotFoundError (HTTP 404) - Resource not foundUnprocessableContentError (HTTP 422) - Request data cannot be processedApiRequestsQuotaReachedError (HTTP 429) - API request quota exceededRateLimitError (HTTP 503) - Rate limit exceeded (automatically retried)All API responses return Response objects that provide dynamic attribute access:
response = client.request.build_report(report_data)
# Access attributes dynamically
puts response.task_id
puts response.status
# Response objects support nested attribute access
if response.respond_to?(:error)
puts response.error.message
end
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
bundle exec rspec
bin/console
Then in the console:
client = HybiscusPdfReport::Client.new(api_key: "your_api_key")
response = client.request.get_remaining_quota
puts response.remaining_single_page_reports
Bug reports and pull requests are welcome on GitHub at https://github.com/Timly-Software-AG/HybiscusPdfReportRubyGem.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that hybiscus_pdf_report demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
React disclosed a CVSS 10.0 RCE in React Server Components and is advising users to upgrade affected packages and frameworks to patched versions now.

Research
/Security News
We spotted a wave of auto-generated “elf-*” npm packages published every two minutes from new accounts, with simple malware variants and early takedowns underway.

Security News
TypeScript 6.0 will be the last JavaScript-based major release, as the project shifts to the TypeScript 7 native toolchain with major build speedups.