Class: CalDAV

Inherits:
WebDAV show all
Defined in:
lib/caldav.rb,
lib/CalDAV/VERSION.rb,
lib/CalDAV/Resource.rb,
lib/CalDAV/MultiStatus.rb

Defined Under Namespace

Classes: MultiStatus, Resource

Constant Summary collapse

NAMESPACE =
'urn:ietf:params:xml:ns:caldav'
DAV_NAMESPACE =
'DAV:'
VERSION =
'0.0.1'

Instance Method Summary collapse

Instance Method Details

#calendar_home_set(principal = current_user_principal) ⇒ Object



48
49
50
51
# File 'lib/caldav.rb', line 48

def calendar_home_set(principal = current_user_principal)
  resource = propfind_as_caldav(principal, body: calendar_home_set_body, depth: '0').resources.first
  resource&.then{|r| href_property(r, NAMESPACE, 'calendar-home-set')}
end

#calendar_multiget(path, body:, depth: '0') ⇒ Object

RFC 4791 §7.9. REPORT with a <c:calendar-multiget> body.



29
30
31
# File 'lib/caldav.rb', line 29

def calendar_multiget(path, body:, depth: '0')
  report_as_caldav(path, body: body, depth: depth)
end

#calendar_query(path, body:, depth: '1') ⇒ Object

RFC 4791 §7.8. REPORT with a <c:calendar-query> body.



24
25
26
# File 'lib/caldav.rb', line 24

def calendar_query(path, body:, depth: '1')
  report_as_caldav(path, body: body, depth: depth)
end

#calendars(home = calendar_home_set) ⇒ Object



53
54
55
56
# File 'lib/caldav.rb', line 53

def calendars(home = calendar_home_set)
  resources = propfind_as_caldav(home, body: calendars_body, depth: '1').resources
  resources.select{|resource| resource.is_calendar?}.collect{|resource| resource.href}
end

#current_user_principal(path = discovery_path) ⇒ Object

Discovery helpers. Return paths/strings. And object-oriented discovery API (Principal/Calendar objects) is is planned.



43
44
45
46
# File 'lib/caldav.rb', line 43

def current_user_principal(path = discovery_path)
  resource = propfind_as_caldav(path, body: current_user_principal_body, depth: '0').resources.first
  resource&.then{|r| href_property(r, DAV_NAMESPACE, 'current-user-principal')}
end

#freebusy_query(path, body:, depth: '0') ⇒ Object

RFC 4791 §7.10. REPORT with a <c:free-busy-query> body. Asymmetric: returns the raw response carrying iCalendar VFREEBUSY data, not a multistatus.



35
36
37
38
# File 'lib/caldav.rb', line 35

def freebusy_query(path, body:, depth: '0')
  response = request(:report, path, body: body, headers: {'Depth' => depth})
  handle_response(response)
end

#mkcalendar(path, body: nil) ⇒ Object

RFC 4791 §5.3.1. Creates a calendar collection.



18
19
20
21
# File 'lib/caldav.rb', line 18

def mkcalendar(path, body: nil)
  response = request(:mkcalendar, path, body: body)
  handle_response(response)
end