Class: Thirdweb::Engine::Api
- Inherits:
-
Object
- Object
- Thirdweb::Engine::Api
- Defined in:
- lib/thirdweb/engine/api.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#get(path, params = {}) ⇒ Hash{Symbol->Object
].
- #initialize ⇒ Faraday::Connection constructor
-
#post(path, body = {}) ⇒ Hash{Symbol->Object
].
Constructor Details
#initialize ⇒ Faraday::Connection
17 18 19 20 21 22 23 24 25 |
# File 'lib/thirdweb/engine/api.rb', line 17 def initialize @connection = Faraday.new(url: Thirdweb::Engine.config.base_url) do |c| c.request :json c.response :json c.use Faraday::Retry::Middleware c.adapter Faraday.default_adapter c.headers = headers end end |
Class Method Details
.instance ⇒ Api
11 12 13 |
# File 'lib/thirdweb/engine/api.rb', line 11 def instance @instance ||= new end |
Instance Method Details
#get(path, params = {}) ⇒ Hash{Symbol->Object
Returns ].
30 31 32 33 34 |
# File 'lib/thirdweb/engine/api.rb', line 30 def get(path, params = {}) handle_response do @connection.get(path, params) end end |
#post(path, body = {}) ⇒ Hash{Symbol->Object
Returns ].
39 40 41 42 43 |
# File 'lib/thirdweb/engine/api.rb', line 39 def post(path, body = {}) handle_response do @connection.post(path, body) end end |