Class: Smshelper::Api::Textmagic
- Inherits:
-
Base
- Object
- Base
- Smshelper::Api::Textmagic
show all
- Defined in:
- lib/smshelper/api/textmagic.rb
Instance Attribute Summary
Attributes inherited from Base
#extra_options, #sent_message_ids, #sent_message_statuses
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Textmagic
7
8
9
10
11
|
# File 'lib/smshelper/api/textmagic.rb', line 7
def initialize(*args)
config = args.shift
@api = TextMagic::API.new config.textmagic[:uname], config.textmagic[:passwd]
super
end
|
Instance Method Details
#get_balance ⇒ Object
19
20
21
|
# File 'lib/smshelper/api/textmagic.rb', line 19
def get_balance
{'Credits' => @api.account.balance}
end
|
#get_callback_response(args = {}) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/smshelper/api/textmagic.rb', line 27
def get_callback_response(args = {})
DeliveryReport.new(
:message_id => args['message_id'],
:timestamp => Time.now,
:delivered => ((args['status'] =~ /d/) ? true : false),
:original_params => args
)
end
|
#get_status(message_id) ⇒ Object
23
24
25
|
# File 'lib/smshelper/api/textmagic.rb', line 23
def get_status(message_id)
raise NotImplementedError, "Sms status checks unsupported by #{self.class.name}"
end
|
#send_message(message) ⇒ Object
13
14
15
16
17
|
# File 'lib/smshelper/api/textmagic.rb', line 13
def send_message(message)
resp = (@api.send message.text, message.recipient, :from => message.sender).to_s
@sent_message_ids << resp
resp
end
|