Class: BlizzardApi::Wow::GenericDataEndpoint

Inherits:
Request show all
Defined in:
lib/blizzard_api/wow/game_data/generic_data_endpoint.rb

Overview

Generic endpoint to support most data requests with minor configurations

Constant Summary

Constants inherited from Request

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

Constants included from ApiStandards

ApiStandards::BASE_URLS

Class Attribute Summary collapse

Attributes inherited from Request

#mode, #region

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#initialize

Methods inherited from Request

#initialize

Constructor Details

This class inherits a constructor from BlizzardApi::Wow::Request

Class Attribute Details

.endpointObject

Returns the value of attribute endpoint.



9
10
11
# File 'lib/blizzard_api/wow/game_data/generic_data_endpoint.rb', line 9

def endpoint
  @endpoint
end

.namespaceObject

Returns the value of attribute namespace.



9
10
11
# File 'lib/blizzard_api/wow/game_data/generic_data_endpoint.rb', line 9

def namespace
  @namespace
end

.ttlObject

Returns the value of attribute ttl.



9
10
11
# File 'lib/blizzard_api/wow/game_data/generic_data_endpoint.rb', line 9

def ttl
  @ttl
end

Class Method Details

.setup(endpoint, namespace, ttl) ⇒ Object



11
12
13
14
15
# File 'lib/blizzard_api/wow/game_data/generic_data_endpoint.rb', line 11

def setup(endpoint, namespace, ttl)
  self.endpoint = endpoint
  self.namespace = namespace
  self.ttl = ttl
end

Instance Method Details

#get(id, **options) ⇒ Hash

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

in the configuration module

Parameters:

  • id (Integer)

    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/wow/game_data/generic_data_endpoint.rb', line 34

def get(id, **options)
  api_request "#{endpoint_uri}/#{id}", **default_options.merge(options)
end

#index(**options) ⇒ Hash

Fetch a list of all resources available for this endpoint

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/wow/game_data/generic_data_endpoint.rb', line 23

def index(**options)
  api_request "#{endpoint_uri}/index", **default_options.merge(options)
end