Class: Smshelper::Api::Routomessaging
- Inherits:
-
Base
- Object
- Base
- Smshelper::Api::Routomessaging
show all
- Defined in:
- lib/smshelper/api/routomessaging.rb
Instance Attribute Summary
Attributes inherited from Base
#extra_options, #sent_message_ids, #sent_message_statuses
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Routomessaging.
6
7
8
9
10
11
|
# File 'lib/smshelper/api/routomessaging.rb', line 6
def initialize(*args)
config = args.shift
@uname, @passwd = config.routomessaging[:uname], config.routomessaging[:passwd]
add_request_options! :skip_endpoint => true
super
end
|
Instance Method Details
#get_balance ⇒ Object
37
38
39
40
|
# File 'lib/smshelper/api/routomessaging.rb', line 37
def get_balance
opts = {:username => @uname, :password => @passwd}
{'EUR' => (post 'http://smsc6.routotelecom.com/balance.php', :extra_query => opts).gsub("\n", '').to_f.round(4)}
end
|
#get_callback_response(args = {}) ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/smshelper/api/routomessaging.rb', line 47
def get_callback_response(args = {})
DeliveryReport.new(
:message_id => args['mess_id'],
:timestamp => Time.now,
:delivered => ((args['status'] == '0') ? true : false),
:status => @response_code.routomessaging(args['status']),
:original_params => args
)
end
|
#get_status ⇒ Object
57
58
59
|
# File 'lib/smshelper/api/routomessaging.rb', line 57
def get_status
raise NotImplementedError, "Sms status checks unsupported by #{self.class.name}"
end
|
#hlr_lookup(number) ⇒ Object
42
43
44
45
|
# File 'lib/smshelper/api/routomessaging.rb', line 42
def hlr_lookup(number)
opts = {:number => number, :user => @uname, :pass => @passwd}
(get 'http://hlr.routotelecom.com', :extra_query => opts)
end
|
#send_message(message) ⇒ Object
send_message TO, MESSAGE, FROM
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/smshelper/api/routomessaging.rb', line 14
def send_message(message)
uuid = (Digest::CRC32.hexdigest @uuid.generate).unpack('U*').collect {|x| sprintf '%02X', x}.join
if message.utf_8
message.to_hex_be
q = {:type => 'longunicode'}
else
q = {:type => 'LongSMS'}
end
options = {
:number => message.recipient,
:message => message.text,
:ownnum => message.sender
}
options.merge!(@extra_options) unless @extra_options.nil?
options.merge!(:mess_id => uuid) if options[:delivery]
options.merge!(:user => @uname, :pass => @passwd)
resp = (post 'http://smsc5.routotelecom.com/NewSMSsend', :extra_query => options.merge(q))
process_response_code(resp) ? (@sent_message_ids << uuid; uuid) : (raise ErrorDuringSend, 'error response processing not implemented yet')
end
|