class SocialPlus::WebApi::User
A class which represents a user of Social Plus
Attributes
@return [Integer] The number of user's followers(reaches)
@return [String] The user's Social Plus ID
@return [ActiveSupport::StringInquirer] The provider which the user has logged in most recently
@return [Profile] The user's profile
@return [Array] The Providers which the user has logged in
Public Class Methods
Fetch information of a user using a given one time token @param [Client] api_client an API client @param [String] token the token returned from Social Plus login @return [User] User
object
# File lib/social_plus/web_api/user.rb, line 16 def authenticate(api_client, token) result = api_client.execute('authenticated_user', token: token, add_profile: true) result['providers'] = api_client.execute('providers_of_user', identifier: result['user']['identifier'])['providers'] new(result) end
@param [hash] params User
information obtained from Social Plus Web API @option params [Hash] “user” User
@option params [Hash] “profile” User's profile @option params [Array] “email” User's email addresses @option params [Hash] “follow” User's counts of following/followed people @option params [Hash] “providers” Providers which the user has logged in
# File lib/social_plus/web_api/user.rb, line 32 def initialize(params) raise ArgumentError, %q|missing 'user'| unless params.key?('user') user = params['user'] raise ArgumentError, %q|missing 'user/identifier'| unless user.key?('identifier') @identifier = user['identifier'] last_logged_in_provider = user['last_logged_in_provider'] || '' @last_logged_in_provider = last_logged_in_provider.inquiry.freeze @profile = SocialPlus::WebApi::Profile.new(params.slice('profile', 'email')).freeze @followers = params.key?('follow') && params['follow'].key?('followed_by') ? params['follow']['followed_by'] : 0 @providers = params['providers'] end