Skip to content

Commit

Permalink
DOCS
Browse files Browse the repository at this point in the history
  • Loading branch information
umbresp committed Feb 16, 2018
1 parent de2761b commit 7d7d875
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 31 deletions.
51 changes: 20 additions & 31 deletions brawlstars/errors.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,37 @@
class Error(Exception):
'''Base Error.'''

def __init__(self):
self.error = 'Fatal error occured.'
super().__init__(self, self.error)
'''Base Error.'''
pass

class ArgError(Error):
'''Argument Error.'''

def __init__(self):
self.error = 'Incorrect argument passed.'
super().__init__(self, self.error)
'''Argument Error.'''
pass

class MissingArg(ArgError):
'''Argument is missing.'''
'''Argument is missing.'''

def __init__(self, arg):
self.error = f'{arg} is a required argument that is missing.'
super().__init__(self, self.error)
def __init__(self, error):
self.error = f'{error} is a required argument that is missing.'

class InvalidArg(ArgError):
'''Argument is invalid.'''
'''Argument is invalid.'''

def __init__(self, arg):
self.error = f'{arg} is invalid.'
super().__init__(self, self.error)
def __init__(self, error):
self.error = f'{arg} is invalid.'

class HTTPError(Error):
'''Error occured in HTTP.'''
'''Error occured in HTTP.'''

def __init__(self, code):
self.error = f'An error occured. Status: {code}'
super().__init__(self, self.error)
def __init__(self, code):
self.error = f'An error occured. Status: {code}'

class Timeout(HTTPError):
'''Connection timed out.'''
class Timeout(Error):
'''Connection timed out.'''

def __init__(self):
self.error = 'The connection timed out.'
super().__init__(self, self.error)
def __init__(self):
self.error = 'The connection timed out.'

class MissingData(Error):
'''Missing data.'''
'''Missing data.'''

def __init__(self, data):
self.error = f'Value of {data} is missing.'
super().__init__(self, self.error)
def __init__(self, data):
self.error = f'Value of {data} is missing.'
Binary file added dist/brawlstars-0.2.4.tar.gz
Binary file not shown.
26 changes: 26 additions & 0 deletions docs/asyncclient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# AsyncClient

## Creating a AsyncClient:
`client = brawlstars.AsyncClient(*args, **kwargs)`
| Argument | Description | Type |
|----------|-------------|------|
| token | The authorization header to be passed to access the API. | string |
| timeout* | How long to wait for response. | integer |

\*optional

## Client Attributes
| Variable | Description | Type |
|----------|-------------|------|
| baseUrl* | Base URL to make requests to. | string |
| headers | Dictionary for headers to pass when making the request. Includes the token. | Dict |
| session* | The aiohttp session. | aiohttp.ClientSession |
| timeout | How long to wait for response. | integer |

\*immutable

## Client Methods
| Method | Description | Returns |
|--------|-------------|---------|
| await get_band(tag) | Get information about a band with specified tag. | Band |
| await get_player(tag) | Get information about a player with specified tag. | Player |
30 changes: 30 additions & 0 deletions docs/band.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Band extends Box

(All methods and attributes of Box automatically belong to Band.)

## Creating a Band
The only way to create a player is to use get it from brawlstars.Client or brawlstars.AsyncClient. Example:
```py
import brawlstars
client = brawlstars.AsyncClient('token here', '5')
band = await client.get_band('P9829')
```

## Band Attributes
| Variable | Description | Type |
|----------|-------------|------|
| bandDescription | The description in the Band's information box. | string |
| bandMembersCount | How many members are in the band. | integer |
| bandRequiredTrophies | How many trophies you need to join the band. | integer |
| bandTrophies | How many trophies the band has. | integer |
| name | The name of the band. | string |
| status | Whether the band is Invite Only, Open, or Closed. | string |
| tag | The band's unique tag. | string |

## Band Methods
| Method | Description | Returns |
|--------|-------------|---------|
| get_players() | Returns a list of members in the band. | List of Member |
| get_id() | Returns the band's ID. | Id |

\*These methods can be awaited depending on if you created a Band through the sync or async client.
29 changes: 29 additions & 0 deletions docs/brawler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Brawler extends Box

(All methods and attributes of Box automatically belong to Member.)

## Creating a Brawler
The only way to create a brawler is to use get it from brawlstars.Player. Example:
```py
import brawlstars
client = brawlstars.AsyncClient('token here', '5')
player = await client.get_player('Q8P2ULP')
brawlers = await player.get_brawlers()
brawler = brawlers[0]
```

## Brawler Attributes
| Variable | Description | Type |
|----------|-------------|------|
| highestTrophies | The highest trophies the brawler has ever been at. | integer |
| name | The name of the brawler. | string |
| trophies | The current trophies of the brawler. | integer |
| type | The type of the brawler (unknown what this does yet, and will always be 16) | integer |
| unk1 | Unknown value | integer |
| upgradesPower | How many upgrades the brawler has. Between 0 and 50. | integer |

