Class: GameLockerAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/gamelocker_api.rb,
lib/gamelocker_api/match.rb,
lib/gamelocker_api/player.rb,
lib/gamelocker_api/roster.rb,
lib/gamelocker_api/version.rb,
lib/gamelocker_api/telemetry.rb,
lib/gamelocker_api/participant.rb,
lib/gamelocker_api/abstract_parser.rb

Defined Under Namespace

Classes: AbstractParser, Match, Participant, Player, Roster, Telemetry, VirtualResponse

Constant Summary collapse

VERSION =
"0.1.4"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, region = "na") ⇒ GameLockerAPI

Returns a new instance of GameLockerAPI.



13
14
15
16
17
18
# File 'lib/gamelocker_api.rb', line 13

def initialize(api_key, region = "na")
  @api_key = api_key
  @region  = region
  @base_url= "https://api.dc01.gamelockerapp.com/shards/"
  @headers = {}
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



12
13
14
# File 'lib/gamelocker_api.rb', line 12

def base_url
  @base_url
end

#headersObject (readonly)

Returns the value of attribute headers.



12
13
14
# File 'lib/gamelocker_api.rb', line 12

def headers
  @headers
end

#regionObject (readonly)

Returns the value of attribute region.



12
13
14
# File 'lib/gamelocker_api.rb', line 12

def region
  @region
end

Instance Method Details

#match(match_uuid = nil) ⇒ Object



32
33
34
# File 'lib/gamelocker_api.rb', line 32

def match(match_uuid = nil)
  match_uuid ? request("matches/#{match_uuid}") : request("matches")
end

#matches(match_params = {}) ⇒ Object



36
37
38
# File 'lib/gamelocker_api.rb', line 36

def matches(match_params = {})
  request("matches", match_params)
end

#player(uuid) ⇒ Object

Probably does not work



21
22
23
# File 'lib/gamelocker_api.rb', line 21

def player(uuid)
  request("players/#{uuid}", {})
end

#players(players_list = []) ⇒ Object



25
26
27
28
29
30
# File 'lib/gamelocker_api.rb', line 25

def players(players_list = [])
  raise "Max of only 6 players" if players_list.count > 6
  string = players_list.join(", ")
  hash   = {"filter[playerNames]": string}
  request("players", hash)
end

#telemetry(telemetry_url) ⇒ Object



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

def telemetry(telemetry_url)
  Telemetry.new(telemetry_url)
end