Skip to content

API 명세서

exertivestar edited this page May 25, 2023 · 3 revisions

API 명세서

담당: 백 상태: In progress 최종 편집 일시: 2023년 5월 25일 오전 11:07

로그인

API 주소 : /api/login

Method : POST

  • Body

    {
        "email":"[email protected]",
        "password":"Abcd1234@"
    }
  • Response Header

    Status : 200 OK

    {
        "Authorization":"JWT TOKEN KEY",
        "Refresh":"JWT TOKEN KEY"
    }
  • Redirection

카카오 로그인

API 주소 : /oauth2/authorization/kakao

Method : GET

  • Body

  • Response uri

    Status : 200 OK

        /oauth2/redirect?accessToken="JWT AccessToken"&refreshToekn="JWT RefreshToken"
  • Redirection

이메일 본인인증을 위한 인증코드 발송

API 주소 : /api/members/email-verify?email=[email protected]

Method : POST

  • Response Header

    Status : 200 OK

    {
        "data": "BxNO2v"
    }
  • Redirection

회원가입

API 주소 : /api/members

Method : POST

  • Body

    • 생년월일(birthDate) 패턴 : 생년월일은 yyyy-mm-dd 형식만 가능.

    • 전화번호(phone) 패턴 : 앞자리=010,011,016~019 , 중간자리=3자리숫자or4자리숫자 , 마지막자리=4자리숫자

    • 비밀번호(password) 패턴 : 비밀번호는 최소 8자 이상의 길이를 가져야 하며, 최소 하나의 대문자, 소문자, 숫자, 특수문자(@ , $ , ! , % , * , ? , &)를 포함

    {
        "name":"홍길동",
        "email":"[email protected]",
        "birthDate":"2000-01-01",
        "password":"Zz1@$!%*?&",
        "phone":"010-1111-2222",
        "isEmailVerified":true  // 이메일본인인증이 완료된 회원은 true, 미완료된 회원은 false
    }
  • Response Header

    Status : 201 CREATED

    Location : /api/members/1

  • Redirection

회원정보 수정

API 주소 : /api/members/1

Method : PATCH

  • Body

    • name, password, phone 필드 → optional

    • 전화번호(phone) 패턴 : 앞자리=010,011,016~019 , 중간자리=3자리숫자or4자리숫자 , 마지막자리=4자리숫자

    • 비밀번호(password) 패턴 : 비밀번호는 최소 8자 이상의 길이를 가져야 하며, 최소 하나의 대문자, 소문자, 숫자, 특수문자(@ , $ , ! , % , * , ? , &)를 포함

    {
        "name":"김길동",
        "password":"zZ3@$!%*?&",
        "phone":"010-111-2222"
    }
  • Response Header

    Status : 200 OK

    {
        "memberId": 1,
        "name": "김길동",
        "email": "[email protected]",
        "createdAt": "2023-05-10T00:44:34.031483",
        "modifiedAt": "2023-05-10T00:44:37.975422",
        "createdBy": "[email protected]",  //작성자
        "modifiedBy": "[email protected]",   //수정자
        "phone": "010-111-2222",
        "reward_points": 0,   //마일리지
        "memberStatus": "MEMBER_ACTIVE",   //MEMBER_ACTIVE("활동중"), MEMBER_QUIT("탈퇴 상태")
        "memberShip": "BASIC",   //BASIC(기본등급), VIP(우수회원)
        "birthDate": "2000-01-01",
        "usageCount": 0,    //이용횟수
        "favoriteId": 1,
        "emailVerified": true,
        "sellerVerified": false,
        "businessRegistrationNumber": null
    }
  • Redirection

특정 회원정보 조회

API 주소 : /api/members/1

Method : GET

  • Response Header

    Status : 200 OK

    {
        "memberId": 1,
        "name": "김길동",
        "email": "[email protected]",
        "createdAt": "2023-05-10T00:44:34.031483",
        "modifiedAt": "2023-05-10T00:44:37.975422",
        "createdBy": "[email protected]",  //작성자
        "modifiedBy": "[email protected]",   //수정자
        "phone": "010-111-2222",
        "reward_points": 0,   //마일리지
        "memberStatus": "MEMBER_ACTIVE",   //MEMBER_ACTIVE("활동중"), MEMBER_QUIT("탈퇴 상태")
        "memberShip": "BASIC",   //BASIC(기본등급), VIP(우수회원)
        "birthDate": "2000-01-01",
        "usageCount": 0,    //이용횟수
        "favoriteId": 1,
        "emailVerified": true,
        "sellerVerified": false,
        "businessRegistrationNumber": null
    }
  • Redirection

