Unofficial wrapper for the Kajomi Mail API.
Add this line to your application's Gemfile:
gem 'kajomi'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kajomi
Return an array of Kajomi::Entities::List
api_client = Kajomi::ApiClient.new(shared_key, secret_key)
lists = api_client.get_lists
Find users by attribute and return an array of Kajomi::Entities::User:
list = Kajomi::Entities::List.new(listnum: 3)
client = Kajomi::ApiClient.new(shared_key, secret_key)
users = client.query_users(list, "email", "<some-email-address>")
Duplicate an existing list (identified by listnum) and return the new list as an Kajomi::Entities::List object:
list = Kajomi::Entities::List.new(listnum: 3)
api_client = Kajomi::ApiClient.new(shared_key, secret_key)
new_list = api_client.duplicate_list(list, "My new list")
Import an array of users into an existing list:
users = []
users << Kajomi::Entities::User.new(email: "[email protected]", firstname: "Manuel", lastname: "Boy")
list = Kajomi::Entities::List.new(listnum: "<some-list-number>")
client = Kajomi::ApiClient.new(shared_key, secret_key)
response = client.import_users(list, users)
Remove users from the system identified by their uid:
users = []
users << Kajomi::Entities::User.new(uid: "<some-uid>")
client = Kajomi::ApiClient.new(shared_key, secret_key)
response = client.remove_users(users)
Note: When removing users the API return typically an empty string and not a valid JSON response
Using Kajomi with the Mail library
You can use Kajomi with the mail
gem.
gem install mail
To send a Mail::Message
via Kajomi you’ll need to specify Mail::Kajomi
as a delivery method for the message and specify the secret key and shared key:
message = Mail.new do
# ...
delivery_method Mail::Kajomi, secret_key: 'your-secret-key', shared_key: 'your-shared-key'
end
require 'rubygems'
require 'kajomi'
require 'mail'
message = Mail.new do
from '[email protected]'
to '[email protected]'
subject 'My Subject'
body 'Hello World!'
delivery_method Mail::Kajomi, secret_key: 'your-secret-key', shared_key: 'your-shared-key'
end
message.deliver
To use Kajomi as a ActionMailer adapter see the kajomi-rails
gem
- 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