restful-sharepoint 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restful-sharepoint/connection.rb +14 -11
- data/lib/restful-sharepoint/objects/attachment.rb +1 -1
- data/lib/restful-sharepoint/objects/file.rb +1 -1
- data/lib/restful-sharepoint/objects/list.rb +1 -1
- data/lib/restful-sharepoint/version.rb +1 -1
- data/lib/restful-sharepoint.rb +1 -3
- data/restful-sharepoint.gemspec +1 -1
- data/spec/restfulsharepoint_spec.rb +2 -2
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44cef9ce93eb602accca9fff9cc11e3ee4a5a304b4351c7638b7453d6e789cfc
|
4
|
+
data.tar.gz: 950a9322055853209cb87413dd802d3128ec43eac8ab888060bd13940fea1f49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9094e55c0e4d386192d4afa5df01455f93613e54e85edbc71ccf5628110bb7e323a31134fdc4710d509c136b34763c84e30a8ad24b34cc9a97303db7a5ec8684
|
7
|
+
data.tar.gz: 5468b96644de62e3338495790bc10ed7963fcd4c66a03886de54b9eaae1533651219f1456ffd746dbfc315f02e42657dcb9a0e87c90dec352529065f2353b65a
|
@@ -23,22 +23,25 @@ module RestfulSharePoint
|
|
23
23
|
|
24
24
|
# Path can be either relative to the site URL, or a complete URL itself.
|
25
25
|
# 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
26
|
def request(path, method, options: {}, body: nil)
|
28
27
|
url = URI.parse(path).is_a?(URI::HTTP) ? path : "#{@site_url}#{path}"
|
29
28
|
options_str = options.map { |k,v| "$#{k}=#{CGI.escape v.to_s}" }.join('&')
|
30
29
|
url += "?#{options_str}"
|
31
|
-
|
32
|
-
|
30
|
+
|
31
|
+
httpclient = HTTPClient.new
|
32
|
+
httpclient.set_auth(nil, @username, @password) if @username
|
33
|
+
httpclient.ssl_config.set_default_paths
|
34
|
+
headers = {'accept' => 'application/json; odata=verbose'}
|
33
35
|
if body
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
body = JSON.dump(body).gsub('/', '\\/') # SharePoint requires forward slashes be escaped in JSON (WTF!!!)
|
37
|
+
headers['Content-Type'] = 'application/json'
|
38
|
+
headers['X-HTTP-Method'] = 'MERGE' # TODO: Extend logic to support all operations
|
39
|
+
headers['If-Match'] = '*'
|
38
40
|
end
|
39
|
-
|
40
|
-
LOG.info "Making HTTP request to: #{
|
41
|
-
response =
|
41
|
+
|
42
|
+
LOG.info "Making HTTP request to: #{url}"
|
43
|
+
response = httpclient.request(method, url, nil, body, headers)
|
44
|
+
|
42
45
|
if response.body.empty?
|
43
46
|
if response.code >= 300
|
44
47
|
raise RestError, "Server returned HTTP status #{response.code} with no message body."
|
@@ -84,7 +87,7 @@ module RestfulSharePoint
|
|
84
87
|
def parse_tree(tree)
|
85
88
|
indices = tree.respond_to?(:keys) ? tree.keys : 0...tree.length
|
86
89
|
indices.each do |i|
|
87
|
-
if tree[i].
|
90
|
+
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$/
|
88
91
|
tree[i] = DateTime.parse(tree[i]).new_offset(DateTime.now.offset)
|
89
92
|
elsif tree[i].respond_to?(:gsub!)
|
90
93
|
# Convert relative paths to absolute URL's.
|
@@ -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
|
|
data/lib/restful-sharepoint.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'json'
|
2
|
-
require 'httpi'
|
3
2
|
require 'httpclient'
|
3
|
+
require 'addressable'
|
4
4
|
require 'rubyntlm'
|
5
5
|
require 'cgi'
|
6
6
|
require 'logger'
|
7
7
|
require 'forwardable'
|
8
8
|
|
9
|
-
HTTPI.adapter = :httpclient
|
10
|
-
|
11
9
|
module RestfulSharePoint
|
12
10
|
OBJECT_MAP = {
|
13
11
|
"SP.Web" => :Web,
|
data/restful-sharepoint.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new 'restful-sharepoint', RestfulSharePoint::VERSION do |s|
|
|
12
12
|
|
13
13
|
s.required_ruby_version = '>= 2.0.0'
|
14
14
|
|
15
|
-
s.add_dependency 'httpi', '~> 2.4'
|
16
15
|
s.add_dependency 'httpclient', '~> 2.8'
|
17
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,57 +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.5
|
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-21 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: '
|
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: '
|
40
|
+
version: '0.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: addressable
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.8'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.8'
|
55
55
|
description: Provides a convenient object model to the OData REST API of SharePoint
|
56
56
|
2013 and newer.
|
57
57
|
email: tomw@msc.qld.gov.au
|