class SabredavClient::Client

Attributes

authtype[R]
base_path[R]
digest_auth[R]
duri[R]
host[R]
password[R]
port[R]
proxy_host[R]
proxy_port[R]
proxy_uri[R]
ssl[R]
user[R]

Public Class Methods

new(data) click to toggle source
# File lib/sabredav_client/client.rb, line 14
def initialize(data)
  unless data[:proxy_uri].nil?
    proxy_uri   = URI(data[:proxy_uri])
    @proxy_host = proxy_uri.host
    @proxy_port = proxy_uri.port.to_i
  end

  uri = URI(data[:uri])

  @host     = uri.host
  @port     = uri.port.to_i
  @base_path = uri.path
  @user     = data[:user]
  @password = data[:password]
  @ssl      = uri.scheme == 'https'

  unless data[:authtype].nil?
    @authtype = data[:authtype]

    if @authtype == 'digest'

      @digest_auth = Net::HTTP::DigestAuth.new
      @duri = URI.parse data[:uri]
      @duri.user = @user
      @duri.password = @password

    elsif @authtype == 'basic'
      #Don't Raise or do anything else
    else
      raise "Authentication Type Specified Is Not Valid. Please use basic or digest"
    end
  else
    @authtype = 'basic'
  end
end

Public Instance Methods

create_request(method, header: {}, body: "", path: "") click to toggle source
# File lib/sabredav_client/client.rb, line 50
def create_request(method, header: {}, body: "", path: "")
  request = SabredavClient::Request.new(method, self, path)
  request.add_header(header)  unless header.empty?
  request.add_body(body)      unless body.empty?
  request
end
format() click to toggle source
# File lib/sabredav_client/client.rb, line 10
def format
  @format ||= Format::Debug.new
end
format=(fmt) click to toggle source
# File lib/sabredav_client/client.rb, line 6
def format=(fmt)
  @format = fmt
end