Skip to content

PreflightQA/ruby_api

Repository files navigation

PreflightQA

Official Ruby library for interacting with the https://preflight.qa API.

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add preflight_qa

If bundler is not being used to manage dependencies, install the gem by executing:

gem install preflight_qa

Usage

Configure the gem with your PreflightQA API key:

PreflightQA.configure do |config|
  config.api_key = "xxxxxxx"
end

You can override the default API host if needed:

PreflightQA.configure do |config|
  config.api_key = "xxxxxxx"
  config.base_url = "https://api.preflight.qa"
end

List available apps:

apps = PreflightQA::Apps.list
apps["apple_mail_mac"]["name"]
apps["apple_mail_mac"]["modes"]

Create a screenshot submission for all default apps:

submission = PreflightQA::Screenshots.create(
  subject: "My Test Email",
  html: "<html><body>Hello world</body></html>"
)

submission.uuid
submission.status
submission.code

webhook_url is optional. If you want PreflightQA to notify your app when rendering is finished, pass it explicitly:

submission = PreflightQA::Screenshots.create(
  subject: "My Test Email",
  html: "<html><body>Hello world</body></html>",
  webhook_url: "https://example.com/preflight/webhook"
)

You can also limit the request to specific apps and modes:

submission = PreflightQA::Screenshots.create(
  subject: "My Test Email",
  html: "<html><body>Hello world</body></html>",
  apps: {
    apple_mail_mac: { modes: [:light, :dark] },
    outlook_mac: { modes: [:light] }
  }
)

Find screenshots for a submission:

screenshots = PreflightQA::Screenshots.find(submission.uuid)

screenshots.each do |screenshot|
  puts "#{screenshot.app}: #{screenshot.status} -> #{screenshot.url}"
end

PreflightQA::Apps.list returns the raw data["apps"] hash from the API.

PreflightQA::Screenshots.create returns PreflightQA::Submission with uuid, status, code, and raw.

PreflightQA::Screenshots.find returns Array<PreflightQA::Screenshot>.

Development

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.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/PreflightQA/ruby_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the PreflightQA project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

Ruby library for interacting with the preflight.qa API service.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages