Class: Calendav::Requests::ListCalendars

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

Constant Summary collapse

PROPERTIES =
[
  { key: :display_name, namespace: "dav", name: "displayname" },
  { key: :resource_type, namespace: "dav", name: "resourcetype" },
  { key: :etag, namespace: "dav", name: "getetag" },
  { key: :ctag, namespace: "cs", name: "getctag" },
  { key: :color, namespace: "apple", name: "calendar-color" },
  { key: :sync_token, namespace: "dav", name: "sync-token" },
  { key: :reports, namespace: "dav", name: "supported-report-set" },
  {
    key: :components,
    namespace: "caldav",
    name: "supported-calendar-component-set"
  }
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ ListCalendars

Returns a new instance of ListCalendars.



29
30
31
# File 'lib/calendav/requests/list_calendars.rb', line 29

def initialize(attributes)
  @attributes = attributes
end

Class Method Details

.callObject



25
26
27
# File 'lib/calendav/requests/list_calendars.rb', line 25

def self.call(...)
  new(...).call
end

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/calendav/requests/list_calendars.rb', line 33

def call
  Nokogiri::XML::Builder.new do |xml|
    xml["dav"].propfind(NAMESPACES) do
      xml["dav"].prop do
        properties.each do |hash|
          xml[hash[:namespace]].public_send(hash[:name].to_sym)
        end
      end
    end
  end
end