Class: ImobisApi::Api

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

Instance Method Summary collapse

Constructor Details

#initialize(user, pass) ⇒ Api

Returns a new instance of Api.



9
10
11
12
13
# File 'lib/imobis_api.rb', line 9

def initialize(user,pass)
  @core = ImobisCore.new
  @user = user
  @pass = pass
end

Instance Method Details

#check_number(num) ⇒ Object



37
38
39
40
41
42
# File 'lib/imobis_api.rb', line 37

def check_number(num)
  xml = @core.WriteXML(@user, @pass, "check", num)
  xml = @core.Post("http://gate.sms-manager.ru/_checkgsm.php", {"XML" => xml})
  data = @core.ReadXml(xml, "check")
  return data
end

#delivery_report(ids) ⇒ Object



24
25
26
27
28
29
# File 'lib/imobis_api.rb', line 24

def delivery_report(ids)
  xml = @core.WriteXML(@user, @pass, "report", ids)
  xml = @core.Post("http://gate.sms-manager.ru/_callback.php", {"XML" => xml})
  data = @core.ReadXml(xml, "report")
  return data
end

#get_balanceObject



31
32
33
34
35
# File 'lib/imobis_api.rb', line 31

def get_balance
  uri = "http://gate.sms-manager.ru/_balance.php?user="+@user+"&password="+@pass
  data = @core.Get(uri)
  return data
end

#get_senderObject



51
52
53
54
55
56
# File 'lib/imobis_api.rb', line 51

def get_sender
  uri = "http://gate.sms-manager.ru/_checksender.php?user="+@user+"&password="+@pass+"&mode=xml"
  xml = @core.Get(uri)
  data = @core.ReadXml(xml, "sender")
  return data
end

#get_state(num) ⇒ Object



44
45
46
47
48
49
# File 'lib/imobis_api.rb', line 44

def get_state(num)
  xml = @core.WriteXML(@user, @pass, "stats", num)
  xml = @core.Post("http://gate.sms-manager.ru/_checkphone.php", {"XML" => xml})
  data = @core.ReadXml(xml, "stats")
  return data
end

#sendsms(sender, text, num) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/imobis_api.rb', line 15

def sendsms(sender, text, num)
  message = [sender,text]
  data = [message, num]
  xml = @core.WriteXML(@user, @pass, "send", data)
  xml = @core.Post("http://gate.sms-manager.ru/_xmlsmsd.php", {"XML" => xml})
  data = @core.ReadXml(xml, "send")
  return data
end