Skip to content

sharkzp/unisender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UniSender Build Status

uni_sender gem provides full ruby dev kit to access API of unisender.com.ua. It uses method_missing to provide flexible functionality. All methods will return hash that represents response from the server. To experiment with the code, run pry for an interactive prompt.

Installation

Add this line to your application's Gemfile:

gem 'uni_sender'

And then execute:

$ bundle

Or install it yourself as:

$ gem install uni_sender

Usage

Gem provides class UniSender::Client for accessing server's API. For creating client you need your personal key

client = UniSender::Client.new("your secret key")

Sandbox mode API key "2pF44VzCfXmNSVOJtMhgBTLzTWlZokU8w"

client = UniSender::Client.new("2pF44VzCfXmNSVOJtMhgBTLzTWlZokU8w")

Retrieve mailing lists with their codes

client.get_lists

Create a new mailing list

client.create_list({ :title => "NewListTitle" })

Subscribe addressee on one or several mailing lists

client.subscribe({
  :list_ids => [1, 2],
  :fields => {
    :email => "[email protected]",
    :phone => "+380987654321",
    :name => "Dougal"
  }
})

Create an e-mail to a mass mailing

client.create_email_message({
  :sender_name => "Test Name",
  :sender_email => "[email protected]",
  :list_id => 1,
  :lang => "en",
  :subject => "Subject",
  :body => "Body"
})

Sending individual email message

client.send_email({
  :sender_name => "Test Name",
  :sender_email => "[email protected]",
  :list_id => 1,
  :lang => "en",
  :subject => "Subject",
  :body => "Body",
  :email => "[email protected]"
})

Create SMS for mass mailing

client.create_sms_message({
  :sender => "CompanyName",
  :list_id => 1,
  :body => "Sample SMS message"
})

Send SMS-message

client.create_sms_message({
  :phone => "+380987654321",
  :sender => "MyCompany",
  :list_id => 1,
  :body => "Sample SMS message",
  :text => "Hello, it's a test message"
})

Gem provides non-sensitive style, so action getLits will equal to get_lists

For getting contacts call client.exportContacts (or client.export_contacts). If request will be accepted client will return hash in the next format:

{ 'result' => { 'field_names' => [...], 'data' => [[...], [...], ... ] } }

Before sent action to server gem processes all parameters.

If parameter is array, uni_sender will join contents by comma, also process all items like string

{ :sample => [233, 'foo', 545] } will be transformed to sample=233,foo,545

Hash will be encoded into nested variables, for example:

{ :friend => { :name => "Роман", :car => "BMW" } } will be friend[name]=Роман&friend[car]=BMW

Keep in mind, that field_names and data for API method importContacts translated in the different way

field_names[0]=email&field_names[1]=email_list_ids&
data[0][0][email protected]&data[0][1]=123&data[1][0][email protected]

Development

After checking out the repo, run bundle install to install dependencies. Then, run rake spec to run the tests. You can also run pry for an interactive prompt that will allow you to experiment.

Wiki

For more information about API methods please visit:

General information about UniSender API

Contributing

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

License

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