Class: Rubygpt::Connection::Faraday
- Inherits:
-
Faraday::Connection
- Object
- Faraday::Connection
- Rubygpt::Connection::Faraday
- Defined in:
- lib/rubygpt/connection/faraday.rb
Overview
The HTTP connection adapter derived from Faraday::Connection
Instance Method Summary collapse
-
#initialize(configuration, faraday_options = {}) ⇒ Faraday
constructor
Initializes a new connection object.
- #post(*args) ⇒ Object
Constructor Details
#initialize(configuration, faraday_options = {}) ⇒ Faraday
Initializes a new connection object
13 14 15 16 17 18 19 20 |
# File 'lib/rubygpt/connection/faraday.rb', line 13 def initialize(configuration, = {}) = { url: configuration.api_url, headers: configuration.to_headers }.merge() super() do |faraday| faraday.request :json faraday.response :json faraday.response :raise_error end end |
Instance Method Details
#post(*args) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/rubygpt/connection/faraday.rb', line 22 def post(*args) faraday_response = super(*args) Rubygpt::Response::StandardApiResponse.new( adapter_response: faraday_response, status: faraday_response.status, body: faraday_response.body, headers: faraday_response.headers ) end |