cliskip2 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/lib/cliskip2/client.rb +34 -9
- data/lib/cliskip2/user.rb +1 -1
- data/lib/cliskip2/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -32,6 +32,10 @@ A Ruby wrapper for the SKIP2 REST APIs
|
|
32
32
|
client = Cliskip2::Client.new
|
33
33
|
client.update_user :user => {:name => 'foobar', :email => 'hoge@hoge.com'}
|
34
34
|
|
35
|
+
### delete the user by email
|
36
|
+
client = Cliskip2::Client.new
|
37
|
+
client.delete_user :user => {:email => 'hoge@hoge.com'}
|
38
|
+
|
35
39
|
### search communities by the community-name
|
36
40
|
client = Cliskip2::Client.new
|
37
41
|
client.search_communities({:search => {:name => 'I love ruby'} })
|
data/lib/cliskip2/client.rb
CHANGED
@@ -52,14 +52,27 @@ module Cliskip2
|
|
52
52
|
# Update the user by params
|
53
53
|
# @return [Cliskip2::User]
|
54
54
|
def update_user params
|
55
|
-
user = get_user
|
56
|
-
|
57
|
-
|
55
|
+
if user = get_user(:email => params[:user][:email])
|
56
|
+
user_attr = put("/admin/tenants/#{current_user.tenant_id}/users/#{user.id}.json", params)
|
57
|
+
Cliskip2::User.new(user_attr['user'])
|
58
|
+
else
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def delete_user params
|
64
|
+
if user = get_user(:email => params[:user][:email])
|
65
|
+
user_attr = delete("/admin/tenants/#{current_user.tenant_id}/users/#{user.id}.json")
|
66
|
+
Cliskip2::User.new(user_attr['user'])
|
67
|
+
else
|
68
|
+
nil
|
69
|
+
end
|
58
70
|
end
|
59
71
|
|
60
72
|
def sync_users users_csv_path
|
61
73
|
inserted_users_count = 0
|
62
74
|
updated_users_count = 0
|
75
|
+
deleted_users_count = 0
|
63
76
|
failed_users_count = 0
|
64
77
|
skipped_users_count = 0
|
65
78
|
logger.info 'Start syncing users...'
|
@@ -67,13 +80,24 @@ module Cliskip2
|
|
67
80
|
begin
|
68
81
|
if email = row['email'] and email != ''
|
69
82
|
if user = self.get_user(:email => email)
|
70
|
-
|
71
|
-
|
72
|
-
|
83
|
+
if user.status == 'UNUSED' && row['status'] == 'RETIRED'
|
84
|
+
self.delete_user :user => {:email => email}
|
85
|
+
logger.info " Deleted email: #{email}"
|
86
|
+
deleted_users_count = deleted_users_count + 1
|
87
|
+
else
|
88
|
+
self.update_user :user => {:name => row['name'], :email => email, :section => row['section'], :status => row['status']}
|
89
|
+
logger.info " Updated email: #{email}"
|
90
|
+
updated_users_count = updated_users_count + 1
|
91
|
+
end
|
73
92
|
else
|
74
|
-
|
75
|
-
|
76
|
-
|
93
|
+
unless row['status'] == 'RETIRED'
|
94
|
+
self.create_user :user => {:name => row['name'], :email => email, :section => row['section']}
|
95
|
+
logger.info " Inserted email: #{email}"
|
96
|
+
inserted_users_count = inserted_users_count + 1
|
97
|
+
else
|
98
|
+
logger.info " Skipped to sync users. because of retired user."
|
99
|
+
skipped_users_count = skipped_users_count + 1
|
100
|
+
end
|
77
101
|
end
|
78
102
|
else
|
79
103
|
logger.info " Skipped to sync users. because of blank-email."
|
@@ -93,6 +117,7 @@ module Cliskip2
|
|
93
117
|
{
|
94
118
|
:inserted_users_count => inserted_users_count,
|
95
119
|
:updated_users_count => updated_users_count,
|
120
|
+
:deleted_users_count => deleted_users_count,
|
96
121
|
:failed_users_count => failed_users_count,
|
97
122
|
:skipped_users_count => skipped_users_count
|
98
123
|
}
|
data/lib/cliskip2/user.rb
CHANGED
data/lib/cliskip2/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cliskip2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
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: 2012-
|
12
|
+
date: 2012-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday_middleware
|