five9 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["dhahn@ctatechs.com"]
11
11
  gem.description = %q{Rubygem integration with five9 API}
12
12
  gem.summary = %q{Write a gem summary}
13
- gem.homepage = "https://github.com/CorporateTechnologyAdvantage/five9"
13
+ gem.homepage = "https://github.com/CTA/five9"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,6 +1,6 @@
1
1
  require "five9/version"
2
2
  require "five9/base"
3
- require "five9/provision"
3
+ require "five9/user_management"
4
4
  require "five9/statistics"
5
5
  require "five9/agent_stats.rb"
6
6
  require "five9/inbound_campaign_stats.rb"
@@ -8,5 +8,4 @@ require "five9/acd_status.rb"
8
8
 
9
9
 
10
10
  module Five9
11
- # Your code goes here...
12
11
  end
@@ -1,17 +1,17 @@
1
1
  module Five9
2
- class AcdStatus < Statistics
3
- attr_accessor :stats
4
- def initialize(username,password,timeout=300)
5
- @stats = nil
6
- super(username,password,timeout)
7
- end
2
+ class AcdStatus < Statistics
3
+ attr_accessor :stats
4
+ def initialize(username,password,timeout=300)
5
+ @stats = nil
6
+ super(username,password,timeout)
7
+ end
8
8
 
9
- def getStatistics(columns=[])
10
- @stats = super("ACDStatus",columns)
11
- end
9
+ def getStatistics(columns=[])
10
+ @stats = super("ACDStatus",columns)
11
+ end
12
12
 
13
- def getStatisticsUpdate(long_polling_timeout=10000)
14
- super("ACDStatus","Skill Name",long_polling_timeout)
15
- end
16
- end
17
- end
13
+ def getStatisticsUpdate(long_polling_timeout=10000)
14
+ super("ACDStatus","Skill Name",long_polling_timeout)
15
+ end
16
+ end
17
+ end
@@ -1,17 +1,17 @@
1
1
  module Five9
2
- class AgentStats < Statistics
3
- attr_accessor :stats
4
- def initialize(username,password,timeout=300)
5
- @stats = nil
6
- super(username,password,timeout)
7
- end
2
+ class AgentStats < Statistics
3
+ attr_accessor :stats
4
+ def initialize(username,password,timeout=300)
5
+ @stats = nil
6
+ super(username,password,timeout)
7
+ end
8
8
 
9
- def getStatistics(columns=[])
10
- @stats = super("AgentStatistics",columns)
11
- end
9
+ def getStatistics(columns=[])
10
+ @stats = super("AgentStatistics",columns)
11
+ end
12
12
 
13
- def getStatisticsUpdate(long_polling_timeout=10000)
14
- super("AgentStatistics","Username",long_polling_timeout)
15
- end
16
- end
17
- end
13
+ def getStatisticsUpdate(long_polling_timeout=10000)
14
+ super("AgentStatistics","Username",long_polling_timeout)
15
+ end
16
+ end
17
+ end
@@ -1,13 +1,13 @@
1
1
  require 'savon'
2
2
  module Five9
3
- class Base
4
- def initialize(username,password,given_wsdl,timeout=300)
3
+ class Base
4
+ def initialize(username,password,given_wsdl,timeout=300)
5
5
  #For some reason httpclient is not compatible with api.five9.com so we have to manually set this option
6
6
  HTTPI.adapter = :net_http
7
7
  @client = Savon.client do
8
- wsdl "#{given_wsdl}#{username}"
8
+ wsdl "#{given_wsdl}#{username}"
9
9
  basic_auth [username, password]
10
- end
11
- end
12
- end
13
- end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,17 +1,17 @@
1
1
  module Five9
