Class: Brawlstars::Client
- Inherits:
-
Object
- Object
- Brawlstars::Client
- Defined in:
- lib/brawlstars.rb
Instance Method Summary collapse
-
#about ⇒ Hash
Get info about the API.
-
#clubSearch(name) ⇒ Hash
Search for clubs by their name.
-
#getBattleLog(tag) ⇒ Hash
Get a player’s battle log by their tag.
-
#getClub(tag) ⇒ Hash
Get a club by its tag.
-
#getCurrentEvents ⇒ Hash
Get current events.
-
#getMisc ⇒ Hash
Get miscellaneous data, like shop/season reset.
-
#getPlayer(tag) ⇒ Brawlstars::Player
Get a player by their tag.
-
#getTopClubs(count = 200, region = "global") ⇒ Hash
Get top global clubs.
-
#getTopPlayers(count = 200, brawler = "", region = "global") ⇒ Hash
Get top global players.
-
#getUpcomingEvents ⇒ Hash
Get upcoming events.
-
#initialize(token: false) ⇒ Client
constructor
A new instance of Client.
-
#playerSearch(name) ⇒ Hash
Search for players by their name.
Constructor Details
#initialize(token: false) ⇒ Client
Returns a new instance of 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
#about ⇒ Hash
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 |
#getCurrentEvents ⇒ Hash
Get current events
116 117 118 |
# File 'lib/brawlstars.rb', line 116 def getCurrentEvents get("/events?type=current") end |
#getMisc ⇒ Hash
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}®ion=#{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}®ion=#{region}") end |
#getUpcomingEvents ⇒ Hash
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 |