Class: Calendav::Endpoint

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

Constant Summary collapse

CONTENT_TYPES =
{
  ics: "text/calendar",
  xml: "application/xml; charset=utf-8"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(credentials, timeout: nil) ⇒ Endpoint

Returns a new instance of Endpoint.



14
15
16
17
# File 'lib/calendav/endpoint.rb', line 14

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

Instance Method Details

#delete(url:, etag: nil) ⇒ Object



19
20
21
22
23
# File 'lib/calendav/endpoint.rb', line 19

def delete(url:, etag: nil)
  request(:delete, url: url, http: with_headers(etag: etag))
    .status
    .success?
end

#get(url:) ⇒ Object



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

def get(url:)
  parse request(:get, url: url)
end

#mkcalendar(body, url:) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/calendav/endpoint.rb', line 29

def mkcalendar(body, url:)
  parse request(
    :mkcalendar,
    body,
    url: url,
    http: with_headers(content_type: :xml)
  )
end

#options(url:) ⇒ Object



38
39
40
# File 'lib/calendav/endpoint.rb', line 38

def options(url:)
  request(:options, url: url)
end

#propfind(body, url: nil, depth: 0) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/calendav/endpoint.rb', line 42

def propfind(body, url: nil, depth: 0)
  parse request(
    :propfind,
    body,
    url: url,
    http: with_headers(depth: depth, content_type: :xml)
  )
end

#proppatch(body, url: nil) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/calendav/endpoint.rb', line 51

def proppatch(body, url: nil)
  parse request(
    :proppatch,
    body,
    url: url,
    http: with_headers(content_type: :xml)
  )
end

#put(body, url:, content_type: nil, etag: nil) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/calendav/endpoint.rb', line 60

def put(body, url:, content_type: nil, etag: nil)
  parse request(
    :put,
    body,
    url: url,
    http: with_headers(content_type: content_type, etag: etag)
  )
end

#report(body, url: nil, depth: 0) ⇒ Object



69
70
71
72
73
74
75
76
# File 'lib/calendav/endpoint.rb', line 69

def report(body, url: nil, depth: 0)
  parse request(
    :report,
    body,
    url: url,
    http: with_headers(depth: depth, content_type: :xml)
  )
end