모든 회원정보 조회

API 주소 : /api/members

Method : GET

  • Response Header

    Status : 200 OK

    [
        {
            "memberId": 1,
            "name": "김코딩",
            "email": "[email protected]",
            "createdAt": "2023-05-10T00:56:10.906617",
            "modifiedAt": "2023-05-10T00:56:10.906631",
            "createdBy": "[email protected]",
            "modifiedBy": "[email protected]",
            "phone": "010-1111-2222",
            "reward_points": 0,
            "memberStatus": "MEMBER_ACTIVE",
            "memberShip": "BASIC",
            "birthDate": "2000-01-01",
            "usageCount": 0,
    		"favoriteId": 1,
    		"emailVerified": true,
    		"sellerVerified": false,
    		"businessRegistrationNumber": null
        },
        {
            "memberId": 2,
            "name": "조코딩",
            "email": "[email protected]",
            "createdAt": "2023-05-10T00:56:55.746517",
            "modifiedAt": "2023-05-10T00:56:55.746559",
            "createdBy": "[email protected]",
            "modifiedBy": "[email protected]",
            "phone": "010-2222-3333",
            "reward_points": 0,
            "memberStatus": "MEMBER_ACTIVE",
            "memberShip": "BASIC",
            "birthDate": "2000-01-01",
            "usageCount": 0,
    		"favoriteId": 1,
    		"emailVerified": true,
    		"sellerVerified": true,
    		"businessRegistrationNumber": "123-12-12345"
        }
    ]
  • Redirection

특정 회원정보 삭제(탈퇴)

API 주소 : /api/members/1

Method : DELETE

  • Response Header

    Status : 204 NO CONTENT

  • Redirection

탈퇴 회원 재가입

API 주소 : /api/members/1

Method : POST

  • Body

    {
        "memberStatus":"MEMBER_ACTIVE"
    }
  • Response Header

    Status : 200 OK

    {
        "memberId": 1,
        "name": "김길동",
        "email": "[email protected]",
        "createdAt": "2023-05-10T00:44:34.031483",
        "modifiedAt": "2023-05-10T00:44:37.975422",
        "createdBy": "[email protected]",  //작성자
        "modifiedBy": "[email protected]",   //수정자
        "phone": "010-111-2222",
        "reward_points": 0,   //마일리지
        "memberStatus": "MEMBER_ACTIVE",   //MEMBER_ACTIVE("활동중"), MEMBER_QUIT("탈퇴 상태")
        "memberShip": "BASIC",   //BASIC(기본등급), VIP(우수회원)
        "birthDate": "2000-01-01",
        "usageCount": 0,    //이용횟수
    	"favoriteId": 1,
    	"emailVerified": true,
    	"sellerVerified": false,
    	"businessRegistrationNumber": null
    }
  • Redirection

일반계정을 판매자계정으로 등록

API 주소 : /api/sellers/{memberId}

Method : POST

  • Body

    • 사업자등록번호(businessRegistrationNumber) 패턴 : “000-00-00000” 패턴으로 입력되어야 합니다.

    • 사업자등록 일자(businessRegistrationDate) 패턴 : “0000-00-00” 패턴으로 입력되어야 합니다.

    {
    	"businessRegistrationNumber":"000-00-00000",
    	"businessRegistrationDate":"2023-01-01"
    }
  • Response Header

    Status : 200 OK

    {
    	"memberId": 1,
        "name": "김길동",
        "email": "[email protected]",
        "createdAt": "2023-05-10T00:44:34.031483",
        "modifiedAt": "2023-05-10T00:44:37.975422",
        "createdBy": "[email protected]",  //작성자
        "modifiedBy": "[email protected]",   //수정자
        "phone": "010-111-2222",
        "reward_points": 0,   //마일리지
        "memberStatus": "MEMBER_ACTIVE",   //MEMBER_ACTIVE("활동중"), MEMBER_QUIT("탈퇴 상태")
        "memberShip": "BASIC",   //BASIC(기본등급), VIP(우수회원)
        "birthDate": "2000-01-01",
        "usageCount": 0,    //이용횟수
    	"favoriteId": 1,
    	"emailVerified": true,
    	"sellerVerified": false,
    	"businessRegistrationNumber": null
    }
  • Redirection

