Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Team] API 문서 #43

Open
102092 opened this issue May 11, 2020 · 8 comments
Open

[Team] API 문서 #43

102092 opened this issue May 11, 2020 · 8 comments
Assignees
Labels
be backend documentation Improvements or additions to documentation fe 프론트 엔드 iOS

Comments

@102092
Copy link
Contributor

102092 commented May 11, 2020

  • API 관련 문서를 공유합니다.
  • 서로 생각하는 게임 flow에 맞는 API인지 확인합니다.
  • 의견이 있으면, 슬랙, 혹은 리플로 알려주세요!
  • 기재된 URL 임시적 입니다!

1. 메인 화면

  • GET
  • /api/main
{
    "success": true,
    "response": [
        {
            "id": 1,
            "homeId": 1,
            "awayId": 2,
            "home": "Captin",
            "away": "Marvel",
            "started": false
        },
        {
            "id": 2,
            "homeId": 3,
            "awayId": 4,
            "home": "Twins",
            "away": "Tigers",
           "started": false
        },
        {
            "id": 3,
            "homeId": 5,
            "awayId": 6,
            "home": "Rockets",
            "away": "Doggers",
            "started": false
        },
        {
            "id": 4,
            "homeId": 7,
            "awayId": 8,
            "home": "Lotte",
            "away": "NC",
            "started": false
        }
    ],
    "error": null
}

2. 팀 선택 요청

  • POST
  • /api/team
  • 요청 객체
{
	"id" : 1,
	"isSelected" : true
}
  • 응답
{
    "success": true,
    "response": true,
    "error": null
}
  • 이미 선택한 팀을 요청한 경우
{
    "success": false,
    "response": null,
    "error": {
        "message": "Team Already Selected : Captin",
        "httpStatus": 400
    }
}

3. 게임 시작 요청

  • POST
  • /api/game
  • request body
{
	"id" : "1",
	"isStarted" : true
}

4. 게임 진행 화면

5. Pitch 요청

6. 상세 점수 팝업 요청

7. 상세 플레이어 현황 팝업 요청

  • 상세 플레이어 합계 추가
@102092 102092 added the documentation Improvements or additions to documentation label May 11, 2020
@102092 102092 added this to the BE 진행사항 milestone May 11, 2020
@102092 102092 self-assigned this May 11, 2020
@Limwin94
Copy link
Member

Limwin94 commented May 11, 2020

{
    "games": [
        {
            "id": 1,
            "home": "marvel"
            "away": "captin"
        },
        {
            "id": 2,
            "home": "marvel"
            "away": "captin"
        }
    ]
}

혹시 이러한 형식으로 줄 수 있으신가요?

@102092
Copy link
Contributor Author

102092 commented May 11, 2020

@Limwin94 네네! 가능합니다.
그런데 객체이름을 games 보다는 response 로 묶어서 보내드리려고 하는데, 혹시 괜찮을까요?

@102092 102092 added be backend fe 프론트 엔드 iOS labels May 11, 2020
@choisohyun
Copy link
Contributor

2번에 팀선택화면 플로우가 이해가 잘 안갑니다 ㅜㅜ 있다가 설명 부탁드려요..!

@Limwin94
Copy link
Member

주소는 어디로 보내면 될까요?

@102092
Copy link
Contributor Author

102092 commented May 12, 2020

4. 게임 진행 화면

  • !!우선 3번에 해당하는 시작요청을 한다
  • 게임 진행 화면을 요청
    • GET : api/game/1
  • 응답 예시
{
    "success": true,
    "response": {
        "gameId": 1,
        "inning": 1,
        "scores": [],
        "sbo": {
            "strike": 0,
            "ball": 0,
            "out": 0,
            "hit": 0
        },
        "game": {
            "home": {
                "id": 1,
                "teamId": 1,
                "name": "양성우",
                "battingAverage": 168,
                "pitcher": true
            },
            "away": {
                "id": 6,
                "teamId": 2,
                "name": "박건우",
                "battingAverage": 319,
                "pitcher": true
            }
        },
        "bottom": false
    },
    "error": null
}

@102092
Copy link
Contributor Author

102092 commented May 12, 2020

