Sha256: 4b975545cb8cd94f2bd328599d89024602d99da4188c56710f348ea505f8a84a

Contents?: true

Size: 517 Bytes

Versions: 5

Compression:

Stored size: 517 Bytes

Contents

require 'json'

module RailsSso
  class FetchUser
    def initialize(client)
      @client = client
    end

    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

    private

    attr_reader :client
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_sso-0.7.5 app/services/rails_sso/fetch_user.rb
rails_sso-0.7.4 app/services/rails_sso/fetch_user.rb
rails_sso-0.7.3 app/services/rails_sso/fetch_user.rb
rails_sso-0.7.2 app/services/rails_sso/fetch_user.rb
rails_sso-0.7.1 app/services/rails_sso/fetch_user.rb