판매자계정 정보 수정

API 주소 : /api/sellers/{memberId}

Method : PATCH

  • Body

    • businessRegistrationNumber, businessRegistrationDate 필드 → optional

    • 사업자등록번호(businessRegistrationNumber) 패턴 : “000-00-00000” 패턴으로 입력되어야 합니다.

    • 사업자등록 일자(businessRegistrationDate) 패턴 : “0000-00-00” 패턴으로 입력되어야 합니다.

    {
    	"businessRegistrationNumber":"000-00-00000",     // optional
    	"businessRegistrationDate":"2023-01-01"       // optional
    }
  • Response Header

    Status : 200 OK

    {
    	"memberId": 1,
        "name": "김길동",
        "email": "[email protected]",
        "createdAt": "2023-05-10T00:44:34.031483",
        "modifiedAt": "2023-05-10T00:44:37.975422",
        "createdBy": "[email protected]",  //작성자
        "modifiedBy": "[email protected]",   //수정자
        "phone": "010-111-2222",
        "reward_points": 0,   //마일리지
        "memberStatus": "MEMBER_ACTIVE",   //MEMBER_ACTIVE("활동중"), MEMBER_QUIT("탈퇴 상태")
        "memberShip": "BASIC",   //BASIC(기본등급), VIP(우수회원)
        "birthDate": "2000-01-01",
        "usageCount": 0,    //이용횟수
    	"favoriteId": 1,
    	"emailVerified": true,
    	"sellerVerified": false,
    	"businessRegistrationNumber": null
    }
  • Redirection

리뷰 작성

API 주소 : /api/reviews

Method : POST

  • Body

    • 평점(score) 패턴 : 평점은 0.0 부터 5.0 까지 0.5점 단위의 값만 가능
    {
        "content": "좋은 캠핑장에서 즐거운 시간 보내고 갑니다.",
        "score": 5.0,
    	"memberId": 1,
    	"productId": 1
    }
  • Response Header

    Status : 201 CREATED

    Location : /api/reviews/1

  • Redirection

리뷰 수정

API 주소 : /api/reviews/1

Method : PATCH

  • Body

    • content, score 필드 → optional

    • 평점(score) 패턴 : 평점은 0.0 부터 5.0 까지 0.5점 단위의 값만 가능

    {
        "content": "좋은 캠핑장에서 즐거운 시간 보내고 갑니다. 또 가고 싶어요. 강추합니다.",
        "score": 5.0
    }
  • Response Header

    Status : 200 OK

    {
        "reviewId": 1,
        "content": "좋은 캠핑장에서 즐거운 시간 보내고 갑니다. 또 가고 싶어요. 강추합니다.",
        "score": 5.0,
        "createdAt": "2023-05-10T01:04:17.778339",
        "modifiedAt": "2023-05-10T01:17:14.557808",
        "createdBy": null,   //작성자
        "modifiedBy": null,   //수정자
    	"memberId": 1,
    	"productId": 1
    }
  • Redirection

특정 리뷰 조회

API 주소 : /api/reviews/1

Method : GET

  • Response Header

    Status : 200 OK

    {
        "reviewId": 1,
        "content": "좋은 캠핑장에서 즐거운 시간 보내고 갑니다. 또 가고 싶어요. 강추합니다.",
        "score": 5.0,
        "createdAt": "2023-05-10T01:04:17.778339",
        "modifiedAt": "2023-05-10T01:04:17.778339",
        "createdBy": null,   //작성자
        "modifiedBy": null,   //수정자
    	"memberId": 1,
    	"productId": 1
    }
  • Redirection

모든 리뷰 조회(page)

