sabredav_client 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f09c3b341d38c5d61c5af212eef534715dd2af8d
4
- data.tar.gz: 2d32cde34531ea583dd10f987269bc1dd78da9e4
3
+ metadata.gz: ca4f23c31aaa106ff42d110c689f13678be60ef6
4
+ data.tar.gz: fa738aebd39edc84d711511f69377ed7f2461d40
5
5
  SHA512:
6
- metadata.gz: 39d91dc553f80a8478538622623d7241372a281d490d7567f309e4689064c7cfa9b2edeebb60f4f2f2034e59611edda4cbee7d07edd7491813dd9964fe2c401b
7
- data.tar.gz: 7b415d80e04584b6789362b98ad571e431fa0c6bfef5ea63c5e8694dd618fae7c50d294871599b061425b2877db2908ea7d6776b9f297a23d5a4e0a5d5497b13
6
+ metadata.gz: 8c214b59a07ae43d0fba3c1381c33f6d9447c42fa3e6bc8444867d096dde1d49afefaf4619a3d0e3411097fada80275f505e545a1fff051fd080f25c4c672edd
7
+ data.tar.gz: d6f19be3cd325f08eef0959431e242c8b9e01f55213a9849e647efd8b0012c412943ab0aa17095ddadcc15043458b3ca7f16d75ca97c8cb8bb4a81d4176f5c03
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sabredav_client (0.1.5)
4
+ sabredav_client (0.1.6)
5
5
  builder (~> 3.2)
6
6
  net-http-digest_auth (~> 1.4)
7
7
 
@@ -40,6 +40,21 @@ module SabredavClient
40
40
  info
41
41
  end
42
42
 
43
+ def update(displayname: nil, description: nil)
44
+ body = XmlRequestBuilder::ProppatchCalendar.new(displayname, description).to_xml
45
+ header = {content_type: "application/xml"}
46
+
47
+ req = client.create_request(:proppatch, header: header, body: body)
48
+
49
+ res = req.run
50
+
51
+ if res.code.to_i.between?(200,299)
52
+ true
53
+ else
54
+ SabredavClient::Errors::errorhandling(res)
55
+ end
56
+ end
57
+
43
58
  def delete
44
59
  req = client.create_request(:delete)
45
60
  res = req.run
@@ -3,6 +3,8 @@ module SabredavClient
3
3
 
4
4
  def self.errorhandling response
5
5
  case response.code.to_i
6
+ when 400
7
+ raise SabredavClient::Errors::BadRequestError
6
8
  when 401
7
9
  raise SabredavClient::Errors::AuthenticationError
8
10
  when 403
@@ -32,6 +34,7 @@ module SabredavClient
32
34
  class NotFoundError < APIError; end
33
35
  class PreconditionFailed < APIError; end
34
36
  class NotAllowedError < APIError; end
37
+ class BadRequestError < APIError; end
35
38
  class AuthenticationError < APIError; end
36
39
  class NotExistError < APIError; end
37
40
  end
@@ -56,7 +56,7 @@ module SabredavClient
56
56
  # Warning: This is not a standard request. It only works if your sabredav
57
57
  # server uses a certain OwnerPlugin
58
58
  header = {content_type: "application/xml"}
59
- body = XmlRequestBuilder::ProppatchOwner.new(owner).to_xml
59
+ body = XmlRequestBuilder::ProppatchEventsOwner.new(owner).to_xml
60
60
  req = client.create_request(:proppatch, path: uri, header: header, body: body)
61
61
  res = req.run
62
62
 
@@ -68,7 +68,7 @@ module SabredavClient
68
68
  end
69
69
 
70
70
  def delete(uri)
71
- raise SabredavClient::Errors::SabredavClientError if uri.nil? || !uri.end_with?(".ics")
71
+ raise SabredavClient::Errors::SabredavClientError if uri.nil? || !uri.end_with?(".ics")
72
72
 
73
73
  req = client.create_request(:delete, path: uri)
74
74
  res = req.run
@@ -1,3 +1,3 @@
1
1
  module SabredavClient
2
- VERSION="0.1.6"
2
+ VERSION="0.1.7"
3
3
  end
@@ -0,0 +1,25 @@
1
+ module SabredavClient
2
+ module XmlRequestBuilder
3
+
4
+ class ProppatchCalendar < Base
5
+ attr_accessor :displayname, :description
6
+
7
+ def initialize(displayname = nil, description = nil)
8
+ @displayname = displayname
9
+ @description = description
10
+ super()
11
+ end
12
+
13
+ def to_xml
14
+ xml.d :propertyupdate, C_NAMESPACES do
15
+ xml.d :set do
16
+ xml.d :prop do
17
+ xml.d :displayname, displayname unless displayname.nil?
18
+ xml.tag! "c:calendar-description", description unless description.nil?
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,7 +1,7 @@
1
1
  module SabredavClient
2
2
  module XmlRequestBuilder
3
3
 
4
- class ProppatchOwner < Base
4
+ class ProppatchEventsOwner < Base
5
5
  attr_accessor :owner
6
6
 
7
7
  def initialize(owner)
@@ -1,6 +1,7 @@
1
1
  require 'builder'
2
2
 
