Class: Optimizely::DefaultHttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/optimizely/cmab/cmab_client.rb

Defined Under Namespace

Classes: HttpResponseAdapter

Instance Method Summary collapse

Instance Method Details

#post(url, json: nil, headers: {}, timeout: nil) ⇒ Object

Default HTTP client for making requests. Uses Optimizely::Helpers::HttpUtils to make requests.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/optimizely/cmab/cmab_client.rb', line 186

def post(url, json: nil, headers: {}, timeout: nil)
  # Makes a POST request to the specified URL with JSON body and headers.
  # Args:
  #   url: The endpoint URL.
  #   json: The JSON payload to send in the request body.
  #   headers: Additional headers for the request.
  #   timeout: Maximum wait time for the request to respond in seconds.
  # Returns:
  #   The response object.

  response = Optimizely::Helpers::HttpUtils.make_request(url, :post, json.to_json, headers, timeout)

  HttpResponseAdapter.new(response)
end