# On Site Notifications

## Table of contents

- [Message Types](#Message-Types)
  - [Create](#create)
  - [Update](#update)
  - [Get One](#Get-One)
  - [Get All (Filtered)](#Get-All-Filtered>)
  - [Archive / Unarchive](#Archive--Unarchive)
  - [Duplicate](#Duplicate)

## Message Types

```ts
export enum OnsiteNotificationMessageType {
  DEFAULT = 'DEFAULT',
  IMAGE = 'IMAGE',
}
```

## Create

### Request

```json
{
  "name": "Template name",
  "tags": ["tag 1", "tag 2"],
  "description": "Description of the template",
  "message": {
    "type": "DEFAULT", // OnsiteNotificationMessageType
    "templates": [
      {
        "language": "EN",
        "title": "Some title",
        "text": "Some text with placeholders {{FirstName}}",
        "ctaUrl": ""
      }
    ]
  },
  "createdBy": "angel"
}
```

### Response

```json
{
  "tags": ["tag 1", "tag 2"],
  "name": "Template name",
  "description": "Description of the template",
  "createdAt": "Tue Nov 10 2020 14:34:12 GMT+0000 (GMT)",
  "updatedAt": "Tue Nov 10 2020 14:34:12 GMT+0000 (GMT)",
  "message": {
    "templates": [
      {
        "language": "EN",
        "title": "Some title",
        "text": "Some text with placeholders {{FirstName}}",
        "ctaUrl": ""
      }
    ],
    "type": "DEFAULT"
  },
  "createdBy": "angel",
  "isDeleted": false,
  "_id": "5faaa4e4dac677e3f242600e",
  "__V": 0
}
```

## Update

### Request

```json
{
  "id": "5faaa4e4dac677e3f242600e",
  "name": "Template name updated"
}
```

### Response

```json
{
  "tags": ["tag 1", "tag 2"],
  "name": "Template name updated",
  "description": "Description of the template",
  "createdAt": "Tue Nov 10 2020 14:34:12 GMT+0000 (GMT)",
  "updatedAt": "Tue Nov 10 2020 14:38:41 GMT+0000 (GMT)",
  "message": {
    "templates": [
      {
        "language": "EN",
        "title": "Some title",
        "text": "Some text with placeholders {{FirstName}}",
        "ctaUrl": ""
      }
    ],
    "type": "DEFAULT"
  },
  "createdBy": "angel",
  "isDeleted": false,
  "_id": "5faaa4e4dac677e3f242600e",
  "__V": 0
}
```

## Get One

### Request

```json
{
  "id": "5faaa4e4dac677e3f242600e"
}
```

### Response

```json
{
  "tags": ["tag 1", "tag 2"],
  "name": "Template name updated",
  "description": "Description of the template",
  "createdAt": "Tue Nov 10 2020 14:34:12 GMT+0000 (GMT)",
  "updatedAt": "Tue Nov 10 2020 14:38:41 GMT+0000 (GMT)",
  "message": {
    "templates": [
      {
        "language": "EN",
        "title": "Some title",
        "text": "Some text with placeholders {{FirstName}}",
        "ctaUrl": ""
      }
    ],
    "type": "DEFAULT"
  },
  "createdBy": "angel",
  "isDeleted": false,
  "_id": "5faaa4e4dac677e3f242600e",
  "__V": 0
}
```

## Get All (Filtered)

### Request

```json
// Full request
{
  "language": ["EN"],
  "tags": ["some_tag"],
  "createdBy": ["someUsername"],
  "limit": 10,
  "page": 1,
  "isArchive": false // required
}
```

### Response

```json
{
  "docs": [
    {
      "tags": ["tag 1", "tag 2"],
      "name": "Template name updated",
      "description": "Description of the template",
      "createdAt": "Tue Nov 10 2020 14:34:12 GMT+0000 (GMT)",
      "updatedAt": "Tue Nov 10 2020 14:38:41 GMT+0000 (GMT)",
      "message": {
        "templates": [
          {
            "language": "EN",
            "title": "Some title",
            "text": "Some text with placeholders {{FirstName}}",
            "ctaUrl": ""
          }
        ],
        "type": "DEFAULT"
      },
      "createdBy": "angel",
      "isDeleted": false,
      "_id": "5faaa4e4dac677e3f242600e",
      "__V": 0
    }
  ],
  "total": 7,
  "limit": 25,
  "page": 1,
  "pages": 1
}
```

## Archive / Unarchive

### Request

```json
{
  "id": "5faaa4e4dac677e3f242600e",
  "isDeleted": true
}
```

### Response

```json
{
  "tags": ["tag 1", "tag 2"],
  "name": "Template name updated",
  "description": "Description of the template",
  "createdAt": "Tue Nov 10 2020 14:34:12 GMT+0000 (GMT)",
  "updatedAt": "Tue Nov 10 2020 15:00:50 GMT+0000 (GMT)",
  "message": {
    "templates": [
      {
        "language": "EN",
        "title": "Some title",
        "text": "Some text with placeholders {{FirstName}}",
        "ctaUrl": ""
      }
    ],
    "type": "DEFAULT"
  },
  "createdBy": "angel",
  "isDeleted": true,
  "_id": "5faaa4e4dac677e3f242600e",
  "__V": 0
}
```

## Duplicate

### Request

```json
{
  "id": "5faaa4e4dac677e3f242600e",
  "createdBy": "otherUsername"
}
```

### Response

```json
{
  "tags": ["tag 1", "tag 2"],
  "name": "Template name updated_copy",
  "description": "Description of the template",
  "createdAt": "Tue Nov 10 2020 15:02:50 GMT+0000 (GMT)",
  "updatedAt": "Tue Nov 10 2020 15:02:50 GMT+0000 (GMT)",
  "message": {
    "templates": [
      {
        "language": "EN",
        "title": "Some title",
        "text": "Some text with placeholders {{FirstName}}",
        "ctaUrl": ""
      }
    ],
    "type": "DEFAULT"
  },
  "createdBy": "otherUsername",
  "isDeleted": true,
  "_id": "5faaab9ac7ec98e8d7f4819b",
  "__V": 0
}
```
