Class: Chutki

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/chutki.rb,
lib/chutki/version.rb

Constant Summary collapse

VERSION =
"1.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = {})
  @options = options
  @username = options[:user]
  @password = options[:password]
  @sender_id = options[:sender]
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/chutki.rb', line 8

def options
  @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_balanceObject



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(message,to,opts = {})
  opts ||= {}
  opts[:mobiles] = to
  opts[:message] = message
  makesend("/sendhttp.php",opts)
end

#settings!(options) ⇒ Object



17
18
19
# File 'lib/chutki.rb', line 17

def settings!(options)
  @options.merge!(options)
end

#validationObject



56
57
58
# File 'lib/chutki.rb', line 56

def validation
  makesend("/api/validate.php")
end

#voice_balanceObject



40
41
42
# File 'lib/chutki.rb', line 40

def voice_balance
  balance("voice")
end