Class: CalDAV
- 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.0'
Instance Method Summary collapse
- #calendar_home_set(principal = current_user_principal) ⇒ Object
-
#calendar_multiget(path, body:, depth: '0') ⇒ Object
RFC 4791 §7.9.
-
#calendar_query(path, body:, depth: '1') ⇒ Object
RFC 4791 §7.8.
- #calendars(home = calendar_home_set) ⇒ Object
-
#current_user_principal(path = discovery_path) ⇒ Object
Discovery helpers.
-
#freebusy_query(path, body:, depth: '0') ⇒ Object
RFC 4791 §7.10.
-
#mkcalendar(path, body: nil) ⇒ Object
RFC 4791 §5.3.1.
Instance Method Details
#calendar_home_set(principal = current_user_principal) ⇒ Object
47 48 49 50 |
# File 'lib/CalDAV.rb', line 47 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.
28 29 30 |
# File 'lib/CalDAV.rb', line 28 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.
23 24 25 |
# File 'lib/CalDAV.rb', line 23 def calendar_query(path, body:, depth: '1') report_as_caldav(path, body: body, depth: depth) end |
#calendars(home = calendar_home_set) ⇒ Object
52 53 54 55 |
# File 'lib/CalDAV.rb', line 52 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.
42 43 44 45 |
# File 'lib/CalDAV.rb', line 42 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.
34 35 36 37 |
# File 'lib/CalDAV.rb', line 34 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.
17 18 19 20 |
# File 'lib/CalDAV.rb', line 17 def mkcalendar(path, body: nil) response = request(:mkcalendar, path, body: body) handle_response(response) end |