passport_thrift_client 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 44b219afea4fc8c88a314af4353e5e18cc4be853
4
+ data.tar.gz: c620abdb51001a00d5f7be7e146710ac8a0a2e93
5
+ SHA512:
6
+ metadata.gz: 6e0ecbb20b147fe0e99ef9eff4bf87b7c0ad368947a12ec00282b553a94912db16f5d41ed7562988f0e4a157d92cf5bf1113865e9b77b8ade0dba79a8bd107c5
7
+ data.tar.gz: 707f0d75dcd765a89b52560f36d3cbbd16479ff271b19d02c9e556751d70cef246e6dc3d8c418b97cdba1e56c9d78df6ff7e1af49b982dd925bb6e2cb5d11494
@@ -0,0 +1,384 @@
1
+ require 'remote_login_service'
2
+ require 'remote_passport_constants'
3
+ require 'remote_passport_service'
4
+ require 'remote_passport_types'
5
+ require 'remote_stat_user_track_service'
6
+ require 'remote_thirdparty_sync_set_service'
7
+ require 'remote_user_profile_service'
8
+
9
+ module Passport
10
+ module Thrift
11
+
12
+ DEFAULT_CONFIG = {
13
+ 'protocol' => 'compact',
14
+ 'transport' => 'socket',
15
+ 'transport_warpper' => 'framed',
16
+ 'size' => 1,
17
+ 'timeout' => 30,
18
+ 'test_on_borrow' => true,
19
+ 'multiplexed' => true,
20
+ 'pool_timeout' => 12
21
+ }
22
+
23
+ class ThriftUserProfileService
24
+
25
+ def initialize(config = {})
26
+ if config['servers'].nil?
27
+ raise 'servers must be determined!'
28
+ return
29
+ end
30
+ config = DEFAULT_CONFIG.merge(config)
31
+ config['client_class'] = 'Passport::Thrift::RemoteUserProfileService::Client'
32
+ @thriftClient = ThriftClient.new(config)
33
+ end
34
+
35
+ def getProfileByUid(uid)
36
+ profile = @thriftClient.getProfileByUid(uid)
37
+ return convert_profile_to_hash(profile)
38
+ end
39
+
40
+ def getProfileByUids(uids)
41
+ profile_map = @thriftClient.getProfileByUids(uids)
42
+ unless profile_map.nil?
43
+ hash_profile_map = {}
44
+ profile_map.each do |k, v|
45
+ hash_profile_map[k] = convert_profile_to_hash(v)
46
+ end
47
+ return hash_profile_map
48
+ end
49
+ return nil
50
+ end
51
+
52
+ def getNicknameByUid(uid)
53
+ @thriftClient.getNicknameByUid(uid)
54
+ end
55
+
56
+ def getMultiNickNameByUids(uidList)
57
+ @thriftClient.getMultiNickNameByUids(uidList)
58
+ end
59
+
60
+ def queryUserBasicInfo(uid)
61
+ convert_user_basicinfo_to_hash(@thriftClient.queryUserBasicInfo(uid))
62
+ end
63
+
64
+ def getMultiUserBasicInfos(uids)
65
+ info_map = @thriftClient.getMultiUserBasicInfos(uids)
66
+ unless info_map.nil?
67
+ hash_info_map = {}
68
+ info_map.each do |k, v|
69
+ hash_info_map[k] = convert_user_basicinfo_to_hash(v)
70
+ end
71
+ return hash_info_map
72
+ end
73
+ return nil
74
+ end
75
+
76
+ def getProfileByNickname(nickname)
77
+ profile_list = @thriftClient.getProfileByNickname(nickname)
78
+ unless profile_list.nil?
79
+ hash_profile_list = []
80
+ profile_list.each do |p|
81
+ hash_profile_list << convert_profile_to_hash(p)
82
+ end
83
+ return hash_profile_list
84
+ end
85
+ return nil
86
+ end
87
+
88
+ def checkNickname(oldNickname, nickname)
89
+ @thriftClient.checkNickname(oldNickname, nickname)
90
+ end
91
+
92
+ def checkNicknameFormat(nickname)
93
+ @thriftClient.checkNicknameFormat(nickname)
94
+ end
95
+
96
+ def checkNicknameDuplicate(oldNickname, nickname)
97
+ @thriftClient.checkNicknameDuplicate(oldNickname, nickname)
98
+ end
99
+
100
+ def getProfielByEmail(email)
101
+ convert_profile_to_hash(@thriftClient.getProfielByEmail(email))
102
+ end
103
+
104
+ def convert_profile_to_hash(profile)
105
+ unless profile.nil?
106
+ profile = profile.to_hash
107
+ if profile['createTime'] > 0
108
+ profile['createTime'] = Time.at(profile['createTime'] / 1000).to_s
109
+ else
110
+ profile['createTime'] = nil
111
+ end
112
+ if profile['lastModifyTime'] > 0
113
+ profile['lastModifyTime'] = Time.at(profile['lastModifyTime'] / 1000).to_s
114
+ else
115
+ profile['lastModifyTime'] = nil
116
+ end
117
+
118
+ if profile['loginBanStart'] > 0
119
+ profile['loginBanStart'] = Time.at(profile['loginBanStart'] / 1000).to_s
120
+ else
121
+ profile['loginBanStart'] = nil
122
+ end
123
+
124
+ if profile['loginBanEnd'] > 0
125
+ profile['loginBanEnd'] = Time.at(profile['loginBanEnd'] / 1000).to_s
126
+ else
127
+ profile['loginBanEnd'] = nil
128
+ end
129
+
130
+ return profile
131
+ end
132
+ return nil
133
+ end
134
+
135
+ def convert_user_basicinfo_to_hash(profile)
136
+ unless profile.nil?
137
+ profile = profile.to_hash
138
+ if profile['createdTime'] > 0
139
+ profile['createdTime'] = Time.at(profile['createdTime'] / 1000).to_s
140
+ else
141
+ profile['createdTime'] = nil
142
+ end
143
+
144
+ if profile['loginBanStart'] > 0
145
+ profile['loginBanStart'] = Time.at(profile['loginBanStart'] / 1000).to_s
146
+ else
147
+ profile['loginBanStart'] = nil
148
+ end
149
+
150
+ if profile['loginBanEnd'] > 0
151
+ profile['loginBanEnd'] = Time.at(profile['loginBanEnd'] / 1000).to_s
152
+ else
153
+ profile['loginBanEnd'] = nil
154
+ end
155
+
156
+ if profile['vCategoryId'] <= 0
157
+ profile['vCategoryId'] = nil
158
+ end
159
+
160
+ return profile
161
+ end
162
+ return nil
163
+ end
164
+ end
165
+
166
+ class ThriftLoginService
167
+ def initialize(config = {})
168
+ if config['servers'].nil?
169
+ raise 'servers must be determined!'
170
+ return
171
+ end
172
+ config = DEFAULT_CONFIG.merge(config)
173
+ config['client_class'] = 'Passport::Thrift::RemoteLoginService::Client'
174
+ @thriftClient = ThriftClient.new(config)
175
+ end
176
+
177
+ def checkLogin(token, rememberMe, loginHelpInfoHash)
178
+ loginHelpInfo = LoginHelpInfo.new(loginHelpInfoHash)
179
+ @thriftClient.checkLogin(token, rememberMe, loginHelpInfo)
180
+ end
181
+
182
+ def login(loginInfoHash, loginHelpInfoHash)
183
+ loginHelpInfo = LoginHelpInfo.new(loginHelpInfoHash)
184
+ loginInfo = LoginInfo.new(loginInfoHash)
185
+ mobileLoginInfo = @thriftClient.login(info, loginHelpInfo)
186
+ unless mobileLoginInfo.nil?
187
+ return mobileLoginInfo.to_hash
188
+ end
189
+ return nil
190
+ end
191
+
192
+ def logout(mobileLoginInfoHash, deviceToken)
193
+ mobileLoginInfo = MobileLoginInfo(mobileLoginInfoHash)
194
+ @thriftClient.logout(mobileLoginInfo, deviceToken)
195
+ end
196
+ end
197
+
198
+ class ThriftPassportService
199
+ def initialize(config = {})
200
+ if config['servers'].nil?
201
+ raise 'servers must be determined!'
202
+ return
203
+ end
204
+ config = DEFAULT_CONFIG.merge(config)
205
+ config['client_class'] = 'Passport::Thrift::RemotePassportService::Client'
206
+ @thriftClient = ThriftClient.new(config)
207
+ end
208
+
209
+ def queryPassportByEmail(email)
210
+ convert_passport_to_hash(@thriftClient.queryPassportByEmail(email))
211
+ end
212
+
213
+ def queryPassportByUid(uid)
214
+ convert_passport_to_hash(@thriftClient.queryPassportByUid(uid))
215
+ end
216
+
217
+ def validatePassword(uid, password)
218
+ @thriftClient.validatePassword(uid, password)
219
+ end
220
+
221
+ def getNickNameByUid(uid)
222
+ @thriftClient.getNickNameByUid(uid)
223
+ end
224
+
225
+ def getMultiNickNameByUids(uidList)
226
+ @thriftClient.getMultiNickNameByUids(uidList)
227
+ end
228
+
229
+ def queryPassportUidMap(uidList)
230
+ passport_map = @thriftClient.queryPassportUidMap(uidList)
231
+ unless passport_map.nil?
232
+ hash_passport_map = {}
233
+ passport_map.each do |k, v|
234
+ hash_passport_map[k] = convert_passport_to_hash(v)
235
+ end
236
+ return hash_passport_map
237
+ end
238
+ return {}
239
+ end
240
+
241
+ def getPassportByLoginName(loginName)
242
+ convert_passport_to_hash(@thriftClient.getPassportByLoginName(loginName))
243
+ end
244
+
245
+ def modifyPasswordDirectly(uid, password)
246
+ @thriftClient.modifyPasswordDirectly(uid, password)
247
+ end
248
+
249
+ def queryByMobile(mobile)
250
+ convert_passport_to_hash(@thriftClient.queryByMobile(mobile))
251
+ end
252
+
253
+ def getMultiPassportByMobiles(mobiles)
254
+ passport_map = @thriftClient.getMultiPassportByMobiles(mobiles)
255
+ unless passport_map.nil?
256
+ hash_passport_map = {}
257
+ passport_map.each do |k, v|
258
+ hash_passport_map[k] = convert_passport_to_hash(v)
259
+ end
260
+ return hash_passport_map
261
+ end
262
+ return {}
263
+ end
264
+
265
+ def convert_passport_to_hash(passport)
266
+ unless passport.nil?
267
+ passport = passport.to_hash
268
+ if passport['createTime'] > 0
269
+ passport['createTime'] = Time.at(passport['createTime'] / 1000).to_s
270
+ else
271
+ passport['createTime'] = nil
272
+ end
273
+ return passport
274
+ end
275
+ return nil
276
+ end
277
+ end
278
+
279
+ class ThriftStatUserTrackService
280
+ def initialize(config = {})
281
+ if config['servers'].nil?
282
+ raise 'servers must be determined!'
283
+ return
284
+ end
285
+ config = DEFAULT_CONFIG.merge(config)
286
+ config['client_class'] = 'Passport::Thrift::RemoteStatUserTrackService::Client'
287
+ @thriftClient = ThriftClient.new(config)
288
+ end
289
+
290
+ def getUserNewTrack(uid)
291
+ @thriftClient.getUserNewTrack(uid)
292
+ end
293
+
294
+ def getUserTotalTime(uid)
295
+ @thriftClient.getUserTotalTime(uid)
296
+ end
297
+
298
+ def getStatTrack(uid)
299
+ convert_stat_track_model_to_hash(@thriftClient.getStatTrack(uid))
300
+ end
301
+
302
+ def getUserNewTracks(uids)
303
+ @thriftClient.getUserNewTracks(uids)
304
+ end
305
+
306
+ def convert_stat_track_model_to_hash(statTrackModel)
307
+ unless statTrackModel.nil?
308
+ statTrackModel = statTrackModel.to_hash
309
+ return statTrackModel
310
+ end
311
+ return nil
312
+ end
313
+ end
314
+
315
+ class ThriftThirdpartySyncSetService
316
+ def initialize(config = {})
317
+ if config['servers'].nil?
318
+ raise 'servers must be determined!'
319
+ return
320
+ end
321
+ config = DEFAULT_CONFIG.merge(config)
322
+ config['client_class'] = 'Passport::Thrift::RemoteThirdpartySyncSetService::Client'
323
+ @thriftClient = ThriftClient.new(config)
324
+ end
325
+
326
+ def insertDefalutSyncSet(tpUid, thirdpartyName)
327
+ convert_sync_set_to_hash(@thriftClient.insertDefalutSyncSet(tpUid, thirdpartyName))
328
+ end
329
+
330
+ def insertOrUpdateToDefaultSet(tpUid, thirdpartyName)
331
+ convert_sync_set_to_hash(@thriftClient.insertOrUpdateToDefaultSet(tpUid, thirdpartyName))
332
+ end
333
+
334
+ def updateOrInsertSyncSet(tpUid, thirdpartyName, syncType, isChecked)
335
+ @thriftClient.updateOrInsertSyncSet(tpUid, thirdpartyName, syncType, isChecked)
336
+ end
337
+
338
+ def updateOrInsertMultiSyncSetColumn(tpUid, thirdpartyName, types)
339
+ @thriftClient.updateOrInsertMultiSyncSetColumn(tpUid, thirdpartyName, types)
340
+ end
341
+
342
+ def updateOrInsertMultiSyncSetColumnSelective(tpUid, thirdpartyName, checkedTypes, unCheckedTypes)
343
+ @thriftClient.updateOrInsertMultiSyncSetColumnSelective(tpUid, thirdpartyName, checkedTypes, unCheckedTypes)
344
+ end
345
+
346
+ def noMoreCommentSyncAlert(uid, noMoreAlert)
347
+ @thriftClient.noMoreCommentSyncAlert(uid, noMoreAlert)
348
+ end
349
+
350
+ def noMoreFavoriteSyncAlert(uid, noMoreAlert)
351
+ @thriftClient.noMoreFavoriteSyncAlert(uid, noMoreAlert)
352
+ end
353
+
354
+ def getSyncSetByType(tpUid, thirdpartyName, syncType)
355
+ @thriftClient.getSyncSetByType(tpUid, thirdpartyName, syncType)
356
+ end
357
+
358
+ def queryByTpUid(tpUid, thirdpartyName)
359
+ convert_sync_set_to_hash(@thriftClient.queryByTpUid(tpUid, thirdpartyName))
360
+ end
361
+
362
+ def queryBindThirdpartySyncSet(bindStatusHashs)
363
+ unless bindStatusHashs.nil?
364
+ bindStatus = []
365
+ bindStatusHashs.each{ |t| bindStatus << BindStatus.new(t) }
366
+ syncSets = @thriftClient.queryBindThirdpartySyncSet(bindStatus)
367
+ unless syncSets.nil?
368
+ sync_set_hashs = []
369
+ syncSets.each { |t| sync_set_hashs << convert_sync_set_to_hash(t)}
370
+ return sync_set_hashs
371
+ end
372
+ end
373
+ return []
374
+ end
375
+
376
+ def convert_sync_set_to_hash(sync_set)
377
+ unless sync_set.nil?
378
+ return sync_set.to_hash
379
+ end
380
+ return nil
381
+ end
382
+ end
383
+ end
384
+ end
@@ -0,0 +1,203 @@
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
@@ -0,0 +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