-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Interacting with the development server is accomplished by sending GET/POST requests. Below is a list of REST endpoints and the arguments needed to correctly interact with the server.
Note: all requests must have Authorization & CustomKey & Username in the header or else the request will fail.
- statuscode: 409 (headers.response: "Malformed request") //invalid arguments
- statuscode: 401 (headers.response: "Unauthorized") //invalid credential
Description: register a user.
Arguments:
- username: username
- device: "android" or "wp" or "ios"
- pushID: Token after registering with APNs / GCM / MPNs
Returns:
- statuscode: 500 (headers.response: "Operation failed")
- statuscode: 409 (headers.response: "Already Registered")
- statuscode: 200 (headers.response: "Ok")
Example:
curl -v -H "Content-Type: application/json" -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" --data "{"username":"Chris", "device":"android", "pushID":"APA91bFM25VA9Y0di6-TzCL3F4icI"}" 104.197.166.11:8080/register
Description: get profile image of a user.
Returns:
- statuscode: 404 (headers.response: "Not Found")
- statuscode: 200 (headers.response: "Ok")
Example:
curl -v -H "Content-Type: application/json" -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" 104.197.166.11:8080/photo/Chris.png
Description: get information on a registered user.
Returns:
- statuscode: 500 (headers.response: "Operation failed")
- statuscode: 400 (headers.response: "User doesn't exist")
- statuscode: 200 (headers.response: "Ok", body:{bio:String, lastPhotoModifiedTime:long, reputation:long})
Example:
curl -v -H "Content-Type: application/json" -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" 104.197.166.11:8080/getuserinfo?username=Chris
Description: create a new goal.
Arguments:
- username: username
- start: epoch time when goal starts
- end: epoch time when goal ends
- wager: how many reputation points are on the line
- referee: username of referee
- title: title of goal
- isGoalPublic: show goal status in feeds or not ("1" = yes, "0" = no)
- encouragement: self encouragement (optional)
Returns:
- statuscode: 500 (headers.response: "Operation failed")
- statuscode: 400 (headers.response: "Referee doesn't exist")
- statuscode: 200 (headers.response: "Ok", body:guid)
Example:
curl -v -H "Content-Type: application/json" -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" --data "{"username":"Chris", "start":1234567890123, "end":1234567890123, "wager":123, "referee":"Chris", "title":"lose weight", "isGoalPublic": "1", "encouragement":"do it"}" 104.197.166.11:8080/newgoal
Description: send a push notification to remind a referee to grade your goal, or remind a friend to do their goal.
Arguments:
- fromUsername: username
- toUsername: username
- guid: goal guid
- isRemindingRef: determine if you are reminding the referee to grade your goal (0 = no, 1 = yes)
Returns:
- statuscode: 500 (headers.response: "Operation failed")
- statuscode: 400 (headers.response: "User doesn't exist")
- statuscode: 200 (headers.response: "Ok")
Example:
curl -v -H "Content-Type: application/json" -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" --data "{"fromUsername":"Chris", "toUsername":"Chris", "guid":"Chris:1234567890123", "isRemindingRef":1 }" 104.197.166.11:8080/remind
Description: sync with server to get any data that was updated.
Arguments:
- username: username
- lastSyncedTime: epoch since you last sucessfully synced with server
Returns:
- statuscode: 500 (headers.response: "Operation failed")
- statuscode: 200 (headers.response: "Ok", body:{"feed":[{"guid":"Chris:1505025537979","createdUsername":"Chris","wager":123,"goalCompleteResult":1,"upvoteCount":1}],"referee":[{"guid":"lglg:1504984006866","createdUsername":"lglg","title":"Stuff","startDate":1504983957000,"endDate":1506063960000,"wager":10,"encouragement":"","goalCompleteResult":2,"activityDate":1504984029000}],"my":[{"guid":"nex6:1505026349830","goalCompleteResult":1}],"info":{"reputation":150},"time":1505026163861})
Example:
curl -v -H "Content-Type: application/json" -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" --data "{"username":"Chris", "lastSyncedTime":1234567890123 }" 104.197.166.11:8080/sync
Description: update the status of a goal to accept, failed, sucessful.
Arguments:
- username: username
- guid: goal guid
- goalCompleteResult: 0-5 (0=None, 1=Pending, 2=Ongoing, 3=Success, 4=Failed, 5=Cancelled)
Returns:
- statuscode: 500 (headers.response: "Operation failed")
- statuscode: 400 (headers.response: "Goal doesn't exist")
- statuscode: 200 (headers.response: "Ok")
Example:
curl -v -H "Content-Type: application/json" -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" --data "{"username":"Chris", "guid":"Chris:1234567890123", "goalCompleteResult":1 }" 104.197.166.11:8080/updategoal
Description: update user information
Arguments:
- username: username
- bio: short biography of user
- pushID: push notification token
Returns:
- statuscode: 500 (headers.response: "Operation failed")
- statuscode: 400 (headers.response: "User doesn't exist")
- statuscode: 200 (headers.response: "Ok")
Example:
curl -v -H "Content-Type: application/json" -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" --data "{"username":"Chris", "bio":"this is Chris", "pushID":"dsafegxcx3422" }" 104.197.166.11:8080/updateuserinfo
Description: upload a photo to server
Arguments:
- name: name/path of the image
- image: .png is the prefer format for now
Returns:
- statuscode: 500 (headers.response: "Operation failed")
- statuscode: 200 (headers.response: "Ok")
Example:
curl -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" -F [email protected] 104.197.166.11:8080/upload
Description: congratulate or send good luck on a user's goal
Arguments:
- username: username
- guid: goal guid
Returns:
- statuscode: 500 (headers.response: "Operation failed")
- statuscode: 400 (headers.response: "Goal doesn't exist")
- statuscode: 200 (headers.response: "Ok")
Example:
curl -v -H "Content-Type: application/json" -H "Username: Chris" -H "Authorization: xxx" -H "CustomKey: CUSTOM_KEY" --data "{"username":"Chris", "guid":"Chris:1234567890123"}" 104.197.166.11:8080/upvote