class SolscanApiRuby::Client::FaradayClient

Public Instance Methods

call_api(endpoint:, http_method:, params: {}) click to toggle source
# 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

Private Instance Methods

client() click to toggle source
# File lib/solscan_api_ruby/client/faraday_client.rb, line 30
def client
  Faraday.new(@api_url) do |client|
    client.request :url_encoded
    client.adapter Faraday.default_adapter
  end
end