7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/cdnetworks-client/statistics_open_api.rb', line 7
def bandwidth_usage(service_name, from, to, time_interval = 2)
session_token = get_session_token
api_key = get_api_key(session_token, service_name)
opts = {
sessionToken: session_token,
apiKey: api_key,
fromDate: from.strftime("%Y%m%d"),
toDate: to.strftime("%Y%m%d"),
timeInterval: time_interval,
output: "json"
}
response = call(BANDWIDTH_PATH, opts)
if response[:code].to_s == "404"
0.0
else
Array.wrap(response[:body]['trafficResponse']['trafficItem']).map{|i| i['dataTransferred']}.inject(&:+)
end
end
|