KaniLaser
SendGrid v3 Mail Send API Ruby Client that validates API request body using JSON Schema.
Installation
Add this line to your application's Gemfile:
gem 'kani_laser'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kani_laser
Usage
require 'kani_laser'
client = KaniLaser::Client.new(api_key: 'ZAPZAPZAP')
# see https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html
client.send_mail(
personalizations: [
{
to: [
{
email: '[email protected]'
}
],
subject: 'Hello, World!'
}
],
from: {
email: '[email protected]'
},
content: [
{
type: 'text/plain',
value: 'Hello, World!'
}
]
)
For testing
client = KaniLaser::Client.new() do |faraday|
faraday.adapter :test, Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/v3/mail/send') do |_env|
[202, {}, '']
end
end
end
Update schema
rake schema:update