Module: OpenAI::HTTP
Instance Method Summary collapse
- #delete(path:) ⇒ Object
- #get(path:, parameters: nil) ⇒ Object
- #json_post(path:, parameters:, query_parameters: {}) ⇒ Object
- #multipart_post(path:, parameters: nil) ⇒ Object
- #post(path:) ⇒ Object
Methods included from HTTPHeaders
Instance Method Details
#delete(path:) ⇒ Object
35 36 37 38 39 |
# File 'lib/openai/http.rb', line 35 def delete(path:) conn.delete(uri(path: path)) do |req| req.headers = headers end&.body end |
#get(path:, parameters: nil) ⇒ Object
9 10 11 12 13 |
# File 'lib/openai/http.rb', line 9 def get(path:, parameters: nil) parse_jsonl(conn.get(uri(path: path), parameters) do |req| req.headers = headers end&.body) end |
#json_post(path:, parameters:, query_parameters: {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/openai/http.rb', line 21 def json_post(path:, parameters:, query_parameters: {}) conn.post(uri(path: path)) do |req| configure_json_post_request(req, parameters) req.params = req.params.merge(query_parameters) end&.body end |
#multipart_post(path:, parameters: nil) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/openai/http.rb', line 28 def multipart_post(path:, parameters: nil) conn(multipart: true).post(uri(path: path)) do |req| req.headers = headers.merge({ "Content-Type" => "multipart/form-data" }) req.body = multipart_parameters(parameters) end&.body end |
#post(path:) ⇒ Object
15 16 17 18 19 |
# File 'lib/openai/http.rb', line 15 def post(path:) parse_jsonl(conn.post(uri(path: path)) do |req| req.headers = headers end&.body) end |