passport_thrift_client 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de9a26852607376df39ad6148062253bc6a5709d
4
- data.tar.gz: f843d6dd60ca52689f7a7ce4c27f36f5c25cf7e7
3
+ metadata.gz: 54abe927fae2ca5ec4c97e129b147d48abf9d870
4
+ data.tar.gz: d1c198c1351d2d7fc0ea4efb343e4af9d2dae2d1
5
5
  SHA512:
6
- metadata.gz: 2e20f5d79b4f6eca0316b0e218076120b3277dc90e24d603fa1432d3ccb6bcf99b6d9d282ae0ca86fda86bd197a98963ae15c4bc4959b7ffffdd62967f976035
7
- data.tar.gz: f98430d6509fc67ac06deb40b98604c34cfe1290b30d3083d813f7446dfcdbbdd854d05ee0c29e9b11ed7bed77b7520bc4b8b0d0b99ca1f96459d396498589ed
6
+ metadata.gz: 5379488ba3673bb04565c9845084026c8adcf658f67a736d9ea1c6dc5df091a0e3d7ba6c738a2c8af8781512cd05cd0770d16c3d35edccbc6879d21f3c3c7e1e
7
+ data.tar.gz: 1a4fc3d4032e66d4a6c91d2c818a5e2228e94ea30a3861ca8d4a6fb02f8c0b4d699b37d3add1a4e3bc608806c08ad533f76fb339a50319f04a43f48c4b2ab9ac
@@ -4,7 +4,6 @@ require 'remote_passport_service'
4
4
  require 'remote_passport_types'
5
5
  require 'remote_stat_user_track_service'
6
6
  require 'remote_thirdparty_sync_set_service'
7
- require 'remote_user_profile_service'
8
7
  require 'logger'
9
8
 
10
9
  module Passport
@@ -36,183 +35,7 @@ module Passport
36
35
  @@logger
37
36
  end
38
37
  end
