-
Notifications
You must be signed in to change notification settings - Fork 0
/
libtelemeter.rb
37 lines (31 loc) · 896 Bytes
/
libtelemeter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# == Synopsis
# Library that helps developers consult a Telenet subscription's
# current volume usage.
#
# == Author
# Robbie Vanbrabant
#
# == Copyright
# Copyright (c) 2008 Robbie Vanbrabant.
require 'soap/wsdlDriver'
require 'rexml/document'
class Telemeter
@@wsdl = 'https://t4t.services.telenet.be/TelemeterService.wsdl'
def initialize
@telemeter = SOAP::WSDLDriverFactory.new(@@wsdl).create_rpc_driver
end
def get_usage(user, pwd)
puts "User: #{user}"
usage = @telemeter.retrieveUsage(:UserId => user,:Password => pwd)
puts "Measured at: #{usage.ticket.timestamp}"
puts "Next update: #{usage.ticket.expiryTimestamp}"
TelemeterData.new(usage.volume.totalUsage.to_i, usage.volume.limit.to_i)
end
end
class TelemeterData
attr_reader :max_usage, :usage
def initialize(usage, max_usage)
@max_usage = max_usage
@usage = usage
end
end