Class: BlizzardApi::Request

Inherits:
Object
  • Object
show all
Includes:
ApiStandards
Defined in:
lib/blizzard_api_rb/request.rb

Overview

Simplifies the requests to Blizzard APIS

Constant Summary collapse

CACHE_HOUR =

One hour cache

3600
CACHE_DAY =

One day cache

24 * CACHE_HOUR
CACHE_TRIMESTER =

Three (commercial) months cache

CACHE_DAY * 90

Constants included from ApiStandards

ApiStandards::BASE_URLS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Request

Returns a new instance of Request.

Parameters:

  • options (Hash)

Options Hash (**options):

  • :region (String)

    API Region

  • :mode (Symbol)

    API Mode



49
50
51
52
53
54
55
56
# File 'lib/blizzard_api_rb/request.rb', line 49

def initialize(**options)
  self.region = options[:region] || BlizzardApi.region
  # Use the shared access_token, or create one if it doesn't exists. This avoids unnecessary calls to create tokens.
  create_access_token if BlizzardApi.access_token_expired?

  # Mode
  @mode = options[:mode] || BlizzardApi.mode
end

Instance Attribute Details

#mode:regular, :extended

Returns:

  • (:regular, :extended)


45
46
47
# File 'lib/blizzard_api_rb/request.rb', line 45

def mode
  @mode
end

#regionString

Returns Api region.

Returns:

  • (String)

    Api region



40
41
42
# File 'lib/blizzard_api_rb/request.rb', line 40

def region
  @region
end