Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alexqfredrickson committed May 8, 2024
1 parent 5616cfd commit 7b5309f
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,43 @@ To install `chyllonge`, execute `pip install chyllonge`.

## Usage

Detailed API documentation is available at https://api.challonge.com/v1.

```python
from chyllonge.api import TournamentAPI
from chyllonge.api import TournamentAPI, ParticipantAPI, MatchAPI, AttachmentAPI
from datetime import datetime, timedelta

# create a tournament
# instantiate base api classes
tournaments_api = TournamentAPI()
participants_api = ParticipantAPI()
match_api = MatchAPI()
attachment_api = AttachmentAPI()

from datetime import datetime, timedelta

tournament = tournaments_api.create(
name="chyllonge-temp",
start_at=(datetime.now() + timedelta(hours=1)).isoformat() + tournaments_api.tz_utc_offset_string,
check_in_duration=60
)
# create a basic tournament
tournament = tournaments_api.create(name="My Chyllonge Tournament")
print(tournament["tournament"]["id"])

# create a tournament that starts in an hour
an_hour_from_now = (datetime.now() + timedelta(hours=1)).isoformat() + tournaments_api.tz_utc_offset_string
tournament = tournaments_api.create(name="My Chyllonge Tournament", start_at=an_hour_from_now, check_in_duration=60)
print(tournament["tournament"]["id"])

# create a tournament, add Alice and Bob, process their check-ins, start the tournment, set their match underway,
# score their match (congratulations Alice!), finalize the tournament
an_hour_from_now = (datetime.now() + timedelta(hours=1)).isoformat() + tournaments_api.tz_utc_offset_string
tournament = tournaments_api.create(name="Alice and Bob Play Bingo", start_at=an_hour_from_now, check_in_duration=60)
tournament_id = tournament["tournament"]["id"]

participants_api.add(tournament_id, name="Alice")
participants_api.add(tournament_id, name="Bob")
tournaments_api.process_checkins(tournament_id)
tournaments_api.start(tournament_id)
match_id = match_api.get_all(tournament_id=tournament_id)[0]["match"]["id"]
alice_id = participants_api.get_all(tournament_id)[0]["participant"]["id"]
match_api.set_underway(tournament_id, match_id)
match_api.update(tournament_id, match_id, match_scores_csv="3-1,2-2", match_winner_id=alice_id)
tournaments_api.finalize(tournament_id)
finished_tournment = tournaments_api.get(tournament_id)
```

## History
Expand All @@ -56,7 +78,8 @@ Please feel free to contribute, and to suggest updates to these contribution gui
The current guidelines are:

* Functions should be documented in-line using `reStructuredText` format.
* Support for older Python versions should be dropped as those minor updates approach end-of-life.
* Support for older Python versions should be dropped as those minor updates approach end-of-life.
* There are no plans to support XML for the time being (although this is a nice-to-have).

## Building

Expand Down

0 comments on commit 7b5309f

Please sign in to comment.