restful-sharepoint 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29ca961a70f6e8c4b1a9a531debcbddeddd5fe4e12989b50155e918a213df993
4
- data.tar.gz: 10aaba8bc8970492ffec41aca51674d8b5e4909e89395313c0288ccaee888f2d
3
+ metadata.gz: 44cef9ce93eb602accca9fff9cc11e3ee4a5a304b4351c7638b7453d6e789cfc
4
+ data.tar.gz: 950a9322055853209cb87413dd802d3128ec43eac8ab888060bd13940fea1f49
5
5
  SHA512:
6
- metadata.gz: 4a05b21660334d86019530585a1589b08ede33a826d2f5653f9f03a0e379a18a4b5ed361fed0d5c98e1b2c49739ca49dfa83cf076ac652b91ef0a40c546ede52
7
- data.tar.gz: f20ffa94d18cbc9f65ab957081c119811de59ff8436a49fd22c766931f93d6dc0f2c1371215b0049d4b271e6f39fe72f857d0b722d552c922d16204b637900fb
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
- req = HTTPI::Request.new(url: url, headers: {'accept' => 'application/json; odata=verbose'})
32
- req.auth.ntlm(@username, @password) if @username
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
- req.body = JSON.dump(body).gsub('/', '\\/') # SharePoint requires forward slashes be escaped in JSON (WTF!!!)
35
- req.headers['Content-Type'] = 'application/json'
36
- req.headers['X-HTTP-Method'] = 'MERGE' # TODO: Extend logic to support all operations
37
- req.headers['If-Match'] = '*'
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
- yield(req) if block_given?
40
- LOG.info "Making HTTP request to: #{req.url.to_s}"
41
- response = HTTPI.request(method, req) { |x| x.ssl_config.set_default_paths }
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].respond_to?(:=~) && tree[i] =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$/
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 endpoint
5
5
  url = URI.parse(connection.site_url)
6
- url.path = URI.encode(@properties['ServerRelativeUrl'])
6
+ url.path = Addressable::URI.encode(@properties['ServerRelativeUrl'])
7
7
  url.to_s
8
8
  end
9
9
  end
@@ -11,7 +11,7 @@ module RestfulSharePoint
11
11
 
12
12
  def url
13
13
  url = URI.parse(connection.site_url)
14
- url.path = URI.encode(self['ServerRelativeUrl'])
14
+ url.path = Addressable::URI.encode(self['ServerRelativeUrl'])
15
15
  url.to_s
16
16
  end
17
17
 
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module RestfulSharePoint
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
@@ -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,
@@ -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
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: 2020-05-22 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: httpi
14
+ name: httpclient
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
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.4'
26
+ version: '2.8'
27
27
  - !ruby/object:Gem::Dependency
28
- name: httpclient
28
+ name: rubyntlm
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.8'
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: '2.8'
40
+ version: '0.6'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rubyntlm
42
+ name: addressable
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.6'
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: '0.6'
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