Skip to content

Commit

Permalink
Fix method visibility and API endpoint consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Nov 6, 2024
1 parent b46ba08 commit 50557d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions lib/omniauth/strategies/mlh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,13 @@ class MLH < OmniAuth::Strategies::OAuth2 # :nodoc:

def raw_info
@raw_info ||= begin
response = access_token.get("#{options.client_options.api_site}/v4/users/#{uid}").parsed
response = access_token.get("#{options.client_options.site}/v4/users/#{uid}").parsed
normalize_response(response)
rescue StandardError
{}
end
end

private

def normalize_response(response)
return {} unless response.is_a?(Hash)

response.key?('user') ? response.deep_symbolize_keys : { user: response }.deep_symbolize_keys
end

def data
@data ||= begin
response = access_token.get('/api/v4/me').parsed
Expand All @@ -71,6 +63,14 @@ def authorize_params
end
end

private

def normalize_response(response)
return {} unless response.is_a?(Hash)

response.key?('user') ? response.deep_symbolize_keys : { user: response }.deep_symbolize_keys
end

def extract_user_data(response)
return {} unless response.is_a?(Hash)

Expand Down
6 changes: 3 additions & 3 deletions spec/omni_auth/mlh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
expect(omniauth_mlh.client.options[:token_url]).to eq('oauth/token')
end

it 'has correct API site' do
expect(omniauth_mlh.options.client_options[:api_site]).to eq('https://api.mlh.com')
it 'has correct site for API endpoints' do
expect(omniauth_mlh.options.client_options[:site]).to eq('https://my.mlh.io')
end

it 'runs the setup block if passed one' do
Expand Down Expand Up @@ -82,7 +82,7 @@

it 'requests the correct API endpoint' do
omniauth_mlh.raw_info
expect(token).to have_received(:get).with('https://api.mlh.com/v4/users/123')
expect(token).to have_received(:get).with('https://my.mlh.io/v4/users/123')
end

it 'returns symbolized response data' do
Expand Down

0 comments on commit 50557d9

Please sign in to comment.