Class: Passport::Thrift::ThriftPassportService
- Inherits:
-
Object
- Object
- Passport::Thrift::ThriftPassportService
- Defined in:
- lib/passport_thrift_client.rb
Instance Method Summary collapse
- #convert_passport_to_hash(passport) ⇒ Object
- #destroy ⇒ Object
- #getMultiNickNameByUids(uidList) ⇒ Object
- #getMultiPassportByMobiles(mobiles) ⇒ Object
- #getNickNameByUid(uid) ⇒ Object
- #getPassportByLoginName(loginName) ⇒ Object
-
#initialize(config = {}) ⇒ ThriftPassportService
constructor
A new instance of ThriftPassportService.
- #modifyPasswordDirectly(uid, password) ⇒ Object
- #queryByMobile(mobile) ⇒ Object
- #queryPassportByEmail(email) ⇒ Object
- #queryPassportByUid(uid) ⇒ Object
- #queryPassportUidMap(uidList) ⇒ Object
- #validatePassword(uid, password) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ ThriftPassportService
Returns a new instance of ThriftPassportService.
252 253 254 255 256 257 258 259 260 261 |
# File 'lib/passport_thrift_client.rb', line 252 def initialize(config = {}) if config['servers'].nil? raise 'servers must be determined!' return end config = DEFAULT_CONFIG.merge(config) config['client_class'] = 'Passport::Thrift::RemotePassportService::Client' @thriftClient = ThriftClient.new(config) @@logger = LoggerFactory.getLogger("ThriftPassportService") end |
Instance Method Details
#convert_passport_to_hash(passport) ⇒ Object
329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/passport_thrift_client.rb', line 329 def convert_passport_to_hash(passport) unless passport.nil? passport = passport.to_hash if passport['createTime'] > 0 passport['createTime'] = Time.at(passport['createTime'] / 1000).to_s else passport['createTime'] = nil end return passport end return nil end |
#destroy ⇒ Object
263 264 265 266 267 268 269 270 271 |
# File 'lib/passport_thrift_client.rb', line 263 def destroy @@logger.error("before ThriftPassportService destroy") begin @thriftClient.destroy rescue Exception => e @@logger.error("ThriftPassportService destroy error !! #{e.message}" + "\n" + e.backtrace.join("\n")) end @@logger.error("ThriftPassportService destroyed!") end |
#getMultiNickNameByUids(uidList) ⇒ Object
289 290 291 |
# File 'lib/passport_thrift_client.rb', line 289 def getMultiNickNameByUids(uidList) @thriftClient.getMultiNickNameByUids(uidList) end |
#getMultiPassportByMobiles(mobiles) ⇒ Object
317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/passport_thrift_client.rb', line 317 def getMultiPassportByMobiles(mobiles) passport_map = @thriftClient.getMultiPassportByMobiles(mobiles) unless passport_map.nil? hash_passport_map = {} passport_map.each do |k, v| hash_passport_map[k] = convert_passport_to_hash(v) end return hash_passport_map end return {} end |
#getNickNameByUid(uid) ⇒ Object
285 286 287 |
# File 'lib/passport_thrift_client.rb', line 285 def getNickNameByUid(uid) @thriftClient.getNickNameByUid(uid) end |
#getPassportByLoginName(loginName) ⇒ Object
305 306 307 |
# File 'lib/passport_thrift_client.rb', line 305 def getPassportByLoginName(loginName) convert_passport_to_hash(@thriftClient.getPassportByLoginName(loginName)) end |
#modifyPasswordDirectly(uid, password) ⇒ Object
309 310 311 |
# File 'lib/passport_thrift_client.rb', line 309 def modifyPasswordDirectly(uid, password) @thriftClient.modifyPasswordDirectly(uid, password) end |
#queryByMobile(mobile) ⇒ Object
313 314 315 |
# File 'lib/passport_thrift_client.rb', line 313 def queryByMobile(mobile) convert_passport_to_hash(@thriftClient.queryByMobile(mobile)) end |
#queryPassportByEmail(email) ⇒ Object
273 274 275 |
# File 'lib/passport_thrift_client.rb', line 273 def queryPassportByEmail(email) convert_passport_to_hash(@thriftClient.queryPassportByEmail(email)) end |
#queryPassportByUid(uid) ⇒ Object
277 278 279 |
# File 'lib/passport_thrift_client.rb', line 277 def queryPassportByUid(uid) convert_passport_to_hash(@thriftClient.queryPassportByUid(uid)) end |
#queryPassportUidMap(uidList) ⇒ Object
293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/passport_thrift_client.rb', line 293 def queryPassportUidMap(uidList) passport_map = @thriftClient.queryPassportUidMap(uidList) unless passport_map.nil? hash_passport_map = {} passport_map.each do |k, v| hash_passport_map[k] = convert_passport_to_hash(v) end return hash_passport_map end return {} end |
#validatePassword(uid, password) ⇒ Object
281 282 283 |
# File 'lib/passport_thrift_client.rb', line 281 def validatePassword(uid, password) @thriftClient.validatePassword(uid, password) end |