Method: EasyLlama::Client::Api#send_request

Defined in:
lib/easyllama/api.rb

#send_request(path: nil, method: :get, body: nil) ⇒ Net::HTTPResponse

Sends an HTTP request to the specified path.

Parameters:

  • path (String) (defaults to: nil)

    The path of the API endpoint.

  • method (Symbol) (defaults to: :get)

    The HTTP method (:get, :post, :put, :patch, :delete).

  • body (Hash) (defaults to: nil)

    The request body (optional).

Returns:

  • (Net::HTTPResponse)

    The HTTP response.

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
# File 'lib/easyllama/api.rb', line 26

def send_request(path: nil, method: :get, body: nil)
  raise ArgumentError, 'Please provide EasyLlama::Client.api_token' if @token.nil?

  uri = build_uri(path)
  request = build_request(uri, method, body)
  execute_request(uri, request)
end