Class: Calendav::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(credentials, timeout: nil) ⇒ Client

Returns a new instance of Client.



11
12
13
14
# File 'lib/calendav/client.rb', line 11

def initialize(credentials, timeout: nil)
  @credentials = credentials
  @timeout = timeout
end

Instance Method Details

#calendarsObject



16
17
18
# File 'lib/calendav/client.rb', line 16

def calendars
  @calendars = Clients::CalendarsClient.new(self, endpoint, credentials)
end

#eventsObject



20
21
22
# File 'lib/calendav/client.rb', line 20

def events
  @events = Clients::EventsClient.new(self, endpoint, credentials)
end

#principal_urlObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/calendav/client.rb', line 24

def principal_url
  @principal_url ||= begin
    request = Requests::CurrentUserPrincipal.call
    response = endpoint.propfind(request.to_xml).first

    ContextualURL.call(
      credentials.host,
      response.xpath(".//dav:current-user-principal/dav:href").text
    )
  end
end