Class: RailsSso::FetchUser

Inherits:
Object
  • Object
show all
Defined in:
app/services/rails_sso/fetch_user.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ FetchUser

Returns a new instance of FetchUser.



5
6
7
# File 'app/services/rails_sso/fetch_user.rb', line 5

def initialize(client)
  @client = client
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/rails_sso/fetch_user.rb', line 9

def call
  response = client.get(RailsSso.config.provider_profile_path)

  case response.status
  when 200
    begin
      JSON.parse(response.body)
    rescue
      response.body
    end
  when 401
    raise ResponseError.new(:unauthenticated)
  else
    raise ResponseError.new(:unknown)
  end
end