Class: MoesifApi::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/moesif_api/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/moesif_api/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: nil, username: nil, password: nil) ⇒ Object

Get a DELETE HttpRequest object.

Parameters:

  • The (String)

    URL to send the request to.

  • The (Hash, Optional)

    headers for the HTTP Request.

  • Username (String, Optional)

    for Basic Auth requests.

  • Password (String, Optional)

    for Basic Auth requests.



101
102
103
104
105
106
107
108
109
110
# File 'lib/moesif_api/http/http_client.rb', line 101

def delete(query_url,
           headers: nil,
           username: nil,
           password: nil)
  return HttpRequest.new(HttpMethodEnum::DELETE,
                         query_url,
                         headers: headers,
                         username: username,
                         password: password)
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/moesif_api/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/moesif_api/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: nil, username: nil, password: nil) ⇒ Object

Get a GET HttpRequest object.

Parameters:

  • The (String)

    URL to send the request to.

  • The (Hash, Optional)

    headers for the HTTP Request.

  • Username (String, Optional)

    for Basic Auth requests.

  • Password (String, Optional)

    for Basic Auth requests.



28
29
30
31
32
33
34
35
36
37
# File 'lib/moesif_api/http/http_client.rb', line 28

def get(query_url,
        headers: nil,
        username: nil,
        password: nil)
  return HttpRequest.new(HttpMethodEnum::GET,
                         query_url,
                         headers: headers,
                         username: username,
                         password: password)
end

#patch(query_url, headers: nil, parameters: nil, username: nil, password: nil) ⇒ 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.

  • Username (String, Optional)

    for Basic Auth requests.

  • Password (String, Optional)

    for Basic Auth requests.



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/moesif_api/http/http_client.rb', line 83

def patch(query_url,
          headers: nil,
          parameters: nil,
          username: nil,
          password: nil)
  return HttpRequest.new(HttpMethodEnum::PATCH,
                         query_url,
                         headers: headers,
                         parameters: parameters,
                         username: username,
                         password: password)
end

#post(query_url, headers: nil, parameters: nil, username: nil, password: nil) ⇒ 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.

  • Username (String, Optional)

    for Basic Auth requests.

  • Password (String, Optional)

    for Basic Auth requests.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/moesif_api/http/http_client.rb', line 45

def post(query_url,
         headers: nil,
         parameters: nil,
         username: nil,
         password: nil)
  return HttpRequest.new(HttpMethodEnum::POST,
                         query_url,
                         headers: headers,
                         parameters: parameters,
                         username: username,
                         password: password)
end

#put(query_url, headers: nil, parameters: nil, username: nil, password: nil) ⇒ 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.

  • Username (String, Optional)

    for Basic Auth requests.

  • Password (String, Optional)

    for Basic Auth requests.



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/moesif_api/http/http_client.rb', line 64

def put(query_url,
        headers: nil,
        parameters: nil,
        username: nil,
        password: nil)
  return HttpRequest.new(HttpMethodEnum::PUT,
                         query_url,
                         headers: headers,
                         parameters: parameters,
                         username: username,
                         password: password)
end