sendpost_ruby_sdk
Sendpost - the Ruby gem for the SendPost API
Email API and SMTP relay to not just send and measure email sending, but also alert and optimise. We provide you with tools, expertise and support needed to reliably deliver emails to your customers inboxes on time, every time.
Installation
gem install sendpost_ruby_sdkGetting Started
Please follow the installation procedure and then run the following code:
require 'sendpost_ruby_sdk'
api_instance = Sendpost::EmailApi.new
x_sub_account_api_key = 'your_api_key' # String | Sub-Account API Key
email_message = Sendpost::EmailMessage.new
email_message.from = {
email: 'richard@piedpiper.com'
}
email_message.to = [{
email: 'gavin@hooli.com'
}]
email_message.subject = 'Hello World'
email_message.html_body = '<strong>it works!</strong>'
email_message.ippool = 'PiedPiper'
opts = {
email_message: email_message # EmailMessage | Email message
}
begin
result = api_instance.send_email(x_sub_account_api_key, opts)
p result
rescue Sendpost::ApiError => e
puts "Exception when calling EmailApi->send_email: #{e}"
endExample with cc, bcc and template:
require 'sendpost_ruby_sdk'
api_instance = Sendpost::EmailApi.new
x_sub_account_api_key = 'your_api_key' # String | Sub-Account API Key
email_message = Sendpost::EmailMessage.new
email_message.from = {
email: 'richard@piedpiper.com'
}
email_message.to = [{
email: 'gavin@hooli.com',
cc: [{ email: 'dinesh@bachmanity.com' }],
bcc: [{ email: 'jian@bachmanity.com' }]
}]
email_message.subject = 'Hello World'
email_message.template = 'Welcome Mail'
email_message.html_body = '<strong>it works!</strong>'
email_message.ippool = 'PiedPiper'
opts = {
email_message: email_message # EmailMessage | Email message
}
begin
result = api_instance.send_email_with_template(x_sub_account_api_key, opts)
p result
rescue Sendpost::ApiError => e
puts "Exception when calling EmailApi->send_email: #{e}"
endSuppressions
Create Suppressions
require 'sendpost_ruby_sdk'
api_instance = Sendpost::SuppressionApi.new
x_sub_account_api_key = 'your_api_key'
r_suppression = Sendpost::RSuppression.new
r_suppression.hard_bounce = [{ email: 'richard@piedpiper_fake.com' }]
# fields are optional, but you have to send at least one of them.
# r_suppression.manual = [{ email: 'richard@piedpiper_fake2.com' }]
# r_suppression.spam_complaint = [{ email: 'richard@piedpiper_fake3.com' }]
# r_suppression.unsubscribe = [{ email: 'richard@piedpiper_fake4.com' }]
opts = {
r_suppression: r_suppression
}
p opts
begin
result = api_instance.create_suppressions(x_sub_account_api_key, opts)
p result
rescue Sendpost::ApiError => e
puts "Exception when calling SuppressionApi->create_suppressions: #{e}"
endGet Suppressions
require 'sendpost_ruby_sdk'
api_instance = Sendpost::SuppressionApi.new
x_sub_account_api_key = 'your_api_key'
opts = {
offset: 0,
limit: 20,
search: nil,
from: '2023-06-07',
to: '2023-08-04'
}
p opts
begin
result = api_instance.get_suppressions(x_sub_account_api_key, opts)
p result
rescue Sendpost::ApiError => e
puts "Exception when calling SuppressionApi->get_suppressions: #{e}"
endDelete Suppression
require 'sendpost_ruby_sdk'
api_instance = Sendpost::SuppressionApi.new
x_sub_account_api_key = 'your_api_key'
rd_suppression = Sendpost::RDSuppression.new
rd_suppression.suppressions = [{ email: 'richard@piedpiper_fake4.com' }]
opts = {
rd_suppression: rd_suppression
}
p opts
begin
result = api_instance.delete_suppression(x_sub_account_api_key, opts)
p result
rescue Sendpost::ApiError => e
puts "Exception when calling SuppressionApi->delete_suppression: #{e}"
endCount Suppression
require 'sendpost_ruby_sdk'
api_instance = Sendpost::SuppressionApi.new
x_sub_account_api_key = 'your_api_key'
opts = {
from: '2023-06-07',
to: '2023-08-04'
}
p opts
begin
result = api_instance.count(x_sub_account_api_key, opts)
p result
rescue Sendpost::ApiError => e
puts "Exception when calling SuppressionApi->count: #{e}"
endDocumentation for API Endpoints
All URIs are relative to https://api.sendpost.io/api/v1
| Class | Method | HTTP request | Description |
|---|---|---|---|
| Sendpost::EmailApi | send_email | POST /subaccount/email/ | |
| Sendpost::EmailApi | send_email_with_template | POST /subaccount/email/template | |
| Sendpost::SuppressionApi | count | GET /subaccount/suppression/count | |
| Sendpost::SuppressionApi | create_suppressions | POST /subaccount/suppression/ | |
| Sendpost::SuppressionApi | delete_suppression | DELETE /subaccount/suppression/ | |
| Sendpost::SuppressionApi | get_suppressions | GET /subaccount/suppression/ |
Documentation for Models
- Sendpost::Attachment
- Sendpost::City
- Sendpost::CopyTo
- Sendpost::CountStat
- Sendpost::DeleteResponse
- Sendpost::Device
- Sendpost::EmailMessage
- Sendpost::EmailResponse
- Sendpost::EventMetadata
- Sendpost::From
- Sendpost::Os
- Sendpost::QEmailMessage
- Sendpost::QEvent
- Sendpost::RDSuppression
- Sendpost::RSuppression
- Sendpost::ReplyTo
- Sendpost::Suppression
- Sendpost::SuppressionEmail
- Sendpost::To
- Sendpost::UserAgent
- Sendpost::WebhookEvent
Documentation for Authorization
Endpoints do not require authorization.