Class: GenAI::Api::Client
- Inherits:
-
Object
- Object
- GenAI::Api::Client
- Defined in:
- lib/gen_ai/api/client.rb
Instance Method Summary collapse
- #get(path, options) ⇒ Object
-
#initialize(url:, token:, headers: {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, body, options = {}) ⇒ Object
Constructor Details
#initialize(url:, token:, headers: {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/gen_ai/api/client.rb', line 9 def initialize(url:, token:, headers: {}) @url = url @token = token @headers = headers end |
Instance Method Details
#get(path, options) ⇒ Object
24 25 26 27 28 |
# File 'lib/gen_ai/api/client.rb', line 24 def get(path, ) handle_response do connection.get(path, ) end end |
#post(path, body, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/gen_ai/api/client.rb', line 15 def post(path, body, = {}) multipart = .delete(:multipart) || false payload = multipart ? body : JSON.generate(body) handle_response do connection(multipart: multipart).post(path, payload) end end |