5.Pitch

  • POST
  • 요청
    • api/pitch
  • 응답
{
    "success": true,
    "response": "STRIKE",
    "error": null
}
  • pitch 후 게임 진행화면
  • GET : api/game/1
{
    "success": true,
    "response": {
        "gameId": 1,
        "inning": 1,
        "scores": [],
        "sbo": {
            "strike": 0,
            "ball": 3,
            "out": 0,
            "hit": 2
        },
        "game": {
            "home": {
                "id": 1,
                "teamId": 1,
                "name": "양성우",
                "battingAverage": 168,
                "pitcher": true
            },
            "away": {
                "id": 8,
                "teamId": 2,
                "name": "오재일",
                "battingAverage": 293,
                "pitcher": false
            }
        },
        "bottom": false
    },
    "error": null
}
  • 점수 추가
{
    "success": true,
    "response": {
        "gameId": 1,
        "inning": 1,
        "homeScore" : 3,
        "awayScore" : 4,
        "sbo": {
            "strike": 0,
            "ball": 1,
            "out": 1,
            "hit": 3
        },
        "game": {
            "home": {
                "id": 1,
                "teamId": 1,
                "name": "양성우",
                "battingAverage": 168,
                "pitcher": true
            },
            "away": {
                "id": 10,
                "teamId": 2,
                "name": "김재환",
                "battingAverage": 283,
                "pitcher": false
            }
        },
        "bottom": false
    },
    "error": null
}
  • 이닝 변화
{
    "success": true,
    "response": {
        "gameId": 1,
        "inning": 2,
        "homeScore" : 3,
        "awayScore" : 4,
        "sbo": {
            "strike": 1,
            "ball": 0,
            "out": 0,
            "hit": 0
        },
        "game": {
            "home": {
                "id": 3,
                "teamId": 1,
                "name": "김태균",
                "battingAverage": 400,
                "pitcher": false
            },
            "away": {
                "id": 6,
                "teamId": 2,
                "name": "박건우",
                "battingAverage": 319,
                "pitcher": true
            }
        },
        "bottom": false
    },
    "error": null
}

@102092
Copy link
Contributor Author

102092 commented May 12, 2020

6. 상세 점수 팝업 요청

  • 요청: GET /game/score/{id}
  • 응답
    • 응답할 점수 현황이 없으면 빈 배열을 리턴
{
    "success": true,
    "response": [],
    "error": null
}
  • 있을 경우
{
    "success": true,
    "response": [
        {
            "gameId": 1,
            "teamId": 2,
            "inning": 2,
            "score": 2,
            "bottom": false
        }
    ],
    "error": null
}

@102092
Copy link
Contributor Author

102092 commented May 14, 2020

1. 게임시작을 알립니다

  • 요청 : POST /api/game
{
	"id" : "1",
	"isStarted" : true
}
  • 응답
{
    "success": true,
    "response": {
        "id": 1,
        "matchId": 1
    },
    "error": null
}
  • 여기서 id 는 할당된 gameId를 의미합니다.

2. game id를 이용해서 게임 진행화면을 불러옵니다.

  • 요청 : GET api/game/1
  • 응답
{
    "success": true,
    "response": {
        "gameId": 1,
        "inning": 1,
        "homeName": "Captin",
        "homeScore": 0,
        "awayName": "Marvel",
        "awayScore": 0,
        "game": {
            "home": {
                "id": 1,
                "teamId": 1,
                "name": "양성우",
                "battingAverage": 168,
                "pitcher": true
            },
            "away": {
                "id": 10,
                "teamId": 2,
                "name": "박건우",
                "battingAverage": 319,
                "pitcher": true
            }
        },
        "status": {
            "gameId": 1,
            "inning": 1,
            "strike": 0,
            "ball": 0,
            "out": 0,
            "hit": 0
        },
        "log": [],
        "bottom": false
    },
    "error": null
}

3. Pitch 합니다.

  • 요청 : api/game/pitch
{
	"gameId" : 1,
	"teamId" : 2,
	"playerId" : 10,
	"inning" : 1,
	"battingAverage" : 229,
	"isBottom" : false
}
  • 진행되고 있는 gameId 와 inning, 회초인지, 말인지를 게시합니다. 현재 타자의 teamId, playerId, battingAverage

  • 응답

{
    "success": true,
    "response": "BALL",
    "error": null
}
  • 피칭에 대한 결과값이 리턴되어 옵니다.

  • 게임 진행화면 재요청 : GET api/game/1

{
    "success": true,
    "response": {
        "gameId": 1,
        "inning": 1,
        "homeName": "Captin",
        "homeScore": 0,
        "awayName": "Marvel",
        "awayScore": 0,
        "game": {
            "home": {
                "id": 1,
                "teamId": 1,
                "name": "양성우",
                "battingAverage": 168,
                "pitcher": true
            },
            "away": {
                "id": 10,
                "teamId": 2,
                "name": "박건우",
                "battingAverage": 319,
                "pitcher": true
            }
        },
        "status": {
            "gameId": 1,
            "inning": 1,
            "strike": 0,
            "ball": 1,
            "out": 0,
            "hit": 0
        },
        "log": [
            {
                "id": 1,
                "gameId": 1,
                "playerId": 10,
                "inning": 1,
                "status": "BALL"
            }
        ],
        "bottom": false
    },
    "error": null
}

4. 상세 점수 화면

  • 요청 : api/game/score/1
  • 응답
{
    "success": true,
    "response": [
        {
            "gameId": 1,
            "teamId": 1,
            "inning": 1,
            "score": 0
        },
        {
            "gameId": 1,
            "teamId": 2,
            "inning": 1,
            "score": 0
        }
    ],
    "error": null
}

5. 상세 플레이어 페이지

  • 요청 : api/game/player/1
  • 응답
{
    "success": true,
    "response": [
        {
            "gameId": 1,
            "teamId": 2,
            "playerId": 10,
            "name": "박건우",
            "atBat": 1,
            "hits": 0,
            "outs": 0
        }
    ],
    "error": null
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
be backend documentation Improvements or additions to documentation fe 프론트 엔드 iOS
Projects
None yet
Development

No branches or pull requests

3 participants