Deprecated. This lib was for a past incarnation of the Stampr API that is no longer in production or supported
Ruby wrapper for the Stampr API.
Author: Bil Bas (bil.bas.dev@gmail.com)
Ruby API: https://github.com/stampr/stampr-api-ruby
Stampr: http://stam.pr
License: MIT
Add this line to your application's Gemfile:
gem 'stampr'
And then execute:
$ bundle
Or install it yourself as:
$ gem install stampr
In this case, all mailings will be in individual batches and with default config.
require 'stampr'
Stampr.authenticate "username", "password"
Stampr.mail my_address, dest_address_1, body1
Stampr.mail my_address, dest_address_2, body2
Managing config and grouping mailings into a single batch.
require 'stampr'
Stampr.authenticate "username", "password"
# Config can be shared by batches.
config = Stampr::Config.new
# Batches contain one or more mailings.
Stampr::Batch.new config: config do |b|
b.mailing do |m|
m.address = dest_address_1
m.return_address = my_address
m.data = body1
end
b.mailing do |m|
m.address = dest_address_2
m.return_address = my_address
m.data = body2
end
end
And without using blocks:
require 'stampr'
Stampr.authenticate "username", "password"
# Config can be shared by batches.
config = Stampr::Config.new
# Batches contain one or more mailings.
batch = Stampr::Batch.new config: config
mailing1 = Mailing.new batch: batch
mailing1.address = dest_address_1
mailing1.return_address = my_address
mailing1.data = data1
mailing1.mail
mailing2 = Mailing.new batch: batch
mailing2.address = dest_address_2
mailing2.return_address = my_address
mailing2.data = data2
mailing2.mail
Browsing:
config = Stampr::Config[123123]
configs = Stampr::Config.all
Browsing:
batch = Stampr::Batch[2451]
time_period = Time.new(2012, 1, 1, 0, 0, 0)..Time.now
batches = Stampr::Batch.browse(time_period)
batches = Stampr::Batch.browse(time_period, status: :processing)
Updating:
batch = Stampr::Batch[2451]
batch.status = :archive
Deleting:
batch = Stampr::Batch[2451]
batch.delete
Browsing:
mailing = Stampr::Mailing[123123]
time_period = Time.new(2012, 1, 1, 0, 0, 0)..Time.now
my_batch = Stampr::Batch[1234]
mailings = Stampr::Mailing.browse(time_period)
mailings = Stampr::Mailing.browse(time_period, status: :processing)
mailings = Stampr::Mailing.browse(time_period, batch: my_batch)
mailings = Stampr::Mailing.browse(time_period, status: :processing, batch: my_batch)
Syncing current status:
mailing = Stampr::Mailing[2451]
mailing.status #=> :received
mailing.sync
mailing.status #=> :render
Deleting:
mailing = Stampr::Mailing[2451]
mailing.delete
Using mail-merge with Mustache template
require 'stampr'
Stampr.authenticate "username", "password"
Stampr::Batch.new do |b|
b.template = "<html>Hello {{name}}, would you like to buy some {{items}}!</html>"
b.mailing do |m|
m.address = dest_address_1
m.return_address = my_address
m.data = { name: "Marie", items: "electric eels" }
end
b.mailing do |m|
m.address = dest_address_2
m.return_address = my_address
m.data = { name: "Romy", items: "scintillating hackers" }
end
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request