five9 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjFjY2M4ZWE2YTBiMTU5YzFhYWFmMTQ4MDY4NTE3YTcyN2YyNzIzMw==
4
+ YWM0MjE5ZTQ1ZTU5YWYzNTc5ZTAxMjIzNDgwNGU5YTMzYmYxMTgwZg==
5
5
  data.tar.gz: !binary |-
6
- ZmE5ZGQ2ODc2ZmIwOGYyYmI2ZjI4MzVlMWIzMDRmOWFjOWZhYWY0NA==
6
+ M2NkZjRhMWU4YzJjOWY4ZTA0MmU2ZDZlZTk2YjUzNDA5YTZkYWQ1Yw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MmU0MmFlMzVlNmUyYWQxYjQxN2Q5YjU1ZjNmZDg1MDdkMDU4NzIyYjM0YWM4
10
- ZmZkZDI0ZWFhZGI1MTcxN2Q3MDQ3MjgzYWU5ZDg2MDZiZDJiZWY4OGZjMzQ2
11
- YWY2Y2M4YTUwNmI5MTk4ODBhOTU1NDUwMWI5NTg2YWYwZDYyMzI=
9
+ MjI2OWZmYjEzOTk0YTlmNDhhM2JkMzcyNTk5ZTdjYjJkZjRjMDljMDc5OWNi
10
+ OWFhYzQ4MjQzZjFmN2RhNGExYWQ4Njc0N2ZjYmE4ZTI5OGEwYmI4NmM5OTYw
11
+ YTI2NzMzNjAyOGQ5MTdlYmE1MjJjODk2NGQ5OTUwYzRjNzBjOGQ=
12
12
  data.tar.gz: !binary |-
13
- NTMzMzRhMzQwZTU0MDJiNDM2MDExZjMyOTdmOTg4MzRkNWI2MjczMjQ3ZDNk
14
- OTc5NjljODFkNWE4OTExOGMyMmIwOWY3NDM3YzQzZmJiODY3YjA2NzRhMzkw
15
- Y2U2YTE4MjQ1MmY1ZDQwMGMxYzNlNmZiMTA2M2MxY2EzZmQwOTI=
13
+ ZTQ2YjFkZTUxNWZiZGI2ZWY1NTA1NmI2Y2ZlNTk4MWI2MzUyZjc1ZTcxZmYx
14
+ NzkxM2NlOWNiZmQ4ODMzNmU1NDlmMTllNzRiZWRiZDhiMWVhYzlhZmYzODIz
15
+ ODVhOWYxZDFkNTAxNDA5NDk0NzhlOWQyZWI1NjQwODA2YmMwNTQ=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Five9
2
2
 
3
- This RubyGem is a ruby integration for the five9 API. Currently, it is only partly integrated with the statistics API. The end goal is to have a full integration.
3
+ This RubyGem is a ruby integration for the five9 API. Currently, it is only partly integrated with the statistics and user management API. The end goal is to have a full integration.
4
4
 
5
5
  ## Installation
6
6
 
@@ -9,6 +9,7 @@ require "five9/acd_status.rb"
9
9
  require "five9/user_management.rb"
10
10
  require "five9/user.rb"
11
11
  require "five9/user_resources/skill_array.rb"
12
+ require "five9/general_user.rb"
12
13
 
13
14
  module Five9
14
15
  end
@@ -0,0 +1,84 @@
1
+ module Five9
2
+ class GeneralUser
3
+ def initialize(args)
4
+ @user_general_info = args.make_accessible
5
+ end
6
+
7
+ def to_h
8
+ @user_general_info
9
+ end
10
+
11
+ def save!
12
+ if GeneralUser.exist? user_name
13
+ UserManagement.modify_user(build_sendable_hash)[:general_info]
14
+ else
15
+ UserManagement.create! @user_general_info
16
+ end
17
+ end
18
+
19
+ def delete!
20
+ UserManagement.delete_user user_name
21
+ @user_general_info
22
+ end
23
+
24
+ def update(args)
25
+ merge! args
26
+ end
27
+
28
+ def update!(args)
29
+ update(args)
30
+ save!
31
+ end
32
+
33
+ def method_missing(method_name, *args)
34
+ @user_general_info.send(method_name, *args)
35
+ end
36
+
37
+ def self.all
38
+ UserManagement.get_users_general_info.map do |user_general_info|
39
+ new(user_general_info)
40
+ end
41
+ end
42
+
43
+ def self.create!(args)
44
+ new(UserManagement.create_user(build_sendable_hash(args))[:general_info])
45
+ end
46
+
47
+ def self.exist?(username)
48
+ not find(username).nil?
49
+ end
50
+
51
+ def self.find(username)
52
+ general_user = new(UserManagement.get_users_general_info(username))
53
+ if general_user[:user_name]
54
+ general_user
55
+ else
56
+ nil
57
+ end
58
+ end
59
+
60
+ def self.where(args)
61
+ all.keep_if do |general_user|
62
+ general_user.merge(args).to_hash == general_user.to_hash
63
+ end
64
+ end
65
+
66
+ private
67
+ def build_sendable_hash
68
+ result = {}
69
+ result[:userGeneralInfo] = @user_general_info
70
+ result[:userGeneralInfo]["EMail"] =
71
+ @user_general_info[:e_mail] || @user_general_info["EMail"]
72
+ result
73
+ end
74
+
75
+ def self.build_sendable_hash(user_general_info)
76
+ result = {}
77
+ user_general_info["EMail"] ||= user_general_info[:e_mail]
78
+ user_general_info[:can_change_password] = true
79
+ result[:generalInfo] = user_general_info
80
+ result[:roles] = {agent: {}}
81
+ result
82
+ end
83
+ end
84
+ end
@@ -1,5 +1,5 @@
1
1
  module Five9
2
- module UserManagement
2
+ module UserManagement
3
3
  class << self
4
4
  def establish_connection adminuser, password
5
5
  @client = Base.new(adminuser, password,
@@ -97,5 +97,5 @@ module Five9
97
97
  end
98
98
  end
99
99
  end
100
- end
101
- end
100
+ end
101
+ end
@@ -1,3 +1,3 @@
1
1
  module Five9
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: five9
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Hahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-16 00:00:00.000000000 Z
11
+ date: 2013-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -56,6 +56,7 @@ files:
56
56
  - lib/five9/acd_status.rb
57
57
  - lib/five9/agent_stats.rb
58
58
  - lib/five9/base.rb
59
+ - lib/five9/general_user.rb
59
60
  - lib/five9/inbound_campaign_stats.rb
60
61
  - lib/five9/statistics.rb
61
62
  - lib/five9/user.rb