Class: SolscanApiRuby::Client::FaradayClient

Inherits:
Base
  • Object
show all
Includes:
HttpCodes
Defined in:
lib/solscan_api_ruby/client/faraday_client.rb

Constant Summary

Constants included from HttpCodes

HttpCodes::HTTP_BAD_REQUEST_CODE, HttpCodes::HTTP_FORBIDDEN_CODE, HttpCodes::HTTP_INTERNAL_SERVER_ERROR, HttpCodes::HTTP_NOT_FOUND_CODE, HttpCodes::HTTP_OK_CODE, HttpCodes::HTTP_UNAUTHORIZED_CODE, HttpCodes::HTTP_UNPROCESSABLE_ENTITY_CODE

Instance Attribute Summary

Attributes inherited from Base

#api_url

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from SolscanApiRuby::Client::Base

Instance Method Details

#call_api(endpoint:, http_method:, params: {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/solscan_api_ruby/client/faraday_client.rb', line 17

def call_api(endpoint:, http_method:, params: {})
  endpoint_url = create_endpoint_url(endpoint)

  api_response = client.public_send(http_method, endpoint_url, params)
  if api_response.status == HTTP_OK_CODE
    Response.new(api_response)
  else
    fail ApiError.new(api_response)
  end
end