API 주소 : /api/reivews?page=1&size=4

Method : GET

  • Body

    {
    	
    }
  • Response Header

    Status : 200 OK

    {
        "data": [
            {
                "reviewId": 4,
                "content": "잘 놀다 갑니다. 추천해요",
                "score": 4.0,
                "createdAt": "2023-05-10T02:35:11.049175",
                "modifiedAt": "2023-05-10T02:35:11.049175",
                "createdBy": null,
                "modifiedBy": null,
    						"memberId": 1,
    						"productId": 1
            },
            {
                "reviewId": 3,
                "content": "그럭저적 나쁘지 않습니다.",
                "score": 3.5,
                "createdAt": "2023-05-10T02:34:55.16117",
                "modifiedAt": "2023-05-10T02:34:55.16117",
                "createdBy": null,
                "modifiedBy": null,
    						"memberId": 1,
    						"productId": 2
            },
            {
                "reviewId": 2,
                "content": "최고의 캠핑장이었습니다. 추천해요",
                "score": 5.0,
                "createdAt": "2023-05-10T02:32:54.103601",
                "modifiedAt": "2023-05-10T02:32:54.103601",
                "createdBy": null,
                "modifiedBy": null,
    						"memberId": 4,
    						"productId": 5
            },
            {
                "reviewId": 1,
                "content": "시설에 생각보다 별로입니다..",
                "score": 0.5,
                "createdAt": "2023-05-10T02:29:07.484284",
                "modifiedAt": "2023-05-10T02:31:22.712995",
                "createdBy": null,
                "modifiedBy": null,
    						"memberId": 2,
    						"productId": 7
            }
        ],
            "pageInfo": {
            "page": 1,
            "size": 4,
            "totalElements": 4,
            "totalPages": 1
        }
    }
  • Redirection

특정 리뷰 삭제

API 주소 : /api/reviews/1

Method : DELETE

  • Response Header

    Status : 204 NO CONTENT

  • Redirection

캠핑장 정보 등록

API 주소 : /api/products

Method : POST

Content-Type: multipart/form-data

  • Request Body

    Key: images 
    Value: image_file
    
    Key: jsonData 
    Value: {
    	"productName":"캠핑장",
        "address":"한강 어딘가",
        "location":"서울",
        "content":"캠핑장 빌려드립니다.",
        "capacity":10,
        "cancellationDeadline":"2023-05-03T10:00:00",
        "productPrice":30000,
        "productPhone":"010-1234-5337",
        "memberId": 1
    }
    

Untitled

  • Response Body

    Status : 201 Created

    Location : /api/products/1

  • Redirection

캠핑장 정보 수정

API 주소 : /api/products/1

Method : PATCH

Content-Type: multipart/form-data

  • Request Body

    Key: images 
    Value: image_file
    
    Key: jsonData 
    Value: {
    	"productName":"new캠핑장",
        "address":"new한강 어딘가",
        "location":"new서울",
        "content":"new캠핑장 빌려드립니다.",
        "capacity":10,
        "cancellationDeadline":"2023-05-05T00:35:17",
        "productPrice":30000,
        "productPhone":"010-1234-5337",
    
    }
  • Response Body

    Status : 200 OK

    {
    	"productId": 1,
        "productName": "new캠핑장",
        "address": "new한강 어딘가",
        "location": "new서울",
        "content": "new캠핑장 빌려드립니다.",
        "capacity": 10,
        "cancellationDeadline": "2023-05-05T00:35:17",
        "productPrice": 30000,
        "productPhone": "010-1234-5337",
        "latitude": 37.5,
        "longitude": 40.5,
        "deleted": false,
        "createdAt": "2023-05-10T09:21:24.770742",
        "createdBy": "name",
        "modifedAt": "2023-05-10T09:21:46.3440725",
        "modifiedBy": "name",
        "imageUrl": "http://~",
        "memberId": 1
    }
  • Redirection

캠핑장 정보 삭제

API 주소 : /api/products/1

Method : DELETE

  • Response Body

    Status : 204 No Content

  • Redirection

특정 캠핑장 조회

API 주소 : /api/products/1