3
3
  ['base.rb', 'propfind_calendar.rb', 'mkcalendar.rb', 'post_sharing.rb', 'report_vevent.rb', 'report_vtodo.rb', 'mkcol_principal.rb',
4
- 'report_event_changes.rb', 'propfind_owner.rb', 'proppatch_owner.rb', 'propfind_invite.rb', 'proppatch_principal.rb'].each do |f|
4
+ 'report_event_changes.rb', 'propfind_owner.rb', 'proppatch_events_owner.rb', 'propfind_invite.rb', 'proppatch_principal.rb',
5
+ 'proppatch_calendar.rb'].each do |f|
5
6
  require File.join( File.dirname(__FILE__), 'xml_request_builder', f )
6
7
  end
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <d:propertyupdate xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
3
+ <d:set>
4
+ <d:prop>
5
+ <d:displayname>name</d:displayname>
6
+ <c:calendar-description>description</c:calendar-description>
7
+ </d:prop>
8
+ </d:set>
9
+ </d:propertyupdate>
@@ -40,6 +40,21 @@ describe SabredavClient::Calendar do
40
40
  expect(r[:sync_token]).to eq(sync_token)
41
41
  end
42
42
 
43
+ it "update" do
44
+ description = "a example description"
45
+ displayname = "example discription"
46
+ body = SabredavClient::XmlRequestBuilder::ProppatchCalendar.new(displayname, description).to_xml
47
+ header = {content_type: "application/xml"}
48
+
49
+ FakeWeb.register_uri(:proppatch, "http://user@localhost:5232/user/calendar/", status: ["207", "Multi-Staus"])
50
+
51
+ expect(calendar.client).to receive(:create_request).with(:proppatch, header: header, body: body).and_call_original
52
+
53
+ r = calendar.update(displayname: displayname, description: description)
54
+ expect(r).to be
55
+
56
+ end
57
+
43
58
  it "delete" do
44
59
  FakeWeb.register_uri(:delete, "http://user@localhost:5232/user/calendar/",
45
60
  [{status: ["204", "No Content"]}, {status: ["404", "Not Found"]}])
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe SabredavClient::XmlRequestBuilder::ProppatchCalendar do
4
+
5
+ let(:proppatch) { described_class.new(displayname = "name", description = "description") }
6
+
7
+ describe "#to_xml" do
8
+ let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/proppatch_calendar.xml') }
9
+
10
+ it "returns a valid xml" do
11
+ expect(proppatch.to_xml).to eq(expected_xml)
12
+ end
13
+
14
+ end
15
+ end
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe SabredavClient::XmlRequestBuilder::ProppatchOwner do
3
+ RSpec.describe SabredavClient::XmlRequestBuilder::ProppatchEventsOwner do
4
4
 
5
5
  let(:proppatch) { described_class.new(owner = "principals/usertest") }
6
6
 
7
7
  describe "#to_xml" do
8
- let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/proppatch_owner.xml') }
8
+ let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/proppatch_events_owner.xml') }
9
9
 
10
10
  it "returns a valid xml" do
11
11
  expect(proppatch.to_xml).to eq(expected_xml)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sabredav_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Schwartau
@@ -98,7 +98,8 @@ files:
98
98
  - lib/sabredav_client/xml_request_builder/propfind_calendar.rb
99
99
  - lib/sabredav_client/xml_request_builder/propfind_invite.rb
100
100
  - lib/sabredav_client/xml_request_builder/propfind_owner.rb
101
- - lib/sabredav_client/xml_request_builder/proppatch_owner.rb
101
+ - lib/sabredav_client/xml_request_builder/proppatch_calendar.rb
102
+ - lib/sabredav_client/xml_request_builder/proppatch_events_owner.rb
102
103
  - lib/sabredav_client/xml_request_builder/proppatch_principal.rb
103
104
  - lib/sabredav_client/xml_request_builder/report_event_changes.rb
104
105
  - lib/sabredav_client/xml_request_builder/report_vevent.rb
@@ -117,7 +118,8 @@ files:
117
118
  - spec/fixtures/xml_request_builder/propfind_calendar/all_properties.xml
118
119
  - spec/fixtures/xml_request_builder/propfind_invite.xml
119
120
  - spec/fixtures/xml_request_builder/propfind_owner.xml
120
- - spec/fixtures/xml_request_builder/proppatch_owner.xml
121
+ - spec/fixtures/xml_request_builder/proppatch_calendar.xml
122
+ - spec/fixtures/xml_request_builder/proppatch_events_owner.xml
121
123
  - spec/fixtures/xml_request_builder/proppatch_principal.xml
122
124
  - spec/fixtures/xml_request_builder/report_event_changes.xml
123
125
  - spec/sabredav_client/calendar_spec.rb
@@ -132,7 +134,8 @@ files:
132
134
  - spec/sabredav_client/xml_request_builder_specs/propfind_calendar_spec.rb
133
135
  - spec/sabredav_client/xml_request_builder_specs/propfind_invite_spec.rb
134
136
  - spec/sabredav_client/xml_request_builder_specs/propfind_owner_spec.rb
135
- - spec/sabredav_client/xml_request_builder_specs/proppatch_owner_spec.rb
137
+ - spec/sabredav_client/xml_request_builder_specs/proppatch_calendar.rb
138
+ - spec/sabredav_client/xml_request_builder_specs/proppatch_events_owner_spec.rb
136
139
  - spec/sabredav_client/xml_request_builder_specs/proppatch_principal_spec.rb
137
140
  - spec/sabredav_client/xml_request_builder_specs/report_event_changes_spec.rb
138
141
  - spec/spec.opts