rdavid1099/poke-api-v2

View on GitHub
lib/poke-api-v2.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
require_relative './config/setup' # rubocop:disable Naming/FileName

# Main module for gem operation
module PokeApi
  class << self
    def get(unnamed_resource = nil, **endpoint_opts)
      Fetcher.get_endpoints(unnamed_resource, endpoint_opts)
    end

    def get!(unnamed_resource = nil, **endpoint_opts)
      Fetcher.get_endpoints(unnamed_resource, endpoint_opts, throw_error: true)
    end

    def pokedex(query = nil)
      query ||= (rand(POKEMON_COUNT) + 1)
      get(pokemon: query)
    end
  end
end