# Notification Template

Notification template is template message to generate mail body when sending a specific mail for each action.

## Create Notification Template

**Example Request**

```
curl --location '{host}/api/v1/notification-templates/' \
--header 'Authorization: Token {Token}' \
--header 'Content-Type: application/json' \
--data '{
    "notification_type": "quotation_created",
    "subject": "quotation_created",
    "template": "Quotation {{ quotation.name }} ({{ quotation.number }}) created."
}'
```

**Example Response (200 OK)**

```json
{
    "id": 8,
    "notification_type": "quotation_created",
    "subject": "quotation_created",
    "template": "Quotation {{ quotation.name }} ({{ quotation.number }}) created.",
    "created_at": "2024-02-01T14:49:27.613403Z",
    "modified_at": "2024-02-01T14:49:27.614573Z"
}
```

**Example Response (400 Bad Request)**

```json
{
    "notification_type": [
        "notification template with this notification type already exists."
    ]
}
```

## List Notification Templates

**Example Request**

```
curl --location '{host}/api/v1/notification-templates/' \
--header 'Authorization: Token {Token}'
```

**Example Response (200 OK)**

```json
{
    "count": 5,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 8,
            "notification_type": "quotation_created",
            "subject": "quotation_created",
            "template": "Quotation {{ quotation.name }} ({{ quotation.number }}) created.",
            "created_at": "2024-02-01T14:49:27.613403Z",
            "modified_at": "2024-02-01T14:49:27.614573Z"
        },
    ],
    ...
}
```

## Get Single Notification Template

**Example Request**

```
curl --location '{host}/api/v1/notification-templates/1/' \
--header 'Authorization: Token {Token}'
```

**Example Response (200 OK)**

```json
{
    "id": 1,
    "notification_type": "quotation_created1",
    "subject": "quotation_created",
    "template": "quotation_created",
    "created_at": "2023-11-15T14:56:16.835914Z",
    "modified_at": "2023-11-15T14:56:16.835923Z"
}
```

**Example Response (404 Not Found)**

```json
{
    "detail": "Not found."
}
```

## Update Notification Template

**Example Request**

```
curl --location --request GET '{host}/api/v1/notification-templates/8/' \
--header 'Authorization: Token {Token}' \
--header 'Content-Type: application/json' \
--data '{
    "notification_type": "quotation_created",
    "subject": "quotation_created",
    "template": "{{ quotation.number }} {{ quotation.name }} {{ quotation.user.email }} updated"
}'
```

**Example Response (200 OK)**

```json
{
    "id": 8,
    "notification_type": "quotation_created",
    "subject": "quotation_created",
    "template": "Quotation {{ quotation.name }} ({{ quotation.number }}) created.",
    "created_at": "2024-02-01T14:49:27.613403Z",
    "modified_at": "2024-02-01T14:49:27.614573Z"
}
```

## Delete Notification Template

**Example Request**

```
curl --location --request DELETE '{host}/api/v1/notification-templates/8/' \
--header 'Authorization: Token {Token}' \
--header 'Content-Type: application/json' \
--data '{
    "notification_type": "quotation_created",
    "subject": "quotation_created",
    "template": "{{ quotation.number }} {{ quotation.name }} {{ quotation.user.email }} updated"
}'
```

**Example Response (204 No Content)**

`204 No Content`
