- ํ์๊ฐ์
- ์์ด๋ ์ค๋ณต์ด๋ฉด ์์ธ
- ๋ก๊ทธ์ธ
- id, ๋น๋ฐ๋ฒํธ ์๋ชป๋์์ ๋ ์์ธ
- ์ ์์ ์ผ๋ก ๋ก๊ทธ์ธ ๋ ๊ฒฝ์ฐ token๊ณผ name ๋๊ธด๋ค.
- ์์
- ๋น๋ฐ๋ฒํธ๊ฐ ์ผ์นํ๋ฉด ์์ ํ ์ ์๋ค.
- name ์์ ๊ฐ๋ฅํ๋ค.
- ๋น๋ฐ๋ฒํธ๊ฐ ์ผ์นํ์ง ์์ ๋ ์์ธ
- ํํด
- ๋น๋ฐ๋ฒํธ๊ฐ ์ผ์นํด์ผ ํํดํ ์ ์๋ค.
- ๋น๋ฐ๋ฒํธ๊ฐ ํ๋ฆด๊ฒฝ์ฐ ์์ธ
POST
/products
// request
{
"name": String
"price": int
"imageUrl": String
}
// response 201 created
Header {
"Location": "/products/{productId}"
}
GET
/products
// request
//response
200 OK
{
[
{
"id": Long,
"name": String
"price": int
"imageUrl": String
},
{
"id": Long,
"name": String
"price": int
"imageUrl": String
}
]
}
๋จ์ผ ์์ดํ ์กฐํ
GET
/products/{productId}
// request
// response
200 OK
{
"id" : Long
"name": String
"price": int
"imageUrl": String
}
// productId ์๋ ๊ฒฝ์ฐ 404 NOT FOUND
DELETE
/products/{productId}
// request
// response
204 No Content
// productId ์๋ ๊ฒฝ์ฐ 404 NOT FOUND
- ์ฅ๋ฐ๊ตฌ๋ ๋ด๊ธฐ
- ์ฅ๋ฐ๊ตฌ๋ ์ญ์
- ์ฅ๋ฐ๊ตฌ๋ ์ ์ฒด ์ญ์
- ์ฅ๋ฐ๊ตฌ๋ ์กฐํ
์ฅ๋ฐ๊ตฌ๋ ๋ด๊ธฐ
POST
/customers/me/carts
// request
Header {
"Authorization": accessToken
}
Body
{
"productId": Long
}
// response
Header {
"Location": "/customers/cart/{cartItemId}"
}
201 Created
Body{
"id" : Long,
"productId" : Long,
"name" : String,
"price" : int,
"imageUrl" : String,
"quantity" : int,
}
// accessToken์ด ์ ํจํ์ง ์์ ๊ฒฝ์ฐ 401 Unauthorized
// productId๊ฐ ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ 404 Not Found
// ์ฅ๋ฐ๊ตฌ๋์ ์ด๋ฏธ product๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ 400 Bad Request
์ฅ๋ฐ๊ตฌ๋ ์กฐํ
GET
/customers/me/carts
// request
Header {
"Authorization": accessToken
}
//response
200 OK
{
[
{
"id": Long,
"productId" : Long,
"name": String
"price": int
"imageUrl": String
"quantity": int
},
{
"id": Long,
"productId" : Long,
"name": String
"price": int
"imageUrl": String
"quantity": int
}
]
}
// ์ฅ๋ฐ๊ตฌ๋์ ์๋ฌด๋ฐ ์ํ์ด ์์ผ๋ฉด empty List
// ํ ํฐ์ด ์ ํจํ์ง ์์ผ๋ฉด 401 Unauthorized
์ฅ๋ฐ๊ตฌ๋ ์ญ์
DELETE
/customers/me/carts/{cartItemId}
// request
Header {
"Authorization": accessToken
}
// response
204 No Content
// ํ ํฐ์ด ์ ํจํ์ง ์์ผ๋ฉด 401 Unauthorized
// cartItemId๊ฐ ์๋ ๊ฒฝ์ฐ 404 NOT FOUND
// productId๊ฐ ์ฌ๋ผ์ ธ์๋ ๊ฒฝ์ฐ ์ถํ ๊ณ ๋ ค
์ฅ๋ฐ๊ตฌ๋ ์ ์ฒด ์ญ์
DELETE
/customers/me/carts
// request
Header {
"Authorization": accessToken
}
// response
204 No Content
// ํ ํฐ์ด ์ ํจํ์ง ์์ผ๋ฉด 401 Unauthorized
์ฅ๋ฐ๊ตฌ๋ ๊ฐ์ ์์
PUT
/customers/me/carts/{cartItemId}
// request
Header {
"Authorization": accessToken
}
Body
{
"quantity": int
}
// response
200 ok
Body{
"id" : Long,
"productId" : Long,
"name" : String,
"price" : int,
"imageUrl" : String,
"quantity" : int,
}
// accessToken์ด ์ ํจํ์ง ์์ ๊ฒฝ์ฐ 401 Unauthorized
// cartItemId๊ฐ ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ 404 Not Found
POST
/customers/orders
// request
Header {
"Authorization": accessToken
}
Body
{
[
{
"cartItemId": Long,
"quantity": int
},
{
"cartItemId": Long,
"quantity": int
},
...
]
}
// response
Header {
"Location": "/customers/orders/{orderId}"
}
// accessToken์ด ์ ํจํ์ง ์์ ๊ฒฝ์ฐ 401 Unauthorized
// cartItemId๊ฐ ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ 404 Not Found
// quantity๊ฐ 0 ์ดํ์ธ ๊ฒฝ์ฐ 400 Bad Request
๋จ์ผ ์ฃผ๋ฌธ ๋ด์ญ ์กฐํ
GET
/customers/orders/{orderId}
// request
Header {
"Authorization": accessToken
}
// response
200 OK
{
"id" : Long,
"orderDetails" : [
{
"productId": Long
"quantity" : int
"price" : int
"name" : String
"imageUrl" : String
},
{
"productId": Long
"quantity" : int
"price" : int
"name" : String
"imageUrl" : String
},
// ...
]
}
// accessToken์ด ์ ํจํ์ง ์์ ๊ฒฝ์ฐ 401 Unauthorized
// orderId ์๋ ๊ฒฝ์ฐ 404 NOT FOUND
// customer๊ฐ orderId์ ๋ํ ๊ถํ์ด ์๋ ๊ฒฝ์ฐ 401 Unauthorized (๊ทธ๋๊น ๋ด ์ฃผ๋ฌธ ๋ด์ญ์ ๋จ์ด ๋ณด๋ ค๊ณ ํ ๋)
GET
/customers/orders
*/*/ request
Header {
"Authorization": accessToken
}
// response
200 OK
{
[
"id" : Long,
"orderDetails" : [
{
"productId": Long
"quantity" : int
"price" : int
"name" : String
"imageUrl" : String
},
{
"productId": Long
"quantity" : int
"price" : int
"name" : String
"imageUrl" : String
}
]
],
[
"id" : Long,
"orderDetails" : [
{
"productId": Long
"quantity" : int
"price" : int
"name" : String
"imageUrl" : String
},
{
"productId": Long
"quantity" : int
"price" : int
"name" : String
"imageUrl" : String
}
]
]
// ...
}
// accessToken์ด ์ ํจํ์ง ์์ ๊ฒฝ์ฐ 401 Unauthorized
- ๋ฐฑ์๋
- 1๋จ๊ณ
- ํ์๊ฐ์
- ๋ก๊ทธ์ธ
- ์์
- ํํด
- 1๋จ๊ณ
POST
/customers
// request
{
"loginId": string,
"name": string,
"password": string
}
// response
// HEADER
// Location: "/customers/me"
// 201
{
"loginId": string,
"name": string
}
// 400 Bad Request
POST
/login
// request
{
"loginId": string,
"password": string
}
// response
// 200
{
"accessToken": string,
"name": string
}
// 401 Unauthorized (๋ก๊ทธ์ธ ์คํจ)
- id, ๋น๋ฐ๋ฒํธ ์๋ชป๋์์ ๋
GET
/customers/me
headers: {
Authorization: `Bearer ${accessToken}`,
},
// 200 OK response
{
"loginId": string,
"name": string
}
//401 Unauthorized
//ํ ํฐ์ด ์ ํจํ์ง ์์ ๊ฒฝ์ฐ
//404 Not Found
//์กด์ฌํ์ง ์๋ ํ์์ผ ๊ฒฝ์ฐ
// ํ์ฌ๋ body์ String์ผ๋ก ์ค๋ฅ ๋ฉ์ธ์ง๊ฐ response ๋จ
{
"์กฐํ ์คํจ!" // 2์ฐจ์์๋ JSON๊ฐ์ฒด๋ก ๋ณด๋ด์
}
PUT
/customers/me
// response
// 200
{
"name": string
}
// 400 Bad Request
// ๋น๋ฐ๋ฒํธ ์ผ์นํ์ง ์์๋
// ์์ด๋๊ฐ ์ด๋ฉ์ผ ํ์์ด ์๋ ๋
// 404 Not Found
// ์กด์ฌํ์ง ์๋ ํ์์ผ ๋
- ๋ค์ด๊ฐ์ ์์ ํ๊ณ ๋น๋ฐ๋ฒํธ ์ณ์ผ ํ์
headers: {
Authorization: `Bearer ${accessToken}`,
},
// request
{
"loginId": string,
"name": string,
"password": string // ์์ ํ์ ์ฉ ๋น๋ฐ๋ฒํธ
}
DELETE
/customers/me
- ํํด๋ฅผ ๋น๋ฐ๋ฒํธ ํ๋ฒ ๋ ์น๊ณ ํํด์ํค๊ธฐ
headers: {
Authorization: `Bearer ${accessToken}`,
},
// request
{
"password": string,
}
// response
**// 204 no content**
// 400 Bad Request
// ๋น๋ฐ๋ฒํธ ์ผ์นํ์ง ์์๋
// 404 Not Found
// ์กด์ฌํ์ง ์๋ ํ์์ผ ๊ฒฝ์ฐ
//ํ ํฐ์ด ์กด์ฌํ์ง ์๋ ๊ฒฝ์ฐ