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/participant.rb,
lib/gamelocker_api/abstract_parser.rb

Defined Under Namespace

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

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of GameLockerAPI.



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

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.



9
10
11
# File 'lib/gamelocker_api.rb', line 9

def base_url
  @base_url
end

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/gamelocker_api.rb', line 9

def headers
  @headers
end

#regionObject (readonly)

Returns the value of attribute region.



9
10
11
# File 'lib/gamelocker_api.rb', line 9

def region
  @region
end

Instance Method Details

#match(match_uuid = nil) ⇒ Object



29
30
31
# File 'lib/gamelocker_api.rb', line 29

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

#matches(match_params = {}) ⇒ Object



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

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

#player(uuid) ⇒ Object

Probably does not work



18
19
20
# File 'lib/gamelocker_api.rb', line 18

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

#players(players_list = []) ⇒ Object



22
23
24
25
26
27
# File 'lib/gamelocker_api.rb', line 22

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