Method : GET

  • Response Body

    Status :

    {
    	"productId": 1,
        "productName": "new캠핑장",
        "address": "new한강 어딘가",
        "location": "new서울",
        "content": "new캠핑장 빌려드립니다.",
        "capacity": 10,
        "cancellationDeadline": "2023-05-05T00:35:17",
        "productPrice": 30000,
        "productPhone": "010-1234-5337",
        "latitude": 37.5,
        "longitude": 40.5,
        "deleted": false,
        "createdAt": "2023-05-10T09:21:24.770742",
        "createdBy": "name",
        "modifiedAt": "2023-05-10T09:21:46.3440725",
        "modifiedBy": "name",
        "imageUrl": "http://~",
        "memberId": 1
    }
  • Redirection

모든 캠핑장 조회

API 주소 : /api/products?page=1&size=10

Method : GET

  • Response Body

    Status : 200 OK

    {
    	"data": [
            {
                "productId": 2,
                "productName": "캠핑장2",
                "address": "한강 어딘가2",
                "location": "서울2",
                "content": "캠핑장 빌려드립니다.2",
                "capacity": 10,
                "cancellationDeadline": "2023-05-03T10:00:00",
                "productPrice": 30000,
                "productPhone": "010-1234-1111",
                "latitude": null,
                "longitude": null,
                "deleted": false,
                "createdAt": "2023-05-10T09:24:02.995997",
                "createdBy": "name",
                "modifiedAt": "2023-05-10T09:24:02.995997",
                "modifiedBy": "name",
                "imageUrl": "http://~",
                "memberId": 1
            },
            {
                "productId": 1,
                "productName": "new캠핑장",
                "address": "new한강 어딘가",
                "location": "new서울",
                "content": "new캠핑장 빌려드립니다.",
                "capacity": 10,
                "cancellationDeadline": "2023-05-05T00:35:17",
                "productPrice": 30000,
                "productPhone": "010-1234-5337",
                "latitude": 37.5,
                "longitude": 40.5,
                "deleted": false,
                "createdAt": "2023-05-10T09:21:24.770742",
                "createdBy": "name",
                "modifiedAt": "2023-05-10T09:21:46.344073",
                "modifiedBy": "name",
                "imageUrl": "http://~",
                "memberId": 1
            }
        ],
            "pageInfo": {
            "page": 1,
            "size": 10,
            "totalElements": 2,
            "totalPages": 1
        }
    }
  • Redirection

카카오페이 결제 준비 요청

설명 : 예약고유번호와 실제 결제할 금액을 body에 담아 post로 넘겨주시면 → 우리 서버가 카카오페이 서버와 통신한 후 → tid(결제 한건의 고유번호, 20자의 문자열)와 next_redirect_pc_url (결제 페이지)을 받아서 → 클라이언트쪽으로 응답합니다.

확인 했습니다.

API 주소 : /api/payments/ready

Method : POST

  • Body

    {
    	"reservation_id": long,
    	"actual_payment_amount": int
    }
  • Response Body

    Status : 200 OK

    {
    	"tid": string,
    	"next_redirect_pc_url": string,
    	"created_at": datetime
    }
  • Redirection

    응답으로 받은 {next_redirect_pc_url} 을 팝업또는 레이어 방식으로 띄우면 됩니다.

카카오페이 결제 승인 요청

API 주소 : /api/payments/approve

Method : GET

요청 파라미터 :

  • pg_token (string): 결제 토큰
  • tid (string): 결제 거래 ID

요청 예시:

1️⃣ GET /api/payments/approve?pg_token=abcd1234&tid=T123456789
  • Body

  • Response Body

    Status : 200 OK

    {
      "tid": "T123456789",
      "partner_order_id": "123456789",
      "partner_user_id": "가맹점 회원 ID",
      "approved_at": "2023-05-25T10:05:00Z"
    }
  • Redirection

    응답으로 받은 {next_redirect_pc_url} 을 팝업또는 레이어 방식으로 띄우면 됩니다.

새로운 예약 등록

API 주소 : /api/reservations

