Module: FaxFinder::RequestClassMethods

Defined in:
lib/fax_finder/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



12
13
14
# File 'lib/fax_finder/request.rb', line 12

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



12
13
14
# File 'lib/fax_finder/request.rb', line 12

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



12
13
14
# File 'lib/fax_finder/request.rb', line 12

def port
  @port
end

#sslObject (readonly)

Returns the value of attribute ssl.



12
13
14
# File 'lib/fax_finder/request.rb', line 12

def ssl
  @ssl
end

#userObject (readonly)

Returns the value of attribute user.



12
13
14
# File 'lib/fax_finder/request.rb', line 12

def user
  @user
end

Instance Method Details

#configure(_host, _user, _password, _port = Request::DEFAULT_PORT, _ssl = Request::DEFAULT_SSL) ⇒ Object



13
14
15
# File 'lib/fax_finder/request.rb', line 13

def configure(_host, _user, _password, _port=Request::DEFAULT_PORT, _ssl=Request::DEFAULT_SSL)
  @host, @user, @password, @port, @ssl=_host, _user, _password, _port, _ssl
end

#formatted_fax_finder_time(time) ⇒ Object

def proces_http_response(http_response)

return

end



53
54
55
56
57
58
59
# File 'lib/fax_finder/request.rb', line 53

def formatted_fax_finder_time(time)
  result=nil
  if time
    result=(time.utc? ? time : time.utc).strftime(Request::TIME_FORMAT)
  end
  result
end

#postObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fax_finder/request.rb', line 23

def post
  response_body=nil

  begin
    
    _http=Net::HTTP.new(Request.host, Request.port) 
    _http.use_ssl=Request.ssl
    _http.verify_mode = OpenSSL::SSL::VERIFY_NONE if _http.use_ssl?
    
    _http.start {|http|
      http_request = yield
      http_request.basic_auth Request.user, Request.password
      http_request.set_content_type(Request::CONTENT_TYPE)
      http_response = http.request(http_request)
      response_body=http_response.body
    }
  rescue Errno::ECONNREFUSED => e
    response_body=Responses::NO_CONNECTION
  rescue OpenSSL::SSL::SSLError => e
    response_body=Responses::BAD_SSL_CONFIG
  rescue RuntimeError => e
    response_body=Responses::APPLICATION_ERROR.gsub(Responses::ERROR_GSUB, e.message)
  end
  Response.new(Nokogiri::XML(response_body))
end

#resetObject



17
18
19
20
21
# File 'lib/fax_finder/request.rb', line 17

def reset
  @host=@user=@password=nil
  @port=Request::DEFAULT_PORT
  @ssl=Request::DEFAULT_SSL
end