2
- class InboundCampaignStats < Statistics
3
- attr_accessor :stats
4
- def initialize(username,password,timeout=300)
5
- @stats = nil
6
- super(username,password,timeout)
7
- end
2
+ class InboundCampaignStats < Statistics
3
+ attr_accessor :stats
4
+ def initialize(username,password,timeout=300)
5
+ @stats = nil
6
+ super(username,password,timeout)
7
+ end
8
8
 
9
- def getStatistics(columns=[])
10
- @stats = super("InboundCampaignStatistics",columns)
11
- end
9
+ def getStatistics(columns=[])
10
+ @stats = super("InboundCampaignStatistics",columns)
11
+ end
12
12
 
13
- def getStatisticsUpdate(long_polling_timeout=10000)
14
- super("InboundCampaignStatistics","Campaign Name",long_polling_timeout)
15
- end
16
- end
17
- end
13
+ def getStatisticsUpdate(long_polling_timeout=10000)
14
+ super("InboundCampaignStatistics","Campaign Name",long_polling_timeout)
15
+ end
16
+ end
17
+ end
@@ -1,54 +1,50 @@
1
1
  module Five9
2
- class Statistics < Base
3
- def initialize(username,password,timeout=300)
4
- super(username,password,"https://api.five9.com/wssupervisor/SupervisorWebService?wsdl&user=",timeout)
5
- @last_working_timestamp = nil
6
- end
2
+ class Statistics < Base
3
+ def initialize(username,password,timeout=300)
4
+ super(username,password,"https://api.five9.com/wssupervisor/SupervisorWebService?wsdl&user=",timeout)
5
+ @last_working_timestamp = nil
6
+ end
7
7
 
8
- def setSessionParams(options)
9
- @client.call(:set_session_parameters, message: {viewSettings: {rollingPeriod: options[:rolling_period], shiftStart: options[:shift_start], statisticsRange: options[:statistics_range],timeZone: options[:time_zone]}})
10
- end
8
+ def setSessionParams(options)
9
+ @client.call(:set_session_parameters, message: {viewSettings: {rollingPeriod: options[:rolling_period], shiftStart: options[:shift_start], statisticsRange: options[:statistics_range],timeZone: options[:time_zone]}})
10
+ end
11
11
 
12
- def getStatistics(statistic_type,columns=[])
13
- stats = []
14
- response = @client.call(:get_statistics, message: {statisticType: statistic_type, columnNames: {values: { data: columns}}})
15
- data = response.to_array
16
- @last_working_timestamp = data[0][:get_statistics_response][:return][:timestamp]
17
- headers = data[0][:get_statistics_response][:return][:columns][:values][:data]
18
- data[0][:get_statistics_response][:return][:rows].each do |row|
19
- stats.push Hash[headers.zip row[:values][:data]]
20
- end
21
- return stats
22
- end
12
+ def getStatistics(statistic_type,columns=[])
13
+ stats = []
14
+ data = @client.call(:get_statistics, message: {statisticType: statistic_type, columnNames: {values: { data: columns}}}).to_array
15
+ @last_working_timestamp = data[0][:get_statistics_response][:return][:timestamp]
16
+ headers = data[0][:get_statistics_response][:return][:columns][:values][:data]
17
+ data[0][:get_statistics_response][:return][:rows].each do |row|
18
+ stats.push Hash[headers.zip row[:values][:data]]
19
+ end
20
+ return stats
21
+ end
23
22
 
