Class: Brawlstars::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/brawlstars.rb

Instance Method Summary collapse

Constructor Details

#initialize(token: false) ⇒ Client


43
44
45
46
# File 'lib/brawlstars.rb', line 43

def initialize(token: false)
  raise "No authorization token was given!" if !token
  @token = token
end

Instance Method Details

#aboutHash

Get info about the API


52
53
54
# File 'lib/brawlstars.rb', line 52

def about
  get("/about")
end

#clubSearch(name) ⇒ Hash

Search for clubs by their name


100
101
102
# File 'lib/brawlstars.rb', line 100

def clubSearch(name)
  get("/club/search?name=#{name.gsub(' ', '%20')}")
end

#getBattleLog(tag) ⇒ Hash

Get a player's battle log by their tag


80
81
82
83
# File 'lib/brawlstars.rb', line 80

def getBattleLog(tag)
  tag = validateTag(tag)
  get("/player/battlelog?tag=#{tag}")
end

#getClub(tag) ⇒ Hash

Get a club by its tag


90
91
92
93
# File 'lib/brawlstars.rb', line 90

def getClub(tag)
  tag = validateTag(tag)
  get("/club?tag=#{tag}")
end

#getCurrentEventsHash

Get current events


116
117
118
# File 'lib/brawlstars.rb', line 116

def getCurrentEvents
  get("/events?type=current")
end

#getMiscHash

Get miscellaneous data, like shop/season reset


124
125
126
# File 'lib/brawlstars.rb', line 124

def getMisc
  get("/misc")
end

#getPlayer(tag) ⇒ Brawlstars::Player

Get a player by their tag


61
62
63
64
# File 'lib/brawlstars.rb', line 61

def getPlayer(tag)
  tag = validateTag(tag)
  Player.new(self, get("/player?tag=#{tag}"))
end

#getTopClubs(count = 200, region = "global") ⇒ Hash

Get top global clubs


134
135
136
137
138
139
# File 'lib/brawlstars.rb', line 134

def getTopClubs(count=200, region="global")
  raise 'Count must be a number.' if !count.is_a? Integer
  raise 'Count must be between 1 and 200.' if !count.between?(1,200)
  validateRegion(region)
  get("/leaderboards/clubs?count=#{count}&region=#{region}")
end

#getTopPlayers(count = 200, brawler = "", region = "global") ⇒ Hash

Get top global players


148
149
150
151
152
153
# File 'lib/brawlstars.rb', line 148

def getTopPlayers(count=200, brawler="", region="global")
  raise 'Count must be a number.' if !count.is_a? Integer
  raise 'Count must be between 1 and 200.' if !count.between?(1,200)
  validateRegion(region)
  get("/leaderboards/players?count=#{count}&brawler=#{brawler}&region=#{region}")
end

#getUpcomingEventsHash

Get upcoming events


108
109
110
# File 'lib/brawlstars.rb', line 108

def getUpcomingEvents
  get("/events?type=upcoming")
end

#playerSearch(name) ⇒ Hash

Search for players by their name


71
72
73
# File 'lib/brawlstars.rb', line 71

def playerSearch(name)
  get("/player/search?name=#{name.gsub(' ', '%20')}")
end