5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/interactors/spree_cm_commissioner/fetch_facebook_user_data.rb', line 5
def call
context.fail!(message: 'fb_access_token_missing') if fb_access_token.blank?
graph_response = fetch_user_info
context.fail!(message: 'invalid_facebook_response') unless graph_response.is_a?(Hash)
context.fail!(message: graph_response['error']['message'] || 'facebook_error') if graph_response['error']
context.provider = {
identity_type: SpreeCmCommissioner::UserIdentityProvider.identity_types[:facebook],
sub: graph_response['id'],
name: graph_response['name'],
email: graph_response['email'],
first_name: graph_response['first_name'],
last_name: graph_response['last_name'],
picture: graph_response.dig('picture', 'data', 'url')
}
end
|