Class: Five9::Statistics

Inherits:
Base
  • Object
show all
Defined in:
lib/five9/statistics.rb

Direct Known Subclasses

AcdStatus, AgentStats, InboundCampaignStats

Instance Method Summary collapse

Constructor Details

#initialize(username, password, timeout = 300) ⇒ Statistics

Returns a new instance of Statistics.



3
4
5
6
# File 'lib/five9/statistics.rb', line 3

def initialize(username,password,timeout=300)
  super(username,password,"https://api.five9.com/wssupervisor/SupervisorWebService?wsdl&user=",timeout)
  @last_working_timestamp = nil
end

Instance Method Details

#getStatistics(statistic_type, columns = []) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/five9/statistics.rb', line 12

def getStatistics(statistic_type,columns=[])
  stats = []
  data =  @client.call(:get_statistics, message: {statisticType: statistic_type, columnNames: {values: { data: columns}}}).to_array
  @last_working_timestamp = data[0][:get_statistics_response][:return][:timestamp]
  headers = data[0][:get_statistics_response][:return][:columns][:values][:data]
  data[0][:get_statistics_response][:return][:rows].each do |row|
          stats.push Hash[headers.zip row[:values][:data]]
  end
  return stats
end

#getStatisticsUpdate(statistic_type, object_name, long_polling_timeout = 10000) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/five9/statistics.rb', line 23

def getStatisticsUpdate(statistic_type, object_name,long_polling_timeout=10000)
  begin
    data = @client.call(:get_statistics_update, message: {statisticType: statistic_type, previousTimestamp: @last_working_timestamp, longPollingTimeout: long_polling_timeout}).to_array
    raise TypeError, "No Updated Statistics" if data[0][:get_statistics_update_response][:return].nil?
    stats = data[0][:get_statistics_update_response][:return][:data_update]
    @last_working_timestamp = data[0][:get_statistics_update_response][:return][:last_timestamp]
    updateStats(stats,object_name)
  rescue TypeError => e
    p e
    p e.backtrace if !e.message.include?("No Updated Statistics")
    return false
  end
  return stats
end

#setSessionParams(options) ⇒ Object



8
9
10
# File 'lib/five9/statistics.rb', line 8

def setSessionParams(options)
  @client.call(:set_session_parameters,  message: {viewSettings: {rollingPeriod: options[:rolling_period], shiftStart: options[:shift_start], statisticsRange: options[:statistics_range],timeZone: options[:time_zone]}})
end