Class: BlizzardApi::Hearthstone::GenericDataEndpoint

Inherits:
Request
  • Object
show all
Defined in:
lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb

Overview

Generic endpoint to support most data requests with minor configurations

Direct Known Subclasses

Back, Card, Deck, Metadata

Constant Summary

Constants inherited from Request

Request::CACHE_DAY, Request::CACHE_HOUR, Request::CACHE_TRIMESTER

Constants included from ApiStandards

ApiStandards::BASE_URLS

Instance Attribute Summary

Attributes inherited from Request

#mode, #region

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ GenericDataEndpoint

Returns a new instance of GenericDataEndpoint.



7
8
9
10
11
# File 'lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb', line 7

def initialize(**options)
  super(**options)
  endpoint_setup
  @ttl ||= CACHE_DAY
end

Instance Method Details

#get(id, **options) ⇒ Hash

Fetch all possible data for one of items listed by the #index using its id

in the configuration module

Parameters:

  • id (Integer|String)

    One of the IDs returned by the #index

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :completed (Boolean)

    Should return completed quests

Returns:

  • (Hash)

    API Response. The actual type of the returned object depends on the format option



34
35
36
# File 'lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb', line 34

def get(id, **options)
  api_request "#{base_url(:community)}/#{@endpoint}/#{id}", **default_options.merge(options)
end

#search(**options) ⇒ Hash

Get information about the resource

in the configuration module

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :completed (Boolean)

    Should return completed quests

Returns:

  • (Hash)

    API Response. The actual type of the returned object depends on the format option



23
24
25
# File 'lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb', line 23

def search(**options)
  api_request "#{base_url(:community)}/#{@endpoint}/", **default_options.merge(options)
end