Sha256: 03ff3ba05a6a48ce938a64ac20fd3cfcc765632fa0881db4e93bf14453b27c59

Contents?: true

Size: 915 Bytes

Versions: 1

Compression:

Stored size: 915 Bytes

Contents

require_relative '../lib/esendex'
include Esendex

namespace :esendex do
  task :validate, [:username, :password, :account_reference] do |t, args|
    begin
      Esendex.configure do |config|
        config.username = args.username
        config.password = args.password
        config.account_reference = args.account_reference
      end
      account = Account.new
      messages_remaining = account.messages_remaining
      puts "Validated user #{Esendex.username} on account #{account.reference}. #{messages_remaining} messages remaining"
    rescue => e
      puts "Failed to validate credentials #{e.message}"
    end
  end

  task :send_message, [:to, :body, :from] do |t, args|
    begin
      account = Account.new
      batch_id = account.send_message(args)
      puts "Message sent to #{args.to}. Batch ID: #{batch_id}"
    rescue => e
      puts "Failed to send message #{e.message}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esendex-0.2.2 tasks/esendex.rake