Class: ApiUserAuth::Providers::Facebook
- Inherits:
-
Object
- Object
- ApiUserAuth::Providers::Facebook
- Defined in:
- lib/api_user_auth/providers/facebook.rb
Overview
Get info from Facebook token
Constant Summary collapse
- API_PATH =
'https://graph.facebook.com/v3.0/me'.freeze
- FIELDS =
%w[id name email birthday hometown gender picture].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #api_info_url ⇒ Object
- #get_user_data ⇒ Object
-
#initialize(token) ⇒ Facebook
constructor
A new instance of Facebook.
- #user_data ⇒ Object
Constructor Details
#initialize(token) ⇒ Facebook
Returns a new instance of Facebook.
10 11 12 13 |
# File 'lib/api_user_auth/providers/facebook.rb', line 10 def initialize(token) @token = token @data = {} end |
Class Method Details
Instance Method Details
#api_info_url ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/api_user_auth/providers/facebook.rb', line 15 def api_info_url params = { access_token: @token, fields: FIELDS.join(','), format: 'json' } URI("#{API_PATH}?#{params.to_query}") end |
#get_user_data ⇒ Object
24 25 26 27 |
# File 'lib/api_user_auth/providers/facebook.rb', line 24 def get_user_data api_get_request user_data end |
#user_data ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/api_user_auth/providers/facebook.rb', line 29 def user_data { id: @data[:id], name: @data[:name], email: @data[:email] || "#{@data[:id]}@facebook.com", provider: 'facebook', img_url: (@data[:picture] || {}).try(:[], :data).try(:[], :url), info: { birthday: @data[:birthday], city: (@data[:hometown] || {}).try(:[], :name), gender: @data[:gender] } } end |