class Multiwoven::Integrations::Source::OpenAI::Client

def check_connection(connection_config)

def check_connection(connection_config)
  connection_config = prepare_config(connection_config)
  response = send_request(
    url: OPEN_AI_URL,
    http_method: HTTP_POST,
    payload: JSON.parse(connection_config[:request_format]),
    headers: auth_headers(connection_config[:api_key]),
    config: connection_config[:config]
  )
  success?(response) ? success_status : failure_status(nil)
rescue StandardError => e
  handle_exception(e, { context: "OPEN AI:CHECK_CONNECTION:EXCEPTION", type: "error" })
  failure_status(e)
end