Class: Smshelper::Api::Mediaburst
- Inherits:
-
Base
- Object
- Base
- Smshelper::Api::Mediaburst
show all
- Defined in:
- lib/smshelper/api/mediaburst.rb
Instance Attribute Summary
Attributes inherited from Base
#extra_options, #sent_message_ids, #sent_message_statuses
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Mediaburst
Returns a new instance of Mediaburst.
6
7
8
9
10
|
# File 'lib/smshelper/api/mediaburst.rb', line 6
def initialize(*args)
config = args.shift
add_query_options! :username => config.mediaburst[:uname], :password => config.mediaburst[:passwd]
super
end
|
Instance Method Details
#get_balance ⇒ Object
26
27
28
|
# File 'lib/smshelper/api/mediaburst.rb', line 26
def get_balance
{'Messages' => (post 'credit.aspx').split(' ').last}
end
|
#get_callback_response(args = {}) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/smshelper/api/mediaburst.rb', line 34
def get_callback_response(args = {})
DeliveryReport.new(
:message_id => args['msg_id'],
:timestamp => Time.now,
:delivered => ((args['status'] =~ /DELIVRD/) ? true : false),
:original_params => args
)
end
|
#get_status(message_id) ⇒ Object
30
31
32
|
# File 'lib/smshelper/api/mediaburst.rb', line 30
def get_status(message_id)
raise NotImplementedError, "Sms status checks unsupported by #{self.class.name}"
end
|
#send_message(message) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/smshelper/api/mediaburst.rb', line 12
def send_message(message)
message.utf_8 ? (q = {:msgtype => 'ucs2'}) : (q = {:msgtype => 'text'})
options = {
:to => message.recipient,
:content => message.text,
:concat => '3',
:from => message.sender}
options = options.merge(@extra_options) unless @extra_options.nil?
resp = (post 'send.aspx', :extra_query => options.merge(q)).to_s.split(' ').last.strip
process_response_code(resp) ? resp.to_s : (raise ErrorDuringSend, "#{self.class.name} does not provide detailed response codes")
end
|