Class: SabredavClient::Principal
- Inherits:
-
Object
- Object
- SabredavClient::Principal
- Defined in:
- lib/sabredav_client/principal.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #create(email, displayname = nil) ⇒ Object
- #delete ⇒ Object
-
#initialize(data) ⇒ Principal
constructor
A new instance of Principal.
- #update(email: "", displayname: "") ⇒ Object
Constructor Details
#initialize(data) ⇒ Principal
Returns a new instance of Principal.
6 7 8 |
# File 'lib/sabredav_client/principal.rb', line 6 def initialize(data) @client = SabredavClient::Client.new(data) end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/sabredav_client/principal.rb', line 4 def client @client end |
Instance Method Details
#create(email, displayname = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sabredav_client/principal.rb', line 10 def create(email, displayname = nil) header = {content_type: "text/xml", depth: "1"} body = SabredavClient::XmlRequestBuilder::MkcolPrincipal.new(email, displayname).to_xml req = client.create_request(:mkcol, header: header, body: body) res = req.run if res.code.to_i.between?(200,299) true else SabredavClient::Errors::errorhandling(res) end end |
#delete ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sabredav_client/principal.rb', line 38 def delete #FIXME seems like deleting a principal is forbidden by sabredav req = client.create_request(:delete) res = req.run if res.code.to_i.between?(200,299) true else SabredavClient::Errors::errorhandling(res) end end |
#update(email: "", displayname: "") ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sabredav_client/principal.rb', line 23 def update(email: "", displayname: "") header = {content_type: "application/xml"} body = SabredavClient::XmlRequestBuilder::ProppatchPrincipal.new(email, displayname).to_xml req = client.create_request(:proppatch, header: header, body: body) res = req.run if res.code.to_i.between?(200,299) true else SabredavClient::Errors::errorhandling(res) end end |