Class: Rajasms::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rajasms.rb

Constant Summary collapse

RAJASMS_URI =
'http://162.211.84.203'
SMSREGULER_PATH =
'/sms/smsreguler.php'
SMSMASKING_PATH =
'/sms/smsmasking.php'
SMSSALDO_PATH =
'/sms/smssaldo.php'
SMSREGULER_CHECK_PATH =
'/sms/smsregulerreport.php'
SMSMASKING_CHECK_PATH =
'/sms/smsmaskingreport.php'

Instance Method Summary collapse

Constructor Details

#initialize(username, password, api_key) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
# File 'lib/rajasms.rb', line 17

def initialize username, password, api_key
	@username = username
   @password = password
   @api_key  = api_key
end

Instance Method Details

#masking(to, message) ⇒ Object



27
28
29
# File 'lib/rajasms.rb', line 27

def masking to, message
  send(to, message, SMSMASKING_PATH)
end

#reguler(to, message) ⇒ Object



23
24
25
# File 'lib/rajasms.rb', line 23

def reguler to, message
  send(to, message, SMSREGULER_PATH)
end

#saldoObject



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

def saldo
  response = self.class.get(SMSSALDO_PATH, build_query)
  code, data = response.body.split('|')
  {code: code, data: data}
end

#status(sms_id, reguler = false) ⇒ Object



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

def status(sms_id, reguler=false)
  response = self.class.get(reguler ? SMSREGULER_CHECK_PATH : SMSMASKING_CHECK_PATH, build_query(id: sms_id))
  code, data = response.body.split('|')
  {code: code, data: data}
end