lib/api.rb in textmagic-0.2.0 vs lib/api.rb in textmagic-0.2.1
- old
+ new
@@ -86,10 +86,11 @@
raise Error.new(7, 'Message too long') unless API.validate_text_length(text, unicode)
phones = args.flatten
raise Error.new(9, 'Invalid phone number format') unless API.validate_phones(phones)
response = Executor.execute('send', @username, @password, options.merge(:text => text, :phone => phones.join(',')))
response.extend(TextMagic::API::Response::Send)
+ response
end
# Executes a message_status command and returns a hash with states of
# messages for specified ids if successful, otherwise it raises a
# TextMagic::API::Error.
@@ -114,13 +115,15 @@
# response['141421'].status
# # => 'd'
# response['141421'].created_time
# # => Fri May 22 10:10:18 +0200 2009
def message_status(*ids)
+ single = ids.size == 1 && ids.first.is_a?(String)
ids.flatten!
raise TextMagic::API::Error.new(4, 'Insufficient parameters') if ids.empty?
response = Executor.execute('message_status', @username, @password, :ids => ids.join(','))
response.extend(TextMagic::API::Response::MessageStatus)
+ single ? response[ids.first] : response
end
# Executes a receive command and returns a hash with unread messages
# if successful, otherwise it raises an Error.
# The returned hash will be extended with custom reader method defined