Class: Request
- Inherits:
-
Object
- Object
- Request
- Defined in:
- lib/utils/request.rb
Class Method Summary collapse
-
.client_service_get(host, path) ⇒ Object
Will do a request path will be evaluated so there could be parameters in that one and then use ” for the string to have the parameters evaluated in this function.
- .client_service_post(url, param) ⇒ Object
-
.get_base_url(host) ⇒ Object
Get a base url for accessing the client service TODO Change this to https but we need a certificate for that.
Methods included from Logging
create_logger, logger, logger, set_log_conf, set_log_file, set_log_level
Methods included from Retriable
extract_options, set_test_mode, with_retries
Class Method Details
.client_service_get(host, path) ⇒ Object
Will do a request path will be evaluated so there could be parameters in that one and then use ” for the string to have the parameters evaluated in this function
37 38 39 40 41 42 43 44 |
# File 'lib/utils/request.rb', line 37 def self.client_service_get(host, path) url = get_base_url(host) + path logger.debug "Will request url #{url}" result = with_retries(:limit => 10, :sleep=> 5) { RestClient.get url } result_json = JSON.parse(result) logger.debug "The result of the request is #{result.inspect}" result_json end |
.client_service_post(url, param) ⇒ Object
46 47 48 49 50 |
# File 'lib/utils/request.rb', line 46 def self.client_service_post(url, param) logger.debug "Will request url #{url}" result = with_retries(:limit => 10, :sleep=> 5) { RestClient.post url, param } JSON.parse(result) end |
.get_base_url(host) ⇒ Object
Get a base url for accessing the client service TODO Change this to https but we need a certificate for that
25 26 27 28 29 |
# File 'lib/utils/request.rb', line 25 def self.get_base_url(host) url = host url = "http://" + url unless url[0..3] == "http" url end |