This is the server app for the android app of Android Team 3 PSE Kit.
Collaborators :
- Irvan Sian Syah Putra
- Chen Zhang
This server app doesn't handle authentication (registration and login), authentication is done in the Sieger mobile app to firebase.
BUT this app always ask for a JWT in the HTTP Request that's generated by firebase.
And you always have to put "Authorization" in your header and put "Bearer ".
Example Authorization : Bearer aslidhmfi23hiuodnf.123jsaidokdas9.sdni3je8dhs
LOCALLY
If you want run this app locally, you must have a Firebase project. Then you have to get the service account key, and put it inside this project.
This project runs on port 8080. To register a user, you have to manually do it in Firebase Auth console or implement it in your mobile app.
To get JWT id token :
Send an HTTP Post request to https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=[Your Api Key]
with the following body, and get the idToken, it expires after one hour.
{
"email" : "[email protected]",
"password" : "yourpassword",
"returnSecureToken" : true
}
DISCLAIMER : Having an account registered in Firebase Auth doesn't mean that there is User data in database, you still have to create a new user.
REMOTE
If you want to use the endpoint from our API, you can hit our url at https://sieger-teamthree.herokuapp.com/
, but before you use the endpoints, you
have to register from our mobile app. In case you are not registered yet, and want to use our API, you can use these two dummy user accounts that have been created
in our Firebase Auth console.
Email : [email protected]
Password : password
and
Email : [email protected]
Password : password
DISCLAIMER : These two accounts only exist in Firebase Auth, there are no User data of these two users in database, you still have to create a new user
To get the token :
Send an HTTP Post request to https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=AIzaSyDIIa-WlH1k9UMsheSc-kU7BSkpEbMRVXM
with the following body, and get the idToken, it expires after one hour.
{
"email" : "[email protected]",
"password" : "password",
"returnSecureToken" : true
}
Users
Method | URL | Description | Request Body |
---|---|---|---|
GET | /users/{username} | Get a user by username | |
GET | /users?id={user_id} | Get a user by its id | |
GET | /users/{username}/tournaments | Get a user's tournaments | |
GET | /users/{username}/teams | Get a user's teams | |
GET | /users/{username}/invitations | Get a user's invitations | |
POST | /users | Create a new user | JSON |
PUT | /users/{username} | Update user detail | JSON |
Tournaments
Method | URL | Description | Request Body |
---|---|---|---|
GET | /tournaments/{tournamentName} | Get a tournament by its name | |
GET | /tournaments?id={tournament_id} | Get a tournament by its id | |
GET | /tournaments/{tournamentName}/participants | Get list of participants of a tournament | |
GET | /tournaments/{tournamentName}/games | Get list of games of a tournament | |
GET | /tournaments/{tournamentName}/games/{id} | Get a game of a tournament by its id | |
POST | /tournaments | Create a new tournament | JSON |
POST | /tournaments/{tournamentName} | Join or quit a tournament | JSON join, JSON quit |
POST | /tournaments/{tournamentName}/games | Ask server to create games automatically | |
PUT | /tournaments/{tournamentName} | Update result of a game | JSON |
DELETE | /tournaments/{tournamentName} | Delete a tournament | |
DELETE | /tournaments/{tournamentName}/games/{id} | Delete a game |
Teams
Method | URL | Description | Request Body |
---|---|---|---|
GET | /teams/{teamName} | Get team by name | |
GET | /teams?id={team_id} | Get team by id | |
GET | /teams/{teamName}/members | Get team members | |
GET | /teams/{teamName}/tournaments | Get team tournaments | |
GET | /teams/{teamName}/invitations | Get team invitations | |
POST | /teams | Create new team | JSON |
POST | /teams/{teamName} | Join or quit the team | JSON join, JSON quit |
DELETE | /teams/{teamName} | Delete a team |
Invitations
Method | URL | Description | Request Body |
---|---|---|---|
POST | /invitations | Create a new invitation | JSON |
POST | /invitations/{id} | Accept or decline invitation | JSON accept, JSON decline |
{
"username" : "myusername",
"surname" : "mysurname",
"forename" : "myforename",
"userId" : "asdinj8dawujd9ijdhh" //this should be generated automatically by firebase auth
}
{
"username" : "newusername",
"surname" : "newsurname",
"forename" : "newforename"
}
{
"type":"League",//can be KnockOut or KnockOutWithGroup
"participantSize":4,
"name":"name",
"tournamentDetail":{
"organisatorId":"PsWZZmzvggdETlTbxJdNUTnpG3t1",
"tournamentTypes":"OPEN", //or"PRIVATE"
"typeOfGame":"typeOfGame",
"location":"location",
"registrationDeadline":"2020-09-15",
"startTime":"2021-09-15",
"endTime":"2021-09-15",
"form":"SINGLE" //or"TEAM"
}
}
{
"participation" : true
}
{
"participation" : false
}
{
"type":"Winlose", //if is winlose result
"firstParticipantResult":"WIN",
"secondParticipantResult":"LOSE"
}
{
"adminId" : "oijmd2in813",
"name" : "myteamname",
"password" : "myteampassword"
}
{
"activity" : "join"
"password": "password"
}
{
"activity" : "quit"
}
{
"senderId":"senderId",
"recipientId" : "recipientId",
"tournamentId" :"tournamentId",
"participantForm":"SINGLE" //Or "TEAM"
}
{
"accept" : true
}
{
"accept" : false
}