Class: Sp2010::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/sp_2010.rb

Class Method Summary collapse

Class Method Details

.get_files(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sp_2010.rb', line 14

def self.get_files(options={})
  host = options[:host]
  domain = options[:domain]
  user = options[:user]
  password = options[:password]
  uri = URI.parse(host)
  http = Net::HTTP.new(uri.host, uri.port)
  
  if (use_ssl?(host))
    http.use_ssl = true
  end
  
  req = Net::HTTP::Propfind.new(uri.request_uri)
  
  if domain
    req.ntlm_auth(user, domain, password)
  else
    req.basic_auth(user, password)
  end
  
  res = http.request(req)
  
  FilesResponse.new(res)
end

.use_ssl?(host) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
# File 'lib/sp_2010.rb', line 39

def self.use_ssl?(host)
  x = URI.split(host)
  false if x.count == 0
  x[0] == "https"
end