티스토리 뷰

Project

cart-api

ryumodern 2021. 10. 25. 19:20
장바구니

장바구니 단건 조회

Request

CURL

$ curl 'https://localhost:8443/api/carts/1/1' -i -X GET \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Accept: */*'

HTTPie

$ http GET 'https://localhost:8443/api/carts/1/1' \
    'Content-Type:application/json;charset=UTF-8' \
    'Accept:*/*'

Request HTTP Example

GET /api/carts/1/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: */*
Host: localhost:8443

Response

Response Fields

필드 타입 필수값 설명 제한

id

Number

true

장바구니 고유 번호

quantity

Number

true

주문 수량

memberResponse

Object

true

주문 회원

productResponse

Object

true

주문 상품

_links

Varies

true

HATEOAS

Response HTTP Example

HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/hal+json
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN
Content-Length: 918

{
  "id" : 1,
  "memberResponse" : {
    "id" : 1,
    "email" : "panda@naver.com",
    "nickname" : "panda",
    "profileImage" : null,
    "phone" : null,
    "license" : null,
    "createdDateTime" : "2021-10-25T01:13:51.263301",
    "lastModifiedDateTime" : "2021-10-25T01:13:51.263301",
    "leaveDateTime" : null,
    "authority" : null,
    "address" : null,
    "authProvider" : null,
    "status" : "ACTIVE"
  },
  "productResponse" : {
    "name" : "panda",
    "description" : "nice bear",
    "productImage" : null,
    "memberResponse" : null,
    "price" : 50000,
    "stock" : 15000,
    "createdDateTime" : "2021-10-25T01:13:51.266145",
    "productCategory" : "MEAT",
    "region" : "CHUNGCHEONGBUKDO"
  },
  "quantity" : 500,
  "_links" : {
    "self" : {
      "href" : "https://localhost:8443/api/carts/1/1"
    },
    "cart-list" : {
      "href" : "https://localhost:8443/api/carts/1"
    }
  }
}

장바구니 다건 조회

Request

CURL

$ curl 'https://localhost:8443/api/carts/1' -i -X GET \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Accept: */*'

HTTPie

$ http GET 'https://localhost:8443/api/carts/1' \
    'Content-Type:application/json;charset=UTF-8' \
    'Accept:*/*'

Request HTTP Example

GET /api/carts/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: */*
Host: localhost:8443

Response

Response Fields

필드 타입 필수값 설명 제한

_embedded.cartResponseList[].id

Number

true

장바구니 고유 번호

_embedded.cartResponseList[].quantity

Number

true

주문 수량

_embedded.cartResponseList[].memberResponse

Object

true

주문 회원

_embedded.cartResponseList[].productResponse

Object

true

주문 상품

Response HTTP Example

HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/hal+json
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN
Content-Length: 1122

{
  "_embedded" : {
    "cartResponseList" : [ {
      "id" : 1,
      "memberResponse" : {
        "id" : 1,
        "email" : "panda@naver.com",
        "nickname" : "panda",
        "profileImage" : null,
        "phone" : null,
        "license" : null,
        "createdDateTime" : "2021-10-25T01:13:51.334818",
        "lastModifiedDateTime" : "2021-10-25T01:13:51.334818",
        "leaveDateTime" : null,
        "authority" : null,
        "address" : null,
        "authProvider" : null,
        "status" : "ACTIVE"
      },
      "productResponse" : {
        "name" : "panda",
        "description" : "nice bear",
        "productImage" : null,
        "memberResponse" : null,
        "price" : 50000,
        "stock" : 15000,
        "createdDateTime" : "2021-10-25T01:13:51.337615",
        "productCategory" : "MEAT",
        "region" : "CHUNGCHEONGBUKDO"
      },
      "quantity" : 500
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "https://localhost:8443/api/carts/1?page=0&size=10"
    }
  },
  "page" : {
    "size" : 10,
    "totalElements" : 1,
    "totalPages" : 1,
    "number" : 0
  }
}

장바구니 추가

Request

CURL

$ curl 'https://localhost:8443/api/carts/1' -i -X POST \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Accept: */*' \
    -d '{
  "memberId" : 1,
  "productId" : 1,
  "quantity" : 500
}'

HTTPie

$ echo '{
  "memberId" : 1,
  "productId" : 1,
  "quantity" : 500
}' | http POST 'https://localhost:8443/api/carts/1' \
    'Content-Type:application/json;charset=UTF-8' \
    'Accept:*/*'

Request Fields

필드 타입 필수값 설명 제한

memberId

Number

true

주문 회원 고유 번호

Not Null

productId

Number

true

상품 고유 번호

Not Null

quantity

Number

true

주문 수량

Not Null

Request HTTP Example

POST /api/carts/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: */*
Content-Length: 59
Host: localhost:8443

{
  "memberId" : 1,
  "productId" : 1,
  "quantity" : 500
}

Response

Response HTTP Example

HTTP/1.1 201 Created
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Location: https://localhost:8443/api/carts/1/2
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN

장바구니 단건 삭제

Request

CURL

$ curl 'https://localhost:8443/api/carts/1/1' -i -X DELETE \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Accept: */*'

HTTPie

$ http DELETE 'https://localhost:8443/api/carts/1/1' \
    'Content-Type:application/json;charset=UTF-8' \
    'Accept:*/*'

Request Fields

Request HTTP Example

DELETE /api/carts/1/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: */*
Host: localhost:8443

Response

Response HTTP Example

HTTP/1.1 204 No Content
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN

장바구니 다건 삭제

Request

CURL

$ curl 'https://localhost:8443/api/carts/1' -i -X DELETE \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Accept: */*'

HTTPie

$ http DELETE 'https://localhost:8443/api/carts/1' \
    'Content-Type:application/json;charset=UTF-8' \
    'Accept:*/*'

Request Fields

Request HTTP Example

DELETE /api/carts/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: */*
Host: localhost:8443

Response

Response HTTP Example

HTTP/1.1 204 No Content
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN

'Project' 카테고리의 다른 글

board-api  (0) 2021.10.25
product-api  (0) 2021.10.25
order-api  (0) 2021.10.25
member-api  (0) 2021.10.25
5주차 Java-Spring 웹 개발 인강 후기  (0) 2021.09.07
댓글
링크
글 보관함
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Total
Today
Yesterday