Class: GitkitLib::GitkitUser

Inherits:
Object
  • Object
show all
Defined in:
lib/gitkit_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emailObject

Returns the value of attribute email.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def email
  @email
end

#email_verifiedObject

Returns the value of attribute email_verified.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def email_verified
  @email_verified
end

#nameObject

Returns the value of attribute name.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def name
  @name
end

#passwordObject

Returns the value of attribute password.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def password
  @password
end

#password_hashObject

Returns the value of attribute password_hash.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def password_hash
  @password_hash
end

#photo_urlObject

Returns the value of attribute photo_url.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def photo_url
  @photo_url
end

#provider_idObject

Returns the value of attribute provider_id.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def provider_id
  @provider_id
end

#provider_infoObject

Returns the value of attribute provider_info.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def provider_info
  @provider_info
end

#saltObject

Returns the value of attribute salt.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def salt
  @salt
end

#user_idObject

Returns the value of attribute user_id.



259
260
261
# File 'lib/gitkit_client.rb', line 259

def user_id
  @user_id
end

Class Method Details

.parse_from_api_response(api_response) ⇒ Object



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/gitkit_client.rb', line 262

def self.parse_from_api_response(api_response)
  user = self.new
  user.email = api_response.fetch('email', nil)
  user.user_id = api_response.fetch('user_id',
      api_response.fetch('localId', nil))
  user.name = api_response.fetch('displayName', nil)
  user.photo_url = api_response.fetch('photoUrl', nil)
  user.provider_id = api_response.fetch('provider_id',
      api_response.fetch('providerId', nil))
  user.email_verified = api_response.fetch('emailVerified',
      api_response.fetch('verified', nil))
  user.password_hash = api_response.fetch('passwordHash', nil)
  user.salt = api_response.fetch('salt', nil)
  user.password = api_response.fetch('password', nil)
  user.provider_info = api_response.fetch('providerUserInfo', {})
  user
end

Instance Method Details

#to_requestObject

Convert to gitkit api request (a dict)



281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/gitkit_client.rb', line 281

def to_request
  request = {}
  request['email'] = @email if @email
  request['localId'] = @user_id if @user_id
  request['displayName'] = @name if @name
  request['photoUrl'] = @photo_url if @photo_url
  request['emailVerified'] = @email_verified if @email_verified != nil
  request['passwordHash'] =
      JWT.base64url_encode @password_hash if @password_hash
  request['salt'] = JWT.base64url_encode @salt if @salt
  request['providerUserInfo'] = @provider_info if @provider_info != nil
  request
end