Sha256: 6c430c11678a901cd8d4a1413ab31a156d83f0a40bf15ce2c13d57b7363f4f95

Contents?: true

Size: 949 Bytes

Versions: 1

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

module OpenaiAsissistant
  # An http client
  class HTTPClient
    # disable_ssl instead of ssl because almost the host is https
    def call_post(url, req_body, headers, disable_ssl: false)
      http = Net::HTTP.new(url.host, url.port)
      http.use_ssl = disable_ssl ? false : true
      request = Net::HTTP::Post.new(url.path, headers)
      request.body = req_body unless req_body.nil?
      http.request(request)
    end

    def call_delete(url, headers, disable_ssl: false)
      http = Net::HTTP.new(url.host, url.port)
      http.use_ssl = disable_ssl ? false : true
      request = Net::HTTP::Delete.new(url.path, headers)
      http.request(request)
    end

    def call_get(url, headers, disable_ssl: false)
      http = Net::HTTP.new(url.host, url.port)
      http.use_ssl = disable_ssl ? false : true
      request = Net::HTTP::Get.new(url.path, headers)
      http.request(request)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openai-assistant-1.0.0 lib/openai_assistant/clients/http/http.rb