Class: Autodiscover::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email:, password:, username: nil, domain: nil) ⇒ Client

Returns a new instance of Client.

Parameters:

  • email (String)

    An e-mail to use for autodiscovery. It will be used as the default username.

  • password (String)
  • username (String) (defaults to: nil)

    An optional username if you want to authenticate with something other than the e-mail. For instance DOMAIN\user

  • domain (String) (defaults to: nil)

    An optional domain to provide as an override for the one parsed from the e-mail.



13
14
15
16
17
18
19
# File 'lib/autodiscover/client.rb', line 13

def initialize(email:, password:, username: nil, domain: nil)
  @email = email
  @domain = domain || @email.split("@").last
  @http = HTTPClient.new
  @username = username || email
  @http.set_auth(nil, @username, password)
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



4
5
6
# File 'lib/autodiscover/client.rb', line 4

def domain
  @domain
end

#emailObject (readonly)

Returns the value of attribute email.



4
5
6
# File 'lib/autodiscover/client.rb', line 4

def email
  @email
end

#httpObject (readonly)

Returns the value of attribute http.



4
5
6
# File 'lib/autodiscover/client.rb', line 4

def http
  @http
end

Instance Method Details

#autodiscover(type: :pox, **options) ⇒ Object

Parameters:

  • type (Symbol) (defaults to: :pox)

    The type of response. Right now this is just :pox

  • **options (Hash)


23
24
25
26
27
28
29
30
# File 'lib/autodiscover/client.rb', line 23

def autodiscover(type: :pox, **options)
  case type
  when :pox
    PoxRequest.new(self, **options).autodiscover
  else
    raise Autodiscover::ArgumentError, "Not a valid autodiscover type (#{type})."
  end
end