24
- def getStatisticsUpdate(statistic_type, object_name,long_polling_timeout=10000)
25
- begin
26
- prev_timestamp = @last_working_timestamp
27
- response = @client.call(:get_statistics_update, message: {statisticType: statistic_type, previousTimestamp: prev_timestamp, longPollingTimeout: long_polling_timeout})
28
- data = response.to_array
29
- raise TypeError, "No Updated Statistics" if data[0][:get_statistics_update_response][:return].nil?
30
- prev_timestamp = data[0][:get_statistics_update_response][:return][:last_timestamp]
31
- stats = data[0][:get_statistics_update_response][:return][:data_update]
32
- @last_working_timestamp = prev_timestamp
33
- updateStats(stats,object_name)
34
- rescue TypeError => e
35
- p e
36
- p e.backtrace if !e.message.include?("No Updated Statistics")
37
- return false
38
- end
39
- return stats
40
- end
23
+ def getStatisticsUpdate(statistic_type, object_name,long_polling_timeout=10000)
24
+ begin
25
+ data = @client.call(:get_statistics_update, message: {statisticType: statistic_type, previousTimestamp: @last_working_timestamp, longPollingTimeout: long_polling_timeout}).to_array
26
+ raise TypeError, "No Updated Statistics" if data[0][:get_statistics_update_response][:return].nil?
27
+ stats = data[0][:get_statistics_update_response][:return][:data_update]
28
+ @last_working_timestamp = data[0][:get_statistics_update_response][:return][:last_timestamp]
29
+ updateStats(stats,object_name)
30
+ rescue TypeError => e
31
+ p e
32
+ p e.backtrace if !e.message.include?("No Updated Statistics")
33
+ return false
34
+ end
35
+ return stats
36
+ end
41
37
 
42
- private
43
- def updateStats(updated_stats,object_name)
44
- if updated_stats.class == Hash
45
- @stats.each {|stat| stat[updated_stats[:column_name]] = updated_stats[:column_value] if updated_stats[:object_name] == stat[object_name]}
46
- elsif updated_stats.class == Array
47
- updated_stats.each do |updated_stat|
48
- @stats.each {|stat| stat[updated_stat[:column_name]] = updated_stat[:column_value] if updated_stat[:object_name] == stat[object_name]}
49
- end
50
- end
51
- updated_stats
52
- end
53
- end
38
+ private
39
+ def updateStats(updated_stats,object_name)
40
+ if updated_stats.class == Hash
41
+ @stats.each {|stat| stat[updated_stats[:column_name]] = updated_stats[:column_value] if updated_stats[:object_name] == stat[object_name]}
42
+ elsif updated_stats.class == Array
43
+ updated_stats.each do |updated_stat|
44
+ @stats.each {|stat| stat[updated_stat[:column_name]] = updated_stat[:column_value] if updated_stat[:object_name] == stat[object_name]}
45
+ end
46
+ end
47
+ updated_stats
48
+ end
49
+ end
54
50
  end
