Class: Smstrade

Inherits:
Object
  • Object
show all
Defined in:
lib/smstrade.rb

Overview

Copyright © 2010 Maikel Urlitzki <[email protected]>

Thanks to github.com/splattael

github.com/maikelcoke/smstrade_de

For use with www.smstrade.de

Configuration

# config/intializers/smstrade.rb
Smstrade.key = "YOUR_KEY"
Smstrade.route = "ROUTE"

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Smstrade

Example:

# Controller
Smstrade.new do |sms|
  @result, @response = sms.send(:number => "+491601234567", :text => "This is a dummy text.")
end

Yields:

  • (_self)

Yield Parameters:

  • _self (Smstrade)

    the object that the method was called on



50
51
52
# File 'lib/smstrade.rb', line 50

def initialize(&block)
  yield(self) if block_given?  
end

Instance Method Details

#send(options = {}) ⇒ Object

Required options are:

:number

Mobile number e.g. +49160123456

:text

SMS-Text e.g. “Hello mate, all right?”

Optional options are:

:debug

Debug mode 0 = send the message 1 = sms will not send and not charged



62
63
64
65
66
67
68
69
70
# File 'lib/smstrade.rb', line 62

def send(options={})
  string = prepare_string(options)
  begin
    response = Net::HTTP::get(gateway, "#{string}")
  rescue
    response = 0
  end
  return (response.to_i == 100), response(response.to_i)
end