Class: Gonebusy::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/gonebusy/http/http_client.rb

Direct Known Subclasses

FaradayClient

Instance Method Summary collapse

Instance Method Details

#convert_response(response) ⇒ Object

Converts the HTTP Response from the client to an HttpResponse object.

Parameters:

  • The (Dynamic)

    response object received from the client.

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/gonebusy/http/http_client.rb', line 19

def convert_response(response)
  raise NotImplementedError, 'This method needs to be implemented in a child class.'
end

#delete(query_url, headers: {}, parameters: {}) ⇒ Object

Get a DELETE HttpRequest object.

Parameters:

  • The (String)

    URL to send the request to.

  • The (Hash, Optional)

    headers for the HTTP Request.



75
76
77
78
79
80
81
82
# File 'lib/gonebusy/http/http_client.rb', line 75

def delete(query_url,
           headers: {},
           parameters: {})
  return HttpRequest.new(HttpMethodEnum::DELETE,
                         query_url,
                         headers: headers,
                         parameters: parameters)
end

#execute_as_binary(http_request) ⇒ Object

Execute an HttpRequest when the response is expected to be binary.

Parameters:

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/gonebusy/http/http_client.rb', line 13

def execute_as_binary(http_request)
  raise NotImplementedError, 'This method needs to be implemented in a child class.'
end

#execute_as_string(http_request) ⇒ Object

Execute an HttpRequest when the response is expected to be a string.

Parameters:

Raises:

  • (NotImplementedError)


7
8
9
# File 'lib/gonebusy/http/http_client.rb', line 7

def execute_as_string(http_request)
  raise NotImplementedError, 'This method needs to be implemented in a child class.'
end

#get(query_url, headers: {}) ⇒ Object

Get a GET HttpRequest object.

Parameters:

  • The (String)

    URL to send the request to.

  • The (Hash, Optional)

    headers for the HTTP Request.



26
27
28
29
30
31
# File 'lib/gonebusy/http/http_client.rb', line 26

def get(query_url,
        headers: {})
  return HttpRequest.new(HttpMethodEnum::GET,
                         query_url,
                         headers: headers)
end

#patch(query_url, headers: {}, parameters: {}) ⇒ Object

Get a PATCH HttpRequest object.

Parameters:

  • The (String)

    URL to send the request to.

  • The (Hash, Optional)

    headers for the HTTP Request.

  • The (Hash, Optional)

    parameters for the HTTP Request.



63
64
65
66
67
68
69
70
# File 'lib/gonebusy/http/http_client.rb', line 63

def patch(query_url,
          headers: {},
          parameters: {})
  return HttpRequest.new(HttpMethodEnum::PATCH,
                         query_url,
                         headers: headers,
                         parameters: parameters)
end

#post(query_url, headers: {}, parameters: {}) ⇒ Object

Get a POST HttpRequest object.

Parameters:

  • The (String)

    URL to send the request to.

  • The (Hash, Optional)

    headers for the HTTP Request.

  • The (Hash, Optional)

    parameters for the HTTP Request.



37
38
39
40
41
42
43
44
# File 'lib/gonebusy/http/http_client.rb', line 37

def post(query_url,
         headers: {},
         parameters: {})
  return HttpRequest.new(HttpMethodEnum::POST,
                         query_url,
                         headers: headers,
                         parameters: parameters)
end

#put(query_url, headers: {}, parameters: {}) ⇒ Object

Get a PUT HttpRequest object.

Parameters:

  • The (String)

    URL to send the request to.

  • The (Hash, Optional)

    headers for the HTTP Request.

  • The (Hash, Optional)

    parameters for the HTTP Request.



50
51
52
53
54
55
56
57
# File 'lib/gonebusy/http/http_client.rb', line 50

def put(query_url,
        headers: {},
        parameters: {})
  return HttpRequest.new(HttpMethodEnum::PUT,
                         query_url,
                         headers: headers,
                         parameters: parameters)
end