Class: RedirectUri::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/redirect_uri/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Client

Returns a new instance of Client.



3
4
5
6
7
8
9
10
11
# File 'lib/redirect_uri/client.rb', line 3

def initialize(url)
  raise ArgumentError, "url must be a String (given #{url.class.name})" unless url.is_a?(String)

  @uri = Addressable::URI.parse(url)

  raise ArgumentError, 'url must be an absolute URI (e.g. https://example.com)' unless @uri.absolute?
rescue Addressable::URI::InvalidURIError => error
  raise InvalidURIError, error
end

Instance Method Details

#endpointsObject



13
14
15
# File 'lib/redirect_uri/client.rb', line 13

def endpoints
  @endpoints ||= Discover.new(response).endpoints
end

#responseObject



17
18
19
# File 'lib/redirect_uri/client.rb', line 17

def response
  @response ||= Request.new(@uri).response
end