## Brawler Methods
| Method | Description | Returns |
|--------|-------------|---------|

\*These methods can be awaited depending on if you created a Brawler through the sync or async client
25 changes: 25 additions & 0 deletions docs/client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Client

## Creating a Client:
`client = brawlstars.Client(*args, **kwargs)`
| Argument | Description | Type |
|----------|-------------|------|
| token | The authorization header to be passed to access the API. | string |
| timeout* | How long to wait for response. | integer |

\*optional

## Client Attributes
| Variable | Description | Type |
|----------|-------------|------|
| baseUrl* | Base URL to make requests to. | string |
| headers | Dictionary for headers to pass when making the request. Includes the token. | Dict |
| timeout | How long to wait for response. | integer |

\*immutable

## Client Methods
| Method | Description | Returns |
|--------|-------------|---------|
| get_band(tag) | Get information about a band with specified tag. | Band |
| get_player(tag) | Get information about a player with specified tag. | Player |
3 changes: 3 additions & 0 deletions docs/errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Errors

__**UNDER CONSTRUCTION**__
24 changes: 24 additions & 0 deletions docs/id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Id extends Box

(All methods and attributes of Box automatically belong to Member.)

## Creating a Id
The only way to create a member is to use get it from brawlstars.Player, brawlstars.Member, brawlstars.Band. or brawlstars.MinimalBand. Example:
```py
import brawlstars
client = brawlstars.AsyncClient('token here', '5')
player = await client.get_player('Q8P2ULP')
id = await player.get_id()
```

## Id Attributes
| Variable | Description | Type |
|----------|-------------|------|
| high | The first part of the ID. | integer |
| low | The second part of the ID. | integer |

## Id Methods
| Method | Description | Returns |
|--------|-------------|---------|

\*These methods can be awaited depending on if you created a Id through the sync or async client
29 changes: 29 additions & 0 deletions docs/member.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Member extends Box

(All methods and attributes of Box automatically belong to Member.)

## Creating a Member
The only way to create a member is to use get it from brawlstars.Band. Example:
```py
import brawlstars
client = brawlstars.AsyncClient('token here', '5')
band = await client.get_band('P9829')
members = await band.get_members()
member = members[0]
```

## Member Attributes
| Variable | Description | Type |
|----------|-------------|------|
| avatar | The member's avatar ID. | integer |
| expLevel | The member's experience level. | integer |
| name | The member's in-game name. | string |
| role | The member's role in the band. | string |
| trophies | How many trophies the member currently has. | integer |

## Member Methods
| Method | Description | Returns |
|--------|-------------|---------|
| get_id() | Returns the member's ID. | Id |

\*These methods can be awaited depending on if you created a Member through the sync or async client
23 changes: 23 additions & 0 deletions docs/minimalband.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# MinimalBand extends Box

(All methods and attributes of Box automatically belong to MinimalBand.)

## Creating a MinimalBand
The only way to create a minimal band is to use get it from brawlstars.Player. Example:
```py
import brawlstars
client = brawlstars.AsyncClient('token here', '5')
player = await client.get_player('Q8P2ULP')
band = await player.get_band()
```

## MinimalBand Attributes
| Variable | Description | Type |
|----------|-------------|------|

## MinimalBand Methods
| Method | Description | Returns |
|--------|-------------|---------|
| get_id() | Returns the band's ID. | Id |

\*These methods can be awaited depending on if you created a MinimalBand through the sync or async client.
31 changes: 31 additions & 0 deletions docs/player.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Player extends Box

(All methods and attributes of Box automatically belong to Player.)

## Creating a Player
The only way to create a player is to use get it from brawlstars.Client or brawlstars.AsyncClient. Example:
```py
import brawlstars
client = brawlstars.AsyncClient('token here', '5')
player = await client.get_player('Q8P2ULP')
```

## Player Attributes
| Variable | Description | Type |
|----------|-------------|------|
| brawlersUnlocked | How many brawlers the player has unlocked. | integer |
| highestTrophies | How many trophies the player has ever reached. | integer |
| name | The player's in-game name. | string |
| showdownVictories | How many wins the player has in Showdown. | integer |
| tag | The player's unique tag. | string |
| trophies | How many trophies the player currently has. | integer |
| victories | How many wins the player has in modes other than Showdown. | integer |

## Player Methods
| Method | Description | Returns |
|--------|-------------|---------|
| get_band() | Returns information about the player's band. | MinimalBand |
| get_brawlers() | Returns information about the player's brawlers. | List of Brawler |
| get_id() | Returns the player's ID. | Id |

\*These methods can be awaited depending on if you created a Player through the sync or async client.

0 comments on commit 7d7d875

Please sign in to comment.