Method: Clashinator::League.league_seasons

Defined in:
lib/clashinator/league.rb

.league_seasons(http, league_id, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/clashinator/league.rb', line 29

def self.league_seasons(http, league_id, options = {})
  new_options = prepare_options(options)
  response = http.get("/v1/leagues/#{league_id}/seasons", new_options)
  parsed = JSON.parse(response.body)

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