class MdNotes::HttpClient

An interface for the methods that an HTTP Client must implement.

This class should not be instantiated but should be used as a base class for HTTP Client classes.

Public Instance Methods

convert_response(_response) click to toggle source

Converts the HTTP Response from the client to an HttpResponse object. @param [Dynamic] The response object received from the client.

# File lib/md_notes/http/http_client.rb, line 28
def convert_response(_response)
  raise NotImplementedError, 'This method needs
    to be implemented in a child class.'
end
delete(query_url, headers: {}, parameters: {}) click to toggle source

Get a DELETE HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request.

# File lib/md_notes/http/http_client.rb, line 95
def delete(query_url,
           headers: {},
           parameters: {})
  HttpRequest.new(HttpMethodEnum::DELETE,
                  query_url,
                  headers: headers,
                  parameters: parameters)
end
execute_as_binary(_http_request) click to toggle source

Execute an HttpRequest when the response is expected to be binary. @param [HttpRequest] The HttpRequest to be executed.

# File lib/md_notes/http/http_client.rb, line 21
def execute_as_binary(_http_request)
  raise NotImplementedError, 'This method needs
    to be implemented in a child class.'
end
execute_as_string(_http_request) click to toggle source

Execute an HttpRequest when the response is expected to be a string. @param [HttpRequest] The HttpRequest to be executed.

# File lib/md_notes/http/http_client.rb, line 14
def execute_as_string(_http_request)
  raise NotImplementedError, 'This method needs
    to be implemented in a child class.'
end
get(query_url, headers: {}) click to toggle source

Get a GET HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request.

# File lib/md_notes/http/http_client.rb, line 36
def get(query_url,
        headers: {})
  HttpRequest.new(HttpMethodEnum::GET,
                  query_url,
                  headers: headers)
end
head(query_url, headers: {}) click to toggle source

Get a HEAD HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request.

# File lib/md_notes/http/http_client.rb, line 46
def head(query_url,
         headers: {})
  HttpRequest.new(HttpMethodEnum::HEAD,
                  query_url,
                  headers: headers)
end
patch(query_url, headers: {}, parameters: {}) click to toggle source

Get a PATCH HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request. @param [Hash, Optional] The parameters for the HTTP Request.

# File lib/md_notes/http/http_client.rb, line 83
def patch(query_url,
          headers: {},
          parameters: {})
  HttpRequest.new(HttpMethodEnum::PATCH,
                  query_url,
                  headers: headers,
                  parameters: parameters)
end
post(query_url, headers: {}, parameters: {}) click to toggle source

Get a POST HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request. @param [Hash, Optional] The parameters for the HTTP Request.

# File lib/md_notes/http/http_client.rb, line 57
def post(query_url,
         headers: {},
         parameters: {})
  HttpRequest.new(HttpMethodEnum::POST,
                  query_url,
                  headers: headers,
                  parameters: parameters)
end
put(query_url, headers: {}, parameters: {}) click to toggle source

Get a PUT HttpRequest object. @param [String] The URL to send the request to. @param [Hash, Optional] The headers for the HTTP Request. @param [Hash, Optional] The parameters for the HTTP Request.

# File lib/md_notes/http/http_client.rb, line 70
def put(query_url,
        headers: {},
        parameters: {})
  HttpRequest.new(HttpMethodEnum::PUT,
                  query_url,
                  headers: headers,
                  parameters: parameters)
end