> For the complete documentation index, see [llms.txt](https://verdantjuly.gitbook.io/sansam-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://verdantjuly.gitbook.io/sansam-api/api.md).

# 산삼펫 API

## 회원 가입 / 로그인 API

## 회원 가입 API

<mark style="color:green;">`POST`</mark> `localhost:3000/api/signup`

#### Request Body

| Name                                       | Type   | Description                |
| ------------------------------------------ | ------ | -------------------------- |
| nickname<mark style="color:red;">\*</mark> | string | user nickname              |
| password<mark style="color:red;">\*</mark> | string | password for user nickname |

{% tabs %}
{% tab title="201: Created 회원 가입 성공" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>message:"회원 가입에 성공하였습니다."
}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request 회원 가입 실패 : 중복 닉네임" %}

```json
{
message:"중복된 닉네임입니다."
}
```

{% endtab %}

{% tab title="400: Bad Request 회원 가입 실패 :  닉네임 작성 규칙 미준수" %}

```json
{
message:"닉네임은 최소 3자 이상, 알파벳 대소문자(a~z, A~Z), 숫자(0~9)로 구성해 주세요."
}
```

{% endtab %}

{% tab title="400: Bad Request 회원 가입 실패 : 비밀번호 작성 규칙 미준수" %}

```json
{
message:"비밀번호는 최소 4자 이상입니다."
}
```

{% endtab %}

{% tab title="400: Bad Request 회원 가입 실패 : 비밀번호 !== 비밀번호 확인" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>message:"비밀번호와 비밀번호 확인이 일치하지 않습니다."
}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request 회원 가입 실패 : 미입력" %}

```json
{
message:"미입력된 항목이 있습니다. 모두 입력하여 주세요."
}
```

{% endtab %}
{% endtabs %}

## 로그인 API

<mark style="color:green;">`POST`</mark> `localhost:3000/api/login`

#### Request Body

| Name                                       | Type   | Description                |
| ------------------------------------------ | ------ | -------------------------- |
| nickname<mark style="color:red;">\*</mark> | String | user nickname              |
| password<mark style="color:red;">\*</mark> | String | password for user nickname |

{% tabs %}
{% tab title="200: OK 로그인 성공" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>message:"로그인에 성공하였습니다."
}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request 로그인 실패 " %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>message:"로그인에 실패하였습니다."
}
</code></pre>

{% endtab %}
{% endtabs %}

## 산삼 시터 조회 API

## 산삼 시터 전체 조회 API

<mark style="color:blue;">`GET`</mark> `localhost:3000/api/petsitters`

{% tabs %}
{% tab title="400: Bad Request 산삼 시터 전체 조회 실패" %}

```json
{
    message:"산삼 시터 전체 조회에 실패하였습니다."
}
```

{% endtab %}

{% tab title="200: OK 산삼 시터 전체 조회 성공" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    petsitters
}
</code></pre>

{% endtab %}
{% endtabs %}

## 산삼 시터 개인 조회  API

<mark style="color:blue;">`GET`</mark> `localhost:3000/api/petsitters/:petsitterId`

{% tabs %}
{% tab title="200: OK 산삼 시터 개인 조회 성공" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>petsitter
}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request 산삼 시터 개인 조회 실패" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>message:"산삼 시터 개인 조회에 실패하였습니다."
}
</code></pre>

{% endtab %}
{% endtabs %}

## 예약 CRUD API

## 예약 작성 API

<mark style="color:green;">`POST`</mark> `localhost:3000/api/reservations`

Parmerter : user (req.locals.user)

#### Request Body

| Name                                             | Type     | Description                  |
| ------------------------------------------------ | -------- | ---------------------------- |
| reservationAt<mark style="color:red;">\*</mark>  | datetime | datetime of reservation      |
| petsitter\_id <mark style="color:red;">\*</mark> | String   | petsitter\_id of reservation |

{% tabs %}
{% tab title="201: Created 예약 성공" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    message:"예약에 성공하였습니다."
}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request 예약 실패 " %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong><strong>    message:"예약에 실패하였습니다."
</strong>}
</code></pre>

{% endtab %}
{% endtabs %}

## 예약 전체 조회 API

<mark style="color:blue;">`GET`</mark> `localhost:3000/api/reservations`

Parmerter : user (req.locals.user)

{% tabs %}
{% tab title="200: OK 예약 조회 성공 : 게시물 n개" %}

```json
{ reservations }

```

{% endtab %}

{% tab title="200: OK 예약 조회 성공 : 게시물 0개" %}

<pre class="language-json"><code class="lang-json">{
<strong>    message:"예약이 없습니다. 첫 예약을 진행해 주세요."
</strong>}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request 예약 조회 실패" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    message:"예약 조회에 실패하였습니다."
}
</code></pre>

