dc_tunnel 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dc_tunnel.rb +19 -12
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ecf81e7f40a191351a188e746df9b85954278e3d15be589e9bae397247a8bf2
4
- data.tar.gz: 9b5a1267570f117536d084e325d1835577be2c49f9c9252b2f56b8612b1cd1d7
3
+ metadata.gz: 73c6efee8fa1e3825471d39b0a0f24c29055ae7f2605a98e6eb63921e94ca8bd
4
+ data.tar.gz: 27b329ac15d2f7f1b2800f67e699e6a8b99774d0a591e528751c4da0575fb739
5
5
  SHA512:
6
- metadata.gz: 3cf74e50da5aa831ef94b7713729d230bed113c4378342a23156d3c716d59bc7b4bcd87c4c7d8d671edeab328367ba677495e509fcc84a4af23e8cb066045ec5
7
- data.tar.gz: fa853d2266bb759c9bfda78778db77aed96051923d7309aae1a542390aac785e26489ea0e591482495ba7a169dd75e194db057b600ad3c832b5a31cc5aae8076
6
+ metadata.gz: 42fa2f5c3197c38800aa1b97e3d17e0eade4ba3cbd104dd0a78a61f3f32be23136586190fd7c6e4f831ce7585b2e0c7c364866142a3916cc35c6b4d8900bb70f
7
+ data.tar.gz: 089aa1c928184eca34759faf1512130fc92dc6bdf2cdc6d6003d62ec5ce93323e8dda901f3f1f6569c1cf857c5be33540404fcfabc2b0bb9ed5ee63b19bfe7ce
data/lib/dc_tunnel.rb CHANGED
@@ -12,8 +12,9 @@ class DcTunnel
12
12
  def http_get(url)
13
13
  puts "Tunnel : start get #{url} "
14
14
  res = Net::HTTP.get(URI(url))
15
+ puts "Tunnel : got response #{res} "
15
16
  res = JSON.parse(res).symbolize_keys!
16
- puts "Tunnel : got response #{res} "
17
+ puts "Tunnel : got symbolize_keys! response #{res} "
17
18
  res
18
19
  end
19
20
 
@@ -37,27 +38,30 @@ class DcTunnel
37
38
  end
38
39
 
39
40
  def get_user(id)
40
- http_get self.sso_path("/users/#{id}")
41
+ self.http_get self.sso_path("/users/#{id}")
41
42
  end
42
43
 
43
44
  def get_factories(params = {})
44
- http_get self.sso_path("/factories", params)
45
+ self.http_get self.sso_path("/factories", params)
45
46
  end
46
47
 
47
48
  def get_departments(params = {})
48
- http_get self.sso_path('/departments', params)
49
+ self.http_get self.sso_path('/departments', params)
49
50
  end
50
51
 
51
52
  def get_users(params = {})
52
53
  # available params:
53
54
  # id phone department_ids factory_ids
54
- http_get self.sso_path("/users", params)
55
+ self.http_get self.sso_path("/users", params)
55
56
  end
56
57
 
57
58
  def synchronize
58
- res = http_get self.sso_path('/users', {:system_ids => [self.get_settings[:system_id]]})
59
- res['users'].each do |sso_user|
60
- user = User.find_by_sso_id sso_user['id']
59
+ res = self.http_get self.sso_path('/users', {:system_ids => [self.get_settings[:system_id]]})
60
+ res[:users].each do |sso_user|
61
+ puts "sso_user is #{sso_user}"
62
+ puts "sso_user_id is #{sso_user[:id]}"
63
+ user = User.find_by_sso_id sso_user[:id]
64
+ puts "user is #{user}"
61
65
  if user.nil?
62
66
  create_attributes = {}
63
67
  get_settings[:default_user_props].each do |item|
@@ -65,12 +69,15 @@ class DcTunnel
65
69
  value = item[1]
66
70
  create_attributes[name] = sso_user[name].present? ? sso_user[name] : value
67
71
  end
72
+ puts "create_attributes is #{create_attributes}"
68
73
  User.create create_attributes
69
74
  else
70
- user.update({
71
- name: sso_user[:name],
72
- phone: sso_user[:phone]
73
- })
75
+ update_attributes = {
76
+ name: sso_user[:name],
77
+ phone: sso_user[:phone]
78
+ }
79
+ puts "update_attributes is #{update_attributes}"
80
+ user.update(update_attributes)
74
81
  end
75
82
  end
76
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dc_tunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qxchen