restful-sharepoint 0.2.2 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -0
- data/README.md +0 -0
- data/lib/restful-sharepoint/collection.rb +0 -0
- data/lib/restful-sharepoint/collections/attachments.rb +0 -0
- data/lib/restful-sharepoint/collections/list-items.rb +0 -0
- data/lib/restful-sharepoint/collections/lists.rb +0 -0
- data/lib/restful-sharepoint/collections/webs.rb +0 -0
- data/lib/restful-sharepoint/common-base.rb +0 -0
- data/lib/restful-sharepoint/connection.rb +15 -12
- data/lib/restful-sharepoint/error.rb +0 -0
- data/lib/restful-sharepoint/object.rb +0 -0
- data/lib/restful-sharepoint/objects/attachment.rb +1 -1
- data/lib/restful-sharepoint/objects/file.rb +1 -1
- data/lib/restful-sharepoint/objects/list-item.rb +0 -0
- data/lib/restful-sharepoint/objects/list.rb +1 -1
- data/lib/restful-sharepoint/objects/web.rb +0 -0
- data/lib/restful-sharepoint/version.rb +1 -1
- data/lib/restful-sharepoint.rb +4 -4
- data/restful-sharepoint.gemspec +3 -3
- data/spec/restfulsharepoint_spec.rb +2 -2
- metadata +23 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2e6bddfc8e8eb4afad9644e4fceb24043d312e04341485462de992153c49cdc
|
4
|
+
data.tar.gz: d476fd5cee073d7b86a966716898ffbd0dd510bca811997d9f93c8d46a45d53e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d51978834840b49ea49236b599393d6199a1292ea04eb32e3931a9f69c9d8c645cb50e6776306f70ed3db08297989ce0bd2426ab018f8798422d2d9f81a5674e
|
7
|
+
data.tar.gz: b668f5b57dad92a36aad569443216783d061fb34750ecafe9afe7524b306e65bbf55d7116882a14e7ae9a4c982c1876334ac146ff54636e12a4b3b08c25f1fdf
|
data/Gemfile
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -9,6 +9,10 @@ module RestfulSharePoint
|
|
9
9
|
@username = username
|
10
10
|
@password = password
|
11
11
|
@debug = debug
|
12
|
+
|
13
|
+
@httpclient = HTTPClient.new
|
14
|
+
@httpclient.set_auth(nil, @username, @password) if @username
|
15
|
+
@httpclient.ssl_config.set_default_paths
|
12
16
|
end
|
13
17
|
|
14
18
|
attr_reader :site_url
|
@@ -23,22 +27,22 @@ module RestfulSharePoint
|
|
23
27
|
|
24
28
|
# Path can be either relative to the site URL, or a complete URL itself.
|
25
29
|
# Takes an optional `options` hash which are any number of valid OData query options (dollar sign prefix is added automatically)
|
26
|
-
# Also takes an optional block that is provided the HTTPI::Request instance, allowing customisation of the request.
|
27
30
|
def request(path, method, options: {}, body: nil)
|
28
31
|
url = URI.parse(path).is_a?(URI::HTTP) ? path : "#{@site_url}#{path}"
|
29
32
|
options_str = options.map { |k,v| "$#{k}=#{CGI.escape v.to_s}" }.join('&')
|
30
33
|
url += "?#{options_str}"
|
31
|
-
|
32
|
-
|
34
|
+
|
35
|
+
headers = {'accept' => 'application/json; odata=verbose'}
|
33
36
|
if body
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
body = JSON.dump(body).gsub('/', '\\/') # SharePoint requires forward slashes be escaped in JSON (WTF!!!)
|
38
|
+
headers['Content-Type'] = 'application/json'
|
39
|
+
headers['X-HTTP-Method'] = 'MERGE' # TODO: Extend logic to support all operations
|
40
|
+
headers['If-Match'] = '*'
|
38
41
|
end
|
39
|
-
|
40
|
-
LOG.info "Making HTTP request to: #{
|
41
|
-
response =
|
42
|
+
|
43
|
+
LOG.info "Making HTTP request to: #{url}"
|
44
|
+
response = @httpclient.request(method, url, nil, body, headers)
|
45
|
+
|
42
46
|
if response.body.empty?
|
43
47
|
if response.code >= 300
|
44
48
|
raise RestError, "Server returned HTTP status #{response.code} with no message body."
|
@@ -77,7 +81,6 @@ module RestfulSharePoint
|
|
77
81
|
|
78
82
|
def parse(str)
|
79
83
|
data = JSON.load(str)
|
80
|
-
::File.write('parsed.json', JSON.dump(data))
|
81
84
|
raise RestError, "(#{data['error']['code']}): #{data['error']['message']['value']}" if data['error']
|
82
85
|
parse_tree(data['d'])
|
83
86
|
end
|
@@ -85,7 +88,7 @@ module RestfulSharePoint
|
|
85
88
|
def parse_tree(tree)
|
86
89
|
indices = tree.respond_to?(:keys) ? tree.keys : 0...tree.length
|
87
90
|
indices.each do |i|
|
88
|
-
if tree[i].
|
91
|
+
if tree[i].is_a?(String) && tree[i] =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$/
|
89
92
|
tree[i] = DateTime.parse(tree[i]).new_offset(DateTime.now.offset)
|
90
93
|
elsif tree[i].respond_to?(:gsub!)
|
91
94
|
# Convert relative paths to absolute URL's.
|
File without changes
|
File without changes
|
File without changes
|
@@ -3,7 +3,7 @@ module RestfulSharePoint
|
|
3
3
|
|
4
4
|
def self.from_title(title, connection)
|
5
5
|
new(connection: connection).tap do |list|
|
6
|
-
list.define_singleton_method(:endpoint) { "/_api/web/lists/getbytitle('#{URI.encode title}')" }
|
6
|
+
list.define_singleton_method(:endpoint) { "/_api/web/lists/getbytitle('#{Addressable::URI.encode title}')" }
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
File without changes
|
data/lib/restful-sharepoint.rb
CHANGED
data/restful-sharepoint.gemspec
CHANGED
@@ -9,10 +9,10 @@ Gem::Specification.new 'restful-sharepoint', RestfulSharePoint::VERSION do |s|
|
|
9
9
|
s.homepage = 'https://github.com/Wardrop/restful-sharepoint'
|
10
10
|
s.license = 'MIT'
|
11
11
|
s.files = Dir.glob(`git ls-files`.split("\n") - %w[.gitignore])
|
12
|
-
s.has_rdoc = 'yard'
|
13
12
|
|
14
13
|
s.required_ruby_version = '>= 2.0.0'
|
15
14
|
|
16
|
-
s.add_dependency '
|
17
|
-
s.add_dependency '
|
15
|
+
s.add_dependency 'httpclient', '~> 2.8'
|
16
|
+
s.add_dependency 'rubyntlm', '~> 0.6'
|
17
|
+
s.add_dependency 'addressable', '~> 2.8'
|
18
18
|
end
|
@@ -23,13 +23,13 @@ module RestfulSharePoint
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "can work with an object" do
|
26
|
-
list = Object.new(connection: c, properties: c.get("/_api/web/lists/getbytitle('#{URI.encode CONFIG[:test_list_title]}')"))
|
26
|
+
list = Object.new(connection: c, properties: c.get("/_api/web/lists/getbytitle('#{Addressable::URI.encode CONFIG[:test_list_title]}')"))
|
27
27
|
expect(list['Title']).to eq(CONFIG[:test_list_title])
|
28
28
|
end
|
29
29
|
|
30
30
|
it "can automatically get an object or collection" do
|
31
31
|
lists = c.get_as_object('/_api/web/lists/')
|
32
|
-
list = c.get_as_object("/_api/web/lists/getbytitle('#{URI.encode CONFIG[:test_list_title]}')")
|
32
|
+
list = c.get_as_object("/_api/web/lists/getbytitle('#{Addressable::URI.encode CONFIG[:test_list_title]}')")
|
33
33
|
expect(lists).to be_a(Collection)
|
34
34
|
expect(list).to be_a(Object)
|
35
35
|
end
|
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restful-sharepoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Wardrop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: httpclient
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rubyntlm
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: addressable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.8'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.8'
|
41
55
|
description: Provides a convenient object model to the OData REST API of SharePoint
|
42
56
|
2013 and newer.
|
43
57
|
email: tomw@msc.qld.gov.au
|
@@ -85,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
99
|
- !ruby/object:Gem::Version
|
86
100
|
version: '0'
|
87
101
|
requirements: []
|
88
|
-
|
89
|
-
rubygems_version: 2.7.3
|
102
|
+
rubygems_version: 3.1.2
|
90
103
|
signing_key:
|
91
104
|
specification_version: 4
|
92
105
|
summary: Provides a convenient object model to the OData REST API of SharePoint 2013
|