Ajax URIs - robinsr/FantasySlackr GitHub Wiki
Request Methods
login
Status: implemented - stable
Description
Returns session variable used to make valid requests
Example URI:
demos.ethernetbucket.com/FantasySlackr/method/login
Request Body JSON Object
{
uname:<username from form>,
upass:<password from form>
}
In the future we will have to encrypt these for use over HTTP
Responses
HTTP 200
{
"session":"00c66aaf5f2c3f49946f15c1ad2ea0d3"
}
HTTP 400
{
"error":"Invalid username or password"
"error":"no user account found"
"RequestParameterMissing":<missing parameter>
}
HTTP 500
{
"error":"could not create session"
}
createNewUser
Status: implemented - stable
Description
Creating a new user follows this process:
- Client sends username, password, and email to server as defined by the request section below
- Server responds with an Authorization URL
- Client creates a popup using the Authorization URL
- The user authorizes and the popup is automatically redirected to a page that closes the popup
- Client issues method/login with username and password as defined by the request section above
- Server responds
{error : "Unauthorized User"}
until the time that the server has successfully obtained an access token - Server then responds with a session as normal
- Client makes requests using the session token
Example URI:
demos.ethernetbucket.com/FantasySlackr/method/createNewUser
Request Body JSON Object
{
uname:<username from form>,
upass:<password from form>,
uemail:<email from form>
}
In the future we will have to encrypt these for use over HTTP
Responses
HTTP 200
{
"uname":<username provided>,
"oauthURL":"https://api.login.yahoo.com/oauth/v2/request_auth?oauth_token=z4ezdgj",
}
HTTP 400
{
"RequestParameterMissing":<missing parameter>
}
authorize
Status: Not yet implemented
Description
Its possible that a user created an account but didn't complete authorization with Yahoo. In this case, attempting to login will respond 400 { error : Unauthenticate User}
. You should then user authorize to get just the oauthURL that you would get by using createNewUser. Use a popup to show the authentication page and attempt to login after the window is closed (that is, after the user authorized and after sufficient time for the server to retrieve an access token has passed).
Example URI:
demos.ethernetbucket.com/FantasySlackr/method/authorize
Responses
HTTP 200
{
"oauthURL":"https://api.login.yahoo.com/oauth/v2/request_auth?oauth_token=z4ezdgj",
}
getUserData
Status: Not yet implemented
Description
Returns JSON doc containing user's players, players status, last 10 activity events, user settings. Because the session variable should be in the Authoriztion header, the server can determine which user the request is asking for.
Example URI:
demos.ethernetbucket.com/FantasySlackr/method/getUserData
Responses
HTTP 200: <JSON, no details yet>
HTTP 400: Invalid Session
dropPlayer
Status: Not yet implemented
Description
Removes a player from a players team, creating a vacancy for that position. I believe you have to drop a player before you can add a Free Agent. Adding a player from waivers works differently.
pickupPlayer
Status: Not yet implemented
Desscrition
Adds a free agent to a player's team
modifyLineup
Status: Not yet implemented
Description
Sets user's lineup. Request should include JSON in the request body that includes each players ID, their position (QB,RB,DEF,etc.), their status ('bench','active'). The server will validate that the request does not have too many players set as 'active' for each position (1 QB, 3 WR, etc) before sending request to Yahoo.
getFreeAgents
Status: Not yet implemented
Description:
Returns JSON doc of current free agents (players that can be added by anyone in the league)
getPlayersOnWaviers
Status: Not yet implemented
Description:
Returns JSON doc of current players on waivers. See this for an explanation of how it works
submitWaiversClaim
Status: Not yet implemented
Description:
Requires player id of waiver player and player id of player user intends to drop
getWaiversClaim
Status: Not yet implemented
Description:
Returns JSON array with list of filed claims, awarded claims and unsuccessful claims, and user's position on waivers priority list.