@@ -0,0 +1,128 @@
1
+ module Five9
2
+ class UserManagement < Base
3
+ # This class is essentially a cut-paste of the User Management methods
4
+ # from the Five9 API. Arguments to the methods should be hashes of the
5
+ # data values required in the API, unless otherwise specified.
6
+
7
+ def initialize(adminuser, password)
8
+ # arguments should be strings
9
+ super(adminuser, password,
10
+ "https://api.five9.com/wsadmin/v2/AdminWebService?wsdl&user=")
11
+ end
12
+
13
+ def create_user(args = {})
14
+ # Use this method to create a user.
15
+ # An exception is thrown if the user already exists, if the limit number of users is reached, or if user attributes are invalid.
16
+ begin
17
+ @client.call :create_user, message: args
18
+ rescue => error
19
+ puts error.to_s.inspect
20
+ return false
21
+ end
22
+ end
23
+
24
+ def delete_user(username)
25
+ # Use this method to delete the specified user.
26
+ # An exception is thrown if the user does not exist.
27
+ # username is a string
28
+ begin
29
+ @client.call :delete_user, message: { user_name: username }
30
+ rescue => error
31
+ puts error.to_s.inspect
32
+ return false
33
+ end
34
+ end
35
+
36
+ def get_users_general_info(username_pattern = nil)
37
+ # Use this method to obtain general information about each user name that matches a pattern.
38
+ # username_pattern should be a regular expression.
39
+ # If omitted or equal to an empty string, all objects are returned.
40
+ # For example, a pattern may be the first characters of the user name.
41
+ begin
42
+ @client.call :get_users_general_info, message: { userNamePattern: username_pattern }
43
+ rescue => error
44
+ puts error.to_s.inspect
45
+ return false
46
+ end
47
+ end
48
+
49
+ def get_users_info(username_pattern = nil)
50
+ # Use this method to obtain information about roles and skills
51
+ # in addition to general information for the user,
52
+ # for each user name that matches a pattern.
53
+ # username_pattern should be a regular expression
54
+ begin
55
+ @client.call :get_users_info, message: { userNamePattern: username_pattern }
56
+ rescue => error
57
+ puts error.to_s.inspect
58
+ return false
59
+ end
60
+ end
61
+
62
+ def modify_user(args = {})
63
+ # Use this method to modify user attributes
64
+ # args may include userGeneralInfo, rolesToSet, and rolesToRemove
65
+ begin
66
+ @client.call :modify_user, message: args
67
+ rescue => error
68
+ puts error.to_s.inspect
69
+ return false
70
+ end
71
+ end
72
+
73
+ def modify_user_canned_reports(args = {})
74
+ # Use this method to modify the list of canned reports associated with a specific user.
75
+ # args may incldue user, cannedReportsToAdd, and cannedReportsToRemove
76
+ begin
77
+ @client.call :modify_user_canned_reports, message: args
78
+ rescue => error
79
+ puts error.to_s.inspect
80
+ return false
81
+ end
82
+ end
83
+
84
+ def add_user_skill(user_skill)
85
+ # user_skill is a userSkill hash
86
+ affect_user_skill(:user_skill_add, user_skill)
87
+ # begin
88
+ # @client.call :userSkillAdd, message: { userSkill: user_skill }
89
+ # rescue => error
90
+ # puts error.to_s.inspect
91
+ # return false
92
+ # end
93
+ end
94
+
95
+ def modify_user_skill(user_skill)
96
+ # user_skill is a userSkill hash
97
+ affect_user_skill(:user_skill_modify, user_skill)
98
+ # begin
99
+ # @client.call :userSkillModify, message: { userSkill: user_skill }
100
+ # rescue => error
101
+ # puts error.to_s.inspect
102
+ # return false
103
+ # end
104
+ end
105
+
106
+ def remove_user_skill(user_skill)
107
+ # user_skill is a userSkill hash
108
+ affect_user_skill(:user_skill_remove, user_skill)
109
+ # begin
110
+ # @client.call :userSkillRemove, message: { userSkill: user_skill }
111
+ # rescue => error
112
+ # puts error.to_s.inspect
113
+ # return false
114
+ # end
115
+ end
116
+
117
+ private
118
+
119
+ def affect_user_skill(affect, user_skill)
120
+ begin
121
+ @client.call affect, message: { userSkill: user_skill }
122
+ rescue => error
123
+ puts error.to_s.inspect
124
+ return false
125
+ end
126
+ end
127
+ end
128
+ end
@@ -1,3 +1,3 @@
1
1
  module Five9
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: five9
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
12
+ date: 2013-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -34,6 +34,7 @@ executables: []
34
34
  extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
+ - .DS_Store
37
38
  - .gitignore
38
39
  - Gemfile
39
40
  - LICENSE.txt
@@ -45,10 +46,10 @@ files:
45
46
  - lib/five9/agent_stats.rb
46
47
  - lib/five9/base.rb
47
48
  - lib/five9/inbound_campaign_stats.rb
48
- - lib/five9/provision.rb
49
49
  - lib/five9/statistics.rb
50
+ - lib/five9/user_management.rb
50
51
  - lib/five9/version.rb
51
- homepage: https://github.com/CorporateTechnologyAdvantage/five9
52
+ homepage: https://github.com/CTA/five9
52
53
  licenses: []
53
54
  post_install_message:
54
55
  rdoc_options: []
@@ -1,4 +0,0 @@
1
- module Five9
2
- class Provision < Base
3
- end
4
- end