Method: Clashinator::Location.location_player_rankings

Defined in:
lib/clashinator/location.rb

.location_player_rankings(http, location_id, options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/clashinator/location.rb', line 42

def self.location_player_rankings(http, location_id, options = {})
  response = http.get(
    "/v1/locations/#{location_id}/rankings/players",
    prepare_options(options)
  )
  parsed = JSON.parse(response.body)

  return Clashinator::ArrayResource.new(
    Clashinator::PlayerRanking, parsed['items'], parsed['paging']
  ) if response.success?
  raise parsed['reason'] unless response.success?
end