39
-
40
- class ThriftUserProfileService
41
-
42
- def initialize(config = {})
43
- if config['servers'].nil?
44
- raise 'servers must be determined!'
45
- return
46
- end
47
- config = DEFAULT_CONFIG.merge(config)
48
- config['client_class'] = 'Passport::Thrift::RemoteUserProfileService::Client'
49
- @thriftClient = ThriftClient.new(config)
50
- @@logger = LoggerFactory.getLogger("ThriftUserProfileService")
51
- end
52
-
53
- def destroy
54
- @@logger.error("before ThriftUserProfileService destroy")
55
- begin
56
- @thriftClient.destroy
57
- rescue Exception => e
58
- @@logger.error("ThriftUserProfileService destroy error !! #{e.message}" + "\n" + e.backtrace.join("\n"))
59
- end
60
- @@logger.error("thriftUserProfileService destroyed!")
61
- end
62
-
63
- def save(profile = {})
64
- if (profile['uid'].nil?)
65
- return
66
- end
67
- profile = Passport::Thrift::Profile.new(profile)
68
- @thriftClient.save(profile)
69
- end
70
-
71
- def getProfileByUid(uid)
72
- profile = @thriftClient.getProfileByUid(uid)
73
- return convert_profile_to_hash(profile)
74
- end
75
-
76
- def getProfileByUids(uids)
77
- profile_map = @thriftClient.getProfileByUids(uids)
78
- unless profile_map.nil?
79
- hash_profile_map = {}
80
- profile_map.each do |k, v|
81
- hash_profile_map[k] = convert_profile_to_hash(v)
82
- end
83
- return hash_profile_map
84
- end
85
- return nil
86
- end
87
-
88
- def getNicknameByUid(uid)
89
- @thriftClient.getNicknameByUid(uid)
90
- end
91
-
92
- def getMultiNickNameByUids(uidList)
93
- @thriftClient.getMultiNickNameByUids(uidList)
94
- end
95
-
96
- def queryUserBasicInfo(uid)
97
- begin
98
- if uid && uid.to_i > 0
99
- info = @thriftClient.queryUserBasicInfo(uid)
100
- info = convert_user_basicinfo_to_hash(info)
101
- end
102
- unless info
103
- @@logger.error("query user basic info return nil , uid: #{uid}")
104
- end
105
- return info
106
- rescue Exception => e
107
- @@logger.error("query user basic info error, uid: #{uid},cause by :#{e.message}," + " \n" + e.backtrace.join("\n"))
108
- if info
109
- @@logger.error("info : #{info.inspect}")
110
- end
111
- end
112
- end
113
-
114
- def getMultiUserBasicInfos(uids)
115
- info_map = @thriftClient.getMultiUserBasicInfos(uids)
116
- unless info_map.nil?
117
- hash_info_map = {}
118
- info_map.each do |k, v|
119
- hash_info_map[k] = convert_user_basicinfo_to_hash(v)
120
- end
121
- return hash_info_map
122
- end
123
- return nil
124
- end
125
-
126
- def getProfileByNickname(nickname)
127
- profile_list = @thriftClient.getProfileByNickname(nickname)
128
- unless profile_list.nil?
129
- hash_profile_list = []
130
- profile_list.each do |p|
131
- hash_profile_list << convert_profile_to_hash(p)
132
- end
133
- return hash_profile_list
134
- end
135
- return nil
136
- end
137
-
138
- def checkNickname(oldNickname, nickname)
139
- @thriftClient.checkNickname(oldNickname, nickname)
140
- end
141
-
142
- def checkNicknameFormat(nickname)
143
- @thriftClient.checkNicknameFormat(nickname)
144
- end
145
-
146
- def checkNicknameDuplicate(oldNickname, nickname)
147
- @thriftClient.checkNicknameDuplicate(oldNickname, nickname)
148
- end
149
-
150
- def getProfielByEmail(email)
151
- convert_profile_to_hash(@thriftClient.getProfielByEmail(email))
152
- end
153
-
154
- def convert_profile_to_hash(profile)
155
- unless profile.nil? || profile.isNull
156
- profile = profile.to_hash
157
- if profile['createTime'] > 0
158
- profile['createTime'] = Time.at(profile['createTime'] / 1000).to_s
159
- else
160
- profile['createTime'] = nil
161
- end
162
- if profile['lastModifyTime'] > 0
163
- profile['lastModifyTime'] = Time.at(profile['lastModifyTime'] / 1000).to_s
164
- else
165
- profile['lastModifyTime'] = nil
166
- end
167
-
168
- if profile['loginBanStart'] > 0
169
- profile['loginBanStart'] = Time.at(profile['loginBanStart'] / 1000).to_s
170
- else
171
- profile['loginBanStart'] = nil
172
- end
173
-
174
- if profile['loginBanEnd'] > 0
175
- profile['loginBanEnd'] = Time.at(profile['loginBanEnd'] / 1000).to_s
176
- else
177
- profile['loginBanEnd'] = nil
178
- end
179
-
180
- return profile
181
- end
182
- return nil
183
- end
184
-
185
- def convert_user_basicinfo_to_hash(profile)
186
- unless profile.nil? || profile.isNull
187
- profile = profile.to_hash
188
- if profile['createdTime'] > 0
189
- profile['createdTime'] = Time.at(profile['createdTime'] / 1000).to_s
190
- else
191
- profile['createdTime'] = nil
192
- end
193
-
194
- if profile['loginBanStart'] > 0
195
- profile['loginBanStart'] = Time.at(profile['loginBanStart'] / 1000).to_s
196
- else
197
- profile['loginBanStart'] = nil
198
- end
199
-
200
- if profile['loginBanEnd'] > 0
201
- profile['loginBanEnd'] = Time.at(profile['loginBanEnd'] / 1000).to_s
202
- else
203
- profile['loginBanEnd'] = nil
204
- end
205
-
206
- if profile['vCategoryId'] <= 0
207
- profile['vCategoryId'] = nil
208
- end
209
-
210
- return profile
211
- end
212
- return nil
213
- end
214
- end
215
-
38
+
216
39
  class ThriftLoginService
217
40
  def initialize(config = {})
218
41
  if config['servers'].nil?
@@ -277,6 +100,14 @@ module Passport
277
100
  end
278
101
  @@logger.error("ThriftPassportService destroyed!")
279
102
  end
103
+
104
+ def modifyPassword(uid, old_password, new_password, new_password_confirm)
105
+ @thriftClient.modifyPassword(uid, old_password, new_password, new_password_confirm)
106
+ end
107
+
108
+ def setPassword(uid, new_password, new_password_confirm)
109
+ @thriftClient.setPassword(uid, new_password, new_password_confirm)
110
+ end
280
111
 
281
112
  def queryPassportByEmail(email)
282
113
  convert_passport_to_hash(@thriftClient.queryPassportByEmail(email))
