Class: CiscoWebex::Agents

Inherits:
ContactCenter show all
Defined in:
lib/CC/Agents.rb

Instance Method Summary collapse

Methods inherited from ContactCenter

#address_books, #agent_profiles, #agents, #auxiliary_codes, #captures, #dial_plans, #entry_point_mappings, #entry_points, #get, #head, #journey, #multimedia_profiles, #my_org, #outbound_ani, #post, #put, #queues, #sites, #skill_profiles, #skills, #subscriptions, #tasks, #teams, #user_profiles, #users

Constructor Details

#initialize(token = nil, org_id = nil) ⇒ Agents

initialize object with stored token



7
8
9
10
11
12
13
14
15
# File 'lib/CC/Agents.rb', line 7

def initialize(token=nil, org_id=nil)
	if token == nil || org_id == nil
		STDERR.puts "Must provide API key for CiscoWebex::ContactCenter::Agent"
		return false
	else
		@auth_token = token
		@org_id =  org_id
	end
end

Instance Method Details

#activities(params = {}, limit = 5000) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/CC/Agents.rb', line 34

def activities(params={}, limit=5000)
	if params.class != Hash || params == {}
		STDERR.puts "CiscoWebex::ContactCenter::Agents.activites() - You should provide search parameters, using defaults. Good luck!"
		params = {}
	end
	params['from'] = CiscoWebex::Toolbox::WebexTime.shift("now", -86400, "CC") if ! params.has_key?('from')
	return CiscoWebex::RestCC.get(@auth_token, "/v1/agents/activitiies", params, limit)['data'] rescue false
end

#round_time(timestamp = nil, interval = 15) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/CC/Agents.rb', line 17

def round_time(timestamp=nil, interval=15)
interval = interval * 60
if timestamp.class == DateTime
	timestamp = timestamp.to_i
elsif timestamp.class == String
	timestamp = Time.parse(timestamp.to_s).to_i
elsif timestamp.class != Integer
	timestamp = DateTime.now.strftime('%s').to_i
end

rounded = Time.at((timestamp / interval).round * interval).to_i * 1000
end

#statistics(params = {}, limit = 5000) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/CC/Agents.rb', line 43

def statistics(params={}, limit=5000)
	if params.class != Hash || params == {}
		STDERR.puts "CiscoWebex::ContactCenter::Agents.statistics() - you should provide search parameters, using defaults. Good luck!"
		params = {}
	end

	params['orgId'] = @org_id
	params['interval'] = 60 if ! params.has_key?('interval')

	if ! params.has_key?('from')
		params['from'] = CiscoWebex::Toolbox::WebexTime.shift("now", -60, "ms", params['interval'])
	else
		params['from'] = CiscoWebex::Toolbox::WebexTime.round(params['from'], params['interval'], "ms")
	end
	if ! params.has_key?('to')
		params['to'] = CiscoWebex::Toolbox::WebexTime.round("now", params['interval'], "ms")
	else
		params['to'] = CiscoWebex::Toolbox::WebexTime.round(params['to'], params['interval'], "ms")
	end

	return CiscoWebex::RestCC.get(@auth_token, "/v1/agents/statistics", params, limit)['data'] rescue false
end

#thisObject



30
31
32
# File 'lib/CC/Agents.rb', line 30

def this()
	puts "CiscoWebex::ContactCenter::Agent - Org:#{@org_id}"
end