# Products(이명석)

&#x20;

## products list(filter & sort & search)

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:3000/products?`

\[**endpoint]** : <http://127.0.0.1:3000>/products?keyword=\&checkInDate=\&checkOutDate=\&region=\&numberOfGuests=\&priceMin=\&priceMax=\&type=\&theme=\&orderBy=

\[query]

keyword : 지역, 주소를, 스테이 이름을 검색하면 해당 숙소가 나오도록 구현할 예정입니다. 그러면 키워드가 지역(region),주소(address), 스테이이름(name)이겠네요. 입력창에 담긴 값을주시면 됩니다.

checkInDate, checkOutDate : 달력에서 checkin checkout 날짜를 선택하면 선택된 날짜를 2022.1.1의 형태로 각각 변수에 담아서 보내주세요. 선택가능 날짜는 2022.1.1 \~ 2022.1.14 입니다

region = \["수도권", "강원", "충청", "경상", "전라", "제주"]중 하나만 변수에 담아 보내주세요.

numberOfGuests : 1\~10 중 하나를 변수에 담아주세요.

priceMin, priceMax : 각 변수에 가격을 담아 보내주세요. 선택가능 가격은 300,000 \~ 700,000입니다.

theme = \["커플","가족","나홀로 여행"]중 테마를 변수에 담아주세요.

type = \["펜션", "한옥","캠핑","민박","호텔"]중 하나를 변수에 담아주세요.

orderBy = \["priceAsc, "priceDecs", "newest"] 중 하나를 변수에 담아주세요.

#### Query Parameters

| Name                                   | Type    | Description                                            |
| -------------------------------------- | ------- | ------------------------------------------------------ |
| search                                 | String  | search keyword                                         |
| availableProductOptionsId              | Int     | dateOptionId                                           |
| region                                 | String  | region name                                            |
| numberOfGuests                         | Number  | number of person to stay                               |
| price                                  | Decimal | price per 1 day                                        |
| theme                                  | String  | stay theme                                             |
| type                                   | String  | stay type                                              |
| offset                                 | Int     | <p>start number</p><p>\[for pagenation]</p>            |
| limit                                  | Int     | <p>number of items in page</p><p>\[for pagenation]</p> |
| sort<mark style="color:red;">\*</mark> | String  | <p>sorting option</p><p>\[default : newest]</p>        |

{% tabs %}
{% tab title="200: OK return json data" %}

```javascript
Data example

{
  "data": [
    {
      "id": "1",
      "name": "보령 스테이 인터뷰",
      "type": "캠핑",
      "region": "충청도",
      "numberOfGuests": "2",
      "price": "25000",
      "thumbnailImage": "https://stayinterview.co.kr/fileData/download?code=4358"
    }
  ]
}

Data structure & type
{
  "data": [
    {
      "id" : "int",
      "name": "varcha(50)",
      "type": "varcha(50)",
      "region": "varcha(50)",
      "numberOfGuests": "int",
      "price": "decimal",
      "thumbnailImage": "varcha(2083)"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## 상품 상세정보

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:3000/product/:productId`

eg ) <http://127.0.0.1:3000/product/1>

1\) availableProductOptionsId는 boolean으로 변경될 수 있음

2\) productOptionImageUrl의 개수는 백앤드의 선택

#### Path Parameters

| Name                                        | Type | Description                      |
| ------------------------------------------- | ---- | -------------------------------- |
| productId<mark style="color:red;">\*</mark> | int  | room의 id입니다(product\_option\_id) |

{% tabs %}
{% tab title="200: OK return json data" %}
{% code overflow="wrap" %}

```javascript
{
    "data": [
        {
            "id": 1,
            "name": "레이크뷰",
            "latitude": "37.8855687000",
            "longitude": "127.7301849000",
            "address": "강원도 춘천시 중앙로 1",
            "rooms": [
                {
                    "id": 1,
                    "name": "blue door",
                    "size": 28,
                    "price": 300000,
                    "features": [
                        "주차",
                        "정원",
                        "산책로",
                        "빔프로젝터"
                    ],
                    "amenities": [
                        "TV",
                        "냉장고",
                        "헤어드라이어",
                        "전자레인지",
                        "세면도구",
                        "캡슐커피"
                    ],
                    "checkInTime": "15:00:00.000000",
                    "description": "고요한 호수 속 운치를 만끽할 수 있는 스테이",
                    "checkOutTime": "11:00:00.000000",
                    "numberOfGuests": 2,
                    "productOptionImageUrl": [
                        "https://cdn.pixabay.com/photo/2016/06/24/11/47/architecture-1477100_960_720.jpg",
                        "https://cdn.pixabay.com/photo/2017/08/06/11/22/web-2591485_960_720.jpg"
                    ],
                    "availableProductOptionsId": [
                        "2023-01-01 00:00:00.000000",
                        "2023-01-02 00:00:00.000000",
                        "2023-01-03 00:00:00.000000",
                        "2023-01-04 00:00:00.000000",
                        "2023-01-05 00:00:00.000000",
                        "2023-01-06 00:00:00.000000",
                        "2023-01-07 00:00:00.000000",
                        "2023-01-08 00:00:00.000000",
                        "2023-01-09 00:00:00.000000",
                        "2023-01-10 00:00:00.000000",
                        "2023-01-11 00:00:00.000000",
                        "2023-01-12 00:00:00.000000",
                        "2023-01-13 00:00:00.000000",
                        "2023-01-14 00:00:00.000000"
                    ]
                }
            ]
        }
    ]
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found return json error" %}

```json
{
    "message" : "products not registered"
}
```

{% endtab %}
{% endtabs %}
