Sha256: eb7e13d34720d131de075c2df75b009668eef2ccb7561c815e2f3760ee00dab6

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

module CoinMarketCapitalization
  # Cryptocurrency class contains methods mapped to API endpoints for cryptocurrencies.
  # This category currently includes 10 endpoints
  class Cryptocurrency < Base
    BASE_URL = "https://pro-api.coinmarketcap.com/v1/cryptocurrency"

    END_POINT_ENTRIES = %w[
      map
      categories
      category
      airdrops
      airdrop
      listings/latest
      listings/historical
      trending/latest
      trending/most-visited
      trending/gainers-losers
    ].freeze

    def initialize(api_key:, base_url: BASE_URL, adapter: Faraday.default_adapter)
      super
    end

    END_POINT_ENTRIES.each do |end_point|
      define_method(end_point.tr("/-", "_").to_sym) do |**args|
        make_request(end_point, **args)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coin_market_capitalization-0.1.2 lib/coin_market_capitalization/cryptocurrency.rb
coin_market_capitalization-0.1.1 lib/coin_market_capitalization/cryptocurrency.rb