Class: Smshelper::Api::Vianett
- Inherits:
-
Base
- Object
- Base
- Smshelper::Api::Vianett
show all
- Defined in:
- lib/smshelper/api/vianett.rb
Instance Attribute Summary
Attributes inherited from Base
#extra_options, #sent_message_ids, #sent_message_statuses
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Vianett
Returns a new instance of Vianett.
6
7
8
9
10
|
# File 'lib/smshelper/api/vianett.rb', line 6
def initialize(*args)
config = args.shift
add_query_options! :username => config.vianett[:uname], :password => config.vianett[:passwd]
super
end
|
Instance Method Details
#get_balance ⇒ Object
26
27
28
|
# File 'lib/smshelper/api/vianett.rb', line 26
def get_balance
{:fake => :value}
end
|
#get_status(message_id) ⇒ Object
30
31
32
|
# File 'lib/smshelper/api/vianett.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/vianett.rb', line 12
def send_message(message)
uuid = (Digest::CRC32.hexdigest @uuid.generate).unpack('U*').collect {|x| sprintf '%02X', x}.join
options = {
:destinationaddr => message.recipient,
:message => message.text,
:sourceaddr => message.sender,
:msgid => uuid}
options = options.merge(@extra_options) unless @extra_options.nil?
resp = (post 'MT.ashx', :extra_query => options)
process_response_code(resp['ack']) ? (@sent_message_ids << uuid; uuid) : (raise ErrorDuringSend, "#{self.class.name} does not implement detailed errors")
end
|