@@ -1,203 +1,196 @@
1
- #
2
- # Autogenerated by Thrift Compiler (0.9.1)
3
- #
4
- # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- #
6
-
7
- require 'thrift'
8
- require 'remote_passport_types'
9
-
10
- module Passport
11
- module Thrift
12
- module RemoteLoginService
13
- class Client
14
- include ::Thrift::Client
15
-
16
- def checkLogin(token, rememberMe, loginHelpInfo)
17
- send_checkLogin(token, rememberMe, loginHelpInfo)
18
- return recv_checkLogin()
19
- end
20
-
21
- def send_checkLogin(token, rememberMe, loginHelpInfo)
22
- send_message('checkLogin', CheckLogin_args, :token => token, :rememberMe => rememberMe, :loginHelpInfo => loginHelpInfo)
23
- end
24
-
25
- def recv_checkLogin()
26
- result = receive_message(CheckLogin_result)
27
- return result.success unless result.success.nil?
28
- raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'checkLogin failed: unknown result')
29
- end
30
-
31
- def login(info, loginHelpInfo)
32
- send_login(info, loginHelpInfo)
33
- return recv_login()
34
- end
35
-
36
- def send_login(info, loginHelpInfo)
37
- send_message('login', Login_args, :info => info, :loginHelpInfo => loginHelpInfo)
38
- end
39
-
40
- def recv_login()
41
- result = receive_message(Login_result)
42
- return result.success unless result.success.nil?
43
- raise result.ex unless result.ex.nil?
44
- raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'login failed: unknown result')
45
- end
46
-
47
- def logout(info, deviceToken)
48
- send_logout(info, deviceToken)
49
- recv_logout()
50
- end
51
-
52
- def send_logout(info, deviceToken)
53
- send_message('logout', Logout_args, :info => info, :deviceToken => deviceToken)
54
- end
55
-
56
- def recv_logout()
57
- result = receive_message(Logout_result)
58
- return
59
- end
60
-
61
- end
62
-
63
- class Processor
64
- include ::Thrift::Processor
65
-
66
- def process_checkLogin(seqid, iprot, oprot)
67
- args = read_args(iprot, CheckLogin_args)
68
- result = CheckLogin_result.new()
69
- result.success = @handler.checkLogin(args.token, args.rememberMe, args.loginHelpInfo)
70
- write_result(result, oprot, 'checkLogin', seqid)
71
- end
72
-
73
- def process_login(seqid, iprot, oprot)
74
- args = read_args(iprot, Login_args)
75
- result = Login_result.new()
76
- begin
77
- result.success = @handler.login(args.info, args.loginHelpInfo)
78
- rescue ::Passport::Thrift::PassportException => ex
79
- result.ex = ex
80
- end
81
- write_result(result, oprot, 'login', seqid)
82
- end
83
-
84
- def process_logout(seqid, iprot, oprot)
85
- args = read_args(iprot, Logout_args)
86
- result = Logout_result.new()
87
- @handler.logout(args.info, args.deviceToken)
88
- write_result(result, oprot, 'logout', seqid)
89
- end
90
-
91
- end
92
-
93
- # HELPER FUNCTIONS AND STRUCTURES
94
-
95
- class CheckLogin_args
96
- include ::Thrift::Struct, ::Thrift::Struct_Union
97
- TOKEN = 1
98
- REMEMBERME = 2
99
- LOGINHELPINFO = 3
100
-
101
- FIELDS = {
102
- TOKEN => {:type => ::Thrift::Types::STRING, :name => 'token'},
103
- REMEMBERME => {:type => ::Thrift::Types::STRING, :name => 'rememberMe'},
104
- LOGINHELPINFO => {:type => ::Thrift::Types::STRUCT, :name => 'loginHelpInfo', :class => ::Passport::Thrift::LoginHelpInfo}
105
- }
106
-
107
- def struct_fields; FIELDS; end
108
-
109
- def validate
110
- end
111
-
112
- ::Thrift::Struct.generate_accessors self
113
- end
114
-
115
- class CheckLogin_result
116
- include ::Thrift::Struct, ::Thrift::Struct_Union
117
- SUCCESS = 0
118
-
119
- FIELDS = {
120
- SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
121
- }
122
-
123
- def struct_fields; FIELDS; end
124
-
125
- def validate
126
- end
127
-
128
- ::Thrift::Struct.generate_accessors self
129
- end
130
-
131
- class Login_args
132
- include ::Thrift::Struct, ::Thrift::Struct_Union
133
- INFO = 1
134
- LOGINHELPINFO = 2
135
-
136
- FIELDS = {
137
- INFO => {:type => ::Thrift::Types::STRUCT, :name => 'info', :class => ::Passport::Thrift::LoginInfo},
138
- LOGINHELPINFO => {:type => ::Thrift::Types::STRUCT, :name => 'loginHelpInfo', :class => ::Passport::Thrift::LoginHelpInfo}
139
- }
140
-
141
- def struct_fields; FIELDS; end
142
-
143
- def validate
144
- end
145
-
146
- ::Thrift::Struct.generate_accessors self
147
- end
148
-
149
- class Login_result
150
- include ::Thrift::Struct, ::Thrift::Struct_Union
151
- SUCCESS = 0
152
- EX = 1
153
-
154
- FIELDS = {
155
- SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Passport::Thrift::MobileLoginInfo},
156
- EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => ::Passport::Thrift::PassportException}
157
- }
158
-
159
- def struct_fields; FIELDS; end
160
-
161
- def validate
162
- end
163
-
164
- ::Thrift::Struct.generate_accessors self
165
- end
166
-
167
- class Logout_args
168
- include ::Thrift::Struct, ::Thrift::Struct_Union
169
- INFO = 1
170
- DEVICETOKEN = 2
171
-
172
- FIELDS = {
173
- INFO => {:type => ::Thrift::Types::STRUCT, :name => 'info', :class => ::Passport::Thrift::MobileLoginInfo},
174
- DEVICETOKEN => {:type => ::Thrift::Types::STRING, :name => 'deviceToken'}
175
- }
176
-
177
- def struct_fields; FIELDS; end
178
-
179
- def validate
180
- end
181
-
182
- ::Thrift::Struct.generate_accessors self
183
- end
184
-
185
- class Logout_result
186
- include ::Thrift::Struct, ::Thrift::Struct_Union
187
-
188
- FIELDS = {
189
-
190
- }
191
-
192
- def struct_fields; FIELDS; end
193
-
194
- def validate
195
- end
196
-
197
- ::Thrift::Struct.generate_accessors self
198
- end
199
-
200
- end
201
-
202
- end
203
- end
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'remote_passport_types'
9
+
10
+ module Passport
11
+ module Thrift
12
+ module RemoteLoginService
13
+ class Client
14
+ include ::Thrift::Client
15
+
16
+ def checkLogin(token, rememberMe, loginHelpInfo)
17
+ send_checkLogin(token, rememberMe, loginHelpInfo)
18
+ return recv_checkLogin()
19
+ end
20
+
21
+ def send_checkLogin(token, rememberMe, loginHelpInfo)
22
+ send_message('checkLogin', CheckLogin_args, :token => token, :rememberMe => rememberMe, :loginHelpInfo => loginHelpInfo)
23
+ end
24
+
25
+ def recv_checkLogin()
26
+ result = receive_message(CheckLogin_result)
27
+ return result.success unless result.success.nil?
28
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'checkLogin failed: unknown result')
29
+ end
30
+
31
+ def login(info, loginHelpInfo)
32
+ send_login(info, loginHelpInfo)
33
+ return recv_login()
34
+ end
35
+
36
+ def send_login(info, loginHelpInfo)
37
+ send_message('login', Login_args, :info => info, :loginHelpInfo => loginHelpInfo)
38
+ end
39
+
40
+ def recv_login()
41
+ result = receive_message(Login_result)
42
+ return result.success unless result.success.nil?
43
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'login failed: unknown result')
44
+ end
45
+
46
+ def logout(info, deviceToken)
47
+ send_logout(info, deviceToken)
48
+ recv_logout()
49
+ end
50
+
51
+ def send_logout(info, deviceToken)
52
+ send_message('logout', Logout_args, :info => info, :deviceToken => deviceToken)
53
+ end
54
+
55
+ def recv_logout()
56
+ result = receive_message(Logout_result)
57
+ return
58
+ end
59
+
60
+ end
61
+
62
+ class Processor
63
+ include ::Thrift::Processor
64
+
65
+ def process_checkLogin(seqid, iprot, oprot)
66
+ args = read_args(iprot, CheckLogin_args)
67
+ result = CheckLogin_result.new()
68
+ result.success = @handler.checkLogin(args.token, args.rememberMe, args.loginHelpInfo)
69
+ write_result(result, oprot, 'checkLogin', seqid)
70
+ end
71
+
72
+ def process_login(seqid, iprot, oprot)
73
+ args = read_args(iprot, Login_args)
74
+ result = Login_result.new()
75
+ result.success = @handler.login(args.info, args.loginHelpInfo)
76
+ write_result(result, oprot, 'login', seqid)
77
+ end
78
+
79
+ def process_logout(seqid, iprot, oprot)
80
+ args = read_args(iprot, Logout_args)
81
+ result = Logout_result.new()
82
+ @handler.logout(args.info, args.deviceToken)
83
+ write_result(result, oprot, 'logout', seqid)
84
+ end
85
+
86
+ end
87
+
88
+ # HELPER FUNCTIONS AND STRUCTURES
89
+
90
+ class CheckLogin_args
91
+ include ::Thrift::Struct, ::Thrift::Struct_Union
92
+ TOKEN = 1
93
+ REMEMBERME = 2
94
+ LOGINHELPINFO = 3
95
+
96
+ FIELDS = {
97
+ TOKEN => {:type => ::Thrift::Types::STRING, :name => 'token'},
98
+ REMEMBERME => {:type => ::Thrift::Types::STRING, :name => 'rememberMe'},
99
+ LOGINHELPINFO => {:type => ::Thrift::Types::STRUCT, :name => 'loginHelpInfo', :class => ::Passport::Thrift::LoginHelpInfo}
100
+ }
101
+
102
+ def struct_fields; FIELDS; end
103
+
104
+ def validate
105
+ end
106
+
107
+ ::Thrift::Struct.generate_accessors self
108
+ end
109
+
110
+ class CheckLogin_result
111
+ include ::Thrift::Struct, ::Thrift::Struct_Union
112
+ SUCCESS = 0
113
+
114
+ FIELDS = {
115
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
116
+ }
117
+
118
+ def struct_fields; FIELDS; end
119
+
120
+ def validate
121
+ end
122
+
123
+ ::Thrift::Struct.generate_accessors self
124
+ end
125
+
126
+ class Login_args
127
+ include ::Thrift::Struct, ::Thrift::Struct_Union
128
+ INFO = 1
129
+ LOGINHELPINFO = 2
130
+
131
+ FIELDS = {
132
+ INFO => {:type => ::Thrift::Types::STRUCT, :name => 'info', :class => ::Passport::Thrift::LoginInfo},
133
+ LOGINHELPINFO => {:type => ::Thrift::Types::STRUCT, :name => 'loginHelpInfo', :class => ::Passport::Thrift::LoginHelpInfo}
134
+ }
135
+
136
+ def struct_fields; FIELDS; end
137
+
138
+ def validate
139
+ end
140
+
141
+ ::Thrift::Struct.generate_accessors self
142
+ end
143
+
144
+ class Login_result
145
+ include ::Thrift::Struct, ::Thrift::Struct_Union
146
+ SUCCESS = 0
147
+
148
+ FIELDS = {
149
+ SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Passport::Thrift::MobileLoginInfo}
150
+ }
151
+
152
+ def struct_fields; FIELDS; end
153
+
154
+ def validate
155
+ end
156
+
157
+ ::Thrift::Struct.generate_accessors self
158
+ end
159
+
160
+ class Logout_args
161
+ include ::Thrift::Struct, ::Thrift::Struct_Union
162
+ INFO = 1
163
+ DEVICETOKEN = 2
164
+
165
+ FIELDS = {
166
+ INFO => {:type => ::Thrift::Types::STRUCT, :name => 'info', :class => ::Passport::Thrift::MobileLoginInfo},
167
+ DEVICETOKEN => {:type => ::Thrift::Types::STRING, :name => 'deviceToken'}
168
+ }
169
+
170
+ def struct_fields; FIELDS; end
171
+
172
+ def validate
173
+ end
174
+
175
+ ::Thrift::Struct.generate_accessors self
176
+ end
177
+
178
+ class Logout_result
179
+ include ::Thrift::Struct, ::Thrift::Struct_Union
180
+
181
+ FIELDS = {
182
+
183
+ }
184
+
185
+ def struct_fields; FIELDS; end
186
+
187
+ def validate
188
+ end
189
+
190
+ ::Thrift::Struct.generate_accessors self
191
+ end
192
+
193
+ end
194
+
195
+ end
196
+ end
@@ -1,13 +1,13 @@
1
- #
2
- # Autogenerated by Thrift Compiler (0.9.1)
3
- #
4
- # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- #
6
-
7
- require 'thrift'
8
- require 'remote_passport_types'
9
-
10
- module Passport
11
- module Thrift
12
- end
13
- end
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'remote_passport_types'
9
+
10
+ module Passport
11
+ module Thrift
12
+ end
13
+ end