{% endtab %}
{% endtabs %}

## 예약 수정 API

<mark style="color:purple;">`PATCH`</mark> `localhost:3000/api/reservations`

Parmerter : user (req.locals.user)

Parmerter : reservationId (req.query)

#### Request Body

| Name                                            | Type     | Description                  |
| ----------------------------------------------- | -------- | ---------------------------- |
| reservationAt<mark style="color:red;">\*</mark> | datetime | reservation date             |
| petsitter\_id<mark style="color:red;">\*</mark> | String   | petsitter\_id of reservation |

{% tabs %}
{% tab title="200: OK 예약 수정 성공" %}

```json
{
    message:"예약 수정에 성공하였습니다."
}
```

{% endtab %}

{% tab title="400: Bad Request 예약 수정 실패" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    message:"예약 수정에 실패하였습니다."
}
</code></pre>

{% endtab %}
{% endtabs %}

## 예약 삭제 API

<mark style="color:red;">`DELETE`</mark> `localhost:3000/api/reservations`

Parmerter : user (req.locals.user)

Parmerter : reservationId (req.query)

{% tabs %}
{% tab title="200: OK 예약 삭제 성공" %}

```json
{
    message:"예약 삭제에 성공하였습니다."
}
```

{% endtab %}

{% tab title="400: Bad Request 예약 삭제 실패" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong><strong>    message:"예약 삭제에 실패하였습니다."
</strong>}
</code></pre>

{% endtab %}
{% endtabs %}

## 리뷰 CRUD API

## 리뷰 작성 API

<mark style="color:green;">`POST`</mark> `localhost:3000/api/petsitters/:petsitterId/review`

Parmerter : user (req.locals.user)

Parmerter : petsitterId (req.params)

#### Request Body

| Name                                      | Type   | Description           |
| ----------------------------------------- | ------ | --------------------- |
| content<mark style="color:red;">\*</mark> | string | content of the review |
| star<mark style="color:red;">\*</mark>    | int    | star of the review    |

{% tabs %}
{% tab title="201: Created 리뷰 작성 성공" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    message:"리뷰 작성에 성공하였습니다."
}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request 리뷰 작성 실패 " %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    message:"리뷰 작성에 실패하였습니다."
}
</code></pre>

{% endtab %}
{% endtabs %}

## 리뷰 전체 조회 API

<mark style="color:blue;">`GET`</mark> `localhost:3000/api/petsitters/:petsitterId/reviews`

Parmerter : user (req.locals.user)

Parmerter : petsitterId (req.params)

{% tabs %}
{% tab title="200: OK 리뷰 조회 성공 : 댓글 n개" %}

```json
{
    reviews
}
```

{% endtab %}

{% tab title="200: OK 리뷰 조회 성공 : 댓글 0개" %}

<pre class="language-json"><code class="lang-json">{
<strong>    message:"리뷰가 없습니다. 첫 작성자가 되어 주세요."
</strong>}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request 리뷰 조회 실패" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    message:"리뷰 조회에 실패하였습니다."
}
</code></pre>

{% endtab %}
{% endtabs %}

## 리뷰 수정 API

<mark style="color:purple;">`PATCH`</mark> `localhost:3000/api/petsitters/:petsitterId/review`

Parmerter : user (req.locals.user)

Parmerter : petsitterId (req.params)

Parmeter : reviewId(req.query)

#### Request Body

| Name                                      | Type   | Description            |
| ----------------------------------------- | ------ | ---------------------- |
| content<mark style="color:red;">\*</mark> | String | content of the comment |

{% tabs %}
{% tab title="200: OK 리뷰 수정 성공" %}

```json
{
    message:"리뷰 수정에 성공하였습니다."
}
```

{% endtab %}

{% tab title="400: Bad Request 리뷰 수정 실패" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    message:"리뷰 수정에 실패하였습니다."
}
</code></pre>

{% endtab %}
{% endtabs %}

## 리뷰 삭제 API

<mark style="color:red;">`DELETE`</mark> `localhost:3000/api/petsitters/:petsitterId/review`

Parmerter : user (req.locals.user)

Parmerter : petsitterId (req.params)

Parmeter : reviewId(req.query)

{% tabs %}
{% tab title="200: OK 리뷰 삭제 성공" %}

<pre class="language-json"><code class="lang-json">{
<strong>    message:"리뷰 삭제에 성공하였습니다."
</strong>}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request 리뷰 삭제 실패" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    message:"리뷰 삭제에 실패하였습니다."
}
</code></pre>

{% endtab %}
{% endtabs %}