Method : POST

  • Body

    {
        "memberId": long,
    	"productId": long,
        "reservationDate": "yyyy-MM-dd",
        "reservationName": string,
        "reservationPhone": string,
        "reservationEmail": string,
    	"actualPaymentAmount": int,
    	"usedRewardPoints": int
    }
  • Response Body

    Status : 201 (Created)

    {
    	"reservation_id": long
    }
  • Response Body (중복된 예약이 이미 존재할 때)

    Status : 400 HttpStatus.BAD_REQUEST

    Body : "해당 날짜에 이미 진행중이거나 완료된 예약이 존재합니다.”

  • Response Body (동시에 여러명의 사용자가 같은 예약을 시도할 때)

    Status : 409 HttpStatus.CONFLICT

    Body : "동시에 중복 예약을 시도하는 상황이 발생하였습니다. 잠시 후 다시 시도해주세요.”

  • Redirection

특정 예약 조회

API 주소 : /api/reservations/{reservation-id}

Method : GET

URL Path Parameters: reservation-id (long)

  • Body

  • Response Body

    Status : 200 OK

    {
        "reservationId": long,
        "reservationDate": "yyyy-MM-dd",
        "reservationName": string,
        "reservationPhone": string,
        "reservationEmail": string,
        "reservationStatus": string,
        "createdAt": "yyyy-MM-dd'T'HH:mm:ss",
        "createdBy": string,
        "productName": string,
        "memberId": long
    }
  • Redirection

특정 예약 수정

API 주소 : /api/reservations/{reservation-id}

Method : PATCH

URL Path Parameters: reservation-id (long)

  • Body

    {
    	"reservationId": long,
        "reservationDate": "yyyy-MM-dd",
        "reservationName": string,
        "reservationPhone": string,
        "reservationEmail": string,
        "reservationStatus": string
    }
  • Response Body

    Status : 200 OK

    {
    	"reservationId": long,
        "reservationDate": "yyyy-MM-dd",
        "reservationName": string,
        "reservationPhone": string,
        "reservationEmail": string,
        "reservationStatus": string,
        "createdAt": "yyyy-MM-dd'T'HH:mm:ss",
        "createdBy": string,
        "productName": string,
        "memberId": long
    }
  • Redirection

특정 예약 취소

API 주소 : /api/reservations/{reservation-id}

Method : DELETE

URL Path Parameters: reservation-id (long)

  • Body

  • Response Body

    Status : 204 (No Content)

  • Redirection

특정 사용자의 예약내역 조회

API 주소 : /api/reservations/member/{memberId}

Method : GET

URL Path Parameters: memberId (long)

  • Body

    None
  • Response Body

    Status : HTTP 200 OK

    {
          "reservationId": long,
          "reservationDate": "2023-05-25",
          "reservationName": "John Doe",
          "reservationPhone": "010-1234-5678",
          "reservationEmail": "[email protected]",
          "usedRewardPoints": 0,
          "actualPaymentAmount": 100000,
          "paymentDate": "2023-05-23",
          "reservationStatus": "RESERVATION_REQUEST",
          "paymentStatus": "NOT_PAYMENT",
          "deleted": false,
          "product": {
            "productId": 3,
            "productName": "Great Camping Tent",
            "address": "123 Camping St.",
            "location": "Seoul",
            "content": "This is a great tent",
            "capacity": 4,
            "cancellationDeadline": "2023-05-24",
            "productPrice": 100000,
            "productPhone": "010-5678-1234",
            "latitude": 37.5665,
            "longitude": 126.9780,
            "deleted": false,
            "imageUrl": "http://example.com/image.jpg"
          },
            "payment": {
            "paymentId": long,
            "tid": "TID12345678",
            "paymentStatus": "COMPLETED"
          }
    }
  • Redirection

해당 날짜에 예약이 존재하는지 확인

API 주소 : /api/reservations/existence

Method : POST

설명 : 해당 캠핑장이 예약날짜에 예약이 이미 존재하면 existence 값으로 true 를 응답함.

만약 존재하지 않으면 false 를 응답함.

  • Body

    {
          "productId": long,
          "reservationDate": "yyyy-MM-dd"
    }
  • Response Body

    Status : HTTP 200 OK

    {
          "productId": long,
          "reservationDate": "yyyy-MM-dd",
          "existence": boolean
    }
  • Redirection