Class: Warframe::Client

Inherits:
Cache
  • Object
show all
Includes:
API
Defined in:
lib/warframe/client.rb

Overview

The main application Client for access live feed data.

Example Usage

client = Warframe::Client.new
client.nightwave.tag # => 'Radio Legion Intermission'

Accepted Platforms

default = 'pc'
all_platorms = [ 'pc', 'ps4', 'xb1', 'swi' ]

client = Waframe::Client.new(platform: 'ps4')
client.platform # => 'ps4'
client.language # => 'en'

Accepted Languages

default = 'en'
all_languages = [ 'de', 'es', 'en', 'fr', 'it', 'ko', 'pl', 'pt', 'ru', 'zh' ]

client = Warframe::Client.new(language: 'fr')
client.language # => 'fr'
client.platform # => 'pc'

Setting both Platform and Language

client = Warframe::Client.new(platform: 'ps4', language: 'de')
client.platform # => 'ps4'
client.language # => 'de'

Constant Summary collapse

BASE_URL =

The base Warframe Stat API link

'https://api.warframestat.us/'
DEFAULT_OPTIONS =

Default attributes

{ platform: 'pc', language: 'en' }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from API::VallisCycle

#vallis_cycle

Methods included from API::SyndicateMissions

#syndicate_missions

Methods included from API::SteelPath

#steel_path

Methods included from API::Sortie

#sortie

Methods included from API::Nightwave

#nightwave

Methods included from API::News

#news

Methods included from API::Invasions

#invasions

Methods included from API::GlobalUpgrades

#global_upgrades

Methods included from API::ConclaveChallenges

#conclave_challenges

Methods included from API::Cetus

#cetus

Methods included from API::CambionDrift

#cambion_drift

Methods included from API::Alerts

#alerts

Constructor Details

#initialize(platform: 'pc', language: 'en') ⇒ Warframe::Client

Initialize the client.

Parameters:

  • platform: (String) (defaults to: 'pc')

    ‘pc’, ‘ps4’, ‘xb1’, or ‘swi’

  • language: (String) (defaults to: 'en')

    ‘de’, ‘es’, ‘en’, ‘fr’, ‘it’, ‘ko’, ‘pl’, ‘pt’, ‘ru’, or ‘zh’



54
55
56
57
58
# File 'lib/warframe/client.rb', line 54

def initialize(platform: 'pc', language: 'en')
  super({})
  @platform = platform
  @language = language
end

Instance Attribute Details

#languageObject

The Client Cache



46
47
48
# File 'lib/warframe/client.rb', line 46

def language
  @language
end

#platformObject

The Client Cache



46
47
48
# File 'lib/warframe/client.rb', line 46

def platform
  @platform
end

Instance Method Details

#base_urlString

Returns the base url and platform combined.

Returns:

  • (String)

    the base url and platform combined.



61
62
63
# File 'lib/warframe/client.rb', line 61

def base_url
  "#{BASE_URL}#{platform}"
end

#get(path, klass) ⇒ Object

Performs a get operation on the requested path, and returns a mapped response of the requested model.

Parameters:



68
69
70
71
72
73
# File 'lib/warframe/client.rb', line 68

def get(path, klass)
  return get_from_cache(path) if find_in_cache(path)

  result = get_request(path, klass)
  add_to_cache(path, result)
end