Class: Chutki
- Inherits:
-
Object
- Object
- Chutki
- Includes:
- HTTParty
- Defined in:
- lib/chutki.rb,
lib/chutki/version.rb
Constant Summary collapse
- VERSION =
"1.1.0"
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #balance(type = nil) ⇒ Object
- #change_password(new_password) ⇒ Object
- #check_delivery_report(msgid) ⇒ Object
- #check_dnd_balance ⇒ Object
- #deliver(mail) ⇒ Object
- #deliver!(mail) ⇒ Object
-
#initialize(options = {}) ⇒ Chutki
constructor
A new instance of Chutki.
- #send_sms(message, to, opts = {}) ⇒ Object
- #settings!(options) ⇒ Object
- #validation ⇒ Object
- #voice_balance ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Chutki
Returns a new instance of Chutki.
10 11 12 13 14 15 |
# File 'lib/chutki.rb', line 10 def initialize( = {}) @options = @username = [:user] @password = [:password] @sender_id = [:sender] end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/chutki.rb', line 8 def @options end |
Instance Method Details
#balance(type = nil) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/chutki.rb', line 44 def balance(type = nil) opts = {} if type && (["dnd","voice"].include?(type)) opts[:type] = type end makesend("/api/balance.php",opts) end |
#change_password(new_password) ⇒ Object
52 53 54 |
# File 'lib/chutki.rb', line 52 def change_password(new_password) makesend("/api/change_password.php",{:newpass => new_password}) end |
#check_delivery_report(msgid) ⇒ Object
60 61 62 |
# File 'lib/chutki.rb', line 60 def check_delivery_report(msgid) makesend("/api/check_delivery.php",:msgid => msgid) end |
#check_dnd_balance ⇒ Object
36 37 38 |
# File 'lib/chutki.rb', line 36 def check_dnd_balance balance("dnd") end |
#deliver(mail) ⇒ Object
28 29 30 |
# File 'lib/chutki.rb', line 28 def deliver(mail) send_sms(mail.body,mail.to[0]) end |
#deliver!(mail) ⇒ Object
32 33 34 |
# File 'lib/chutki.rb', line 32 def deliver!(mail) deliver(mail) end |
#send_sms(message, to, opts = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/chutki.rb', line 21 def send_sms(,to,opts = {}) opts ||= {} opts[:mobiles] = to opts[:message] = makesend("/sendhttp.php",opts) end |
#settings!(options) ⇒ Object
17 18 19 |
# File 'lib/chutki.rb', line 17 def settings!() @options.merge!() end |
#validation ⇒ Object
56 57 58 |
# File 'lib/chutki.rb', line 56 def validation makesend("/api/validate.php") end |
#voice_balance ⇒ Object
40 41 42 |
# File 'lib/chutki.rb', line 40 def voice_balance balance("voice") end |