Class: Brawlstars::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(token: false) ⇒ Client

Returns a new instance of Client



38
39
40
41
# File 'lib/brawlstars.rb', line 38

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

Instance Method Details

#aboutHash

Get info about the API

Returns:

  • (Hash)

    info about the API



47
48
49
# File 'lib/brawlstars.rb', line 47

def about
  get("/about")
end

#clubSearch(name) ⇒ Hash

Search for clubs by their name

Parameters:

  • name (String)

    name to search for.

Returns:

  • (Hash)

    clubs returned by the search.



85
86
87
# File 'lib/brawlstars.rb', line 85

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

#getClub(tag) ⇒ Hash

Get a club by its tag

Parameters:

  • tag (String)

    tag of the club to get.

Returns:

  • (Hash)

    data of the club that was searched.



75
76
77
78
# File 'lib/brawlstars.rb', line 75

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

#getCurrentEventsHash

Get current events

Returns:

  • (Hash)

    current events



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

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

#getMiscHash

Get miscellaneous data, like shop/season reset

Returns:

  • (Hash)

    miscellaneous data



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

def getMisc
  get("/misc")
end

#getPlayer(tag) ⇒ Hash

Get a player by their tag

Parameters:

  • tag (String)

    tag of the player to get.

Returns:

  • (Hash)

    data of the player that was searched.



56
57
58
59
# File 'lib/brawlstars.rb', line 56

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

#getTopClubs(count = 200) ⇒ Hash

Get top global clubs

Parameters:

  • count (Integer) (defaults to: 200)

    number of clubs to return.

Returns:

  • (Hash)

    clubs in order from 1st rank down.



118
119
120
121
122
# File 'lib/brawlstars.rb', line 118

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

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

Get top global players

Parameters:

  • count (Integer) (defaults to: 200)

    number of players to return.

  • brawler (String) (defaults to: "")

    brawler leaderboard to return.

Returns:

  • (Hash)

    players in order from 1st rank down.



130
131
132
133
134
# File 'lib/brawlstars.rb', line 130

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

#getUpcomingEventsHash

Get upcoming events

Returns:

  • (Hash)

    upcoming events



93
94
95
# File 'lib/brawlstars.rb', line 93

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

#playerSearch(name) ⇒ Hash

Search for players by their name

Parameters:

  • name (String)

    name to search for.

Returns:

  • (Hash)

    players returned by the search.



66
67
68
# File 'lib/brawlstars.rb', line 66

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