# Introduction

## Document model

The document is an entity that has some files (with `type: "document"` and Document's ID as `identifier`) attached to it.

Upon creation, a notification containing a link to the document is sent via specified channel to given recipients (members of Tenant community).

When document is `confirmable`, recipients may need to confirm it. In such case, a `deadline_at` must be specified.
Also, it is possible to configure automated [reminder](doc-341723#documentreminder-model) messages that
are sent to recipients which didn't confirm the document.

### Example

```json
{
    "id": 15,
    "confirmable": true,
    "title": "Fire instructions",
    "description": "Describes how to behave in case of fire",
    "deadline_at": "2020-12-15T15:43:32.000Z",
    "message_channel": "sms",
    "first_reminder": {
        "days_before_deadline": 5,
        "scheduled_at": "2020-12-10T08:00:00.000Z",
        "sent_at": null
    },
    "second_reminder": {
        "days_before_deadline": 2,
        "scheduled_at": "2020-12-13T08:00:00.000Z",
        "sent_at": null
    },
    "created_by": { "entity_type": "token", "entity_id": 491 },
    "created_at": "2020-11-30T17:12:46.435Z",
    "updated_at": "2020-11-30T17:12:46.435Z",
    "recipients_count": 2,
    "recipients_confirmation_status": "some",
    "public_access": true
}
```

### Definition

Key | Type | Optional | Description
--------- | --------- | --------- | ---------
id | integer | no |
confirmable | boolean | no | Is document meant to be confirmed by recipients?
title | string | no |
description | string | no |
deadline_at | datetime | when not confirmable | Time until document is meant to be confirmed by recipients - only for `confirmable` documents
message_channel | enum: `['sms', 'email', 'push']` | no | Channel that the document (and reminders) should be sent with
first_reminder | [DocumentReminder](doc-341723#documentreminder-model) | yes |
second_reminder | [DocumentReminder](doc-341723#documentreminder-model)| yes | Can only be specified after the first reminder
created_by | [API entity](doc-341959#api-entity-json-model) | no | Author of document
created_at | datetime | no | Time of creation
updated_at | datetime | no | Time of last update
recipients_count | integer | no | Number of recipients
recipients_confirmation_status | enum: `['all', 'some', 'none']` | no | Describes how many recipients have confirmed the document
public_access | boolean | no| Document with public access

## DocumentReminder model

### Example

```json
{
    "days_before_deadline": 2,
    "scheduled_at": "2020-12-13T08:00:00.000Z",
    "sent_at": "2020-12-13T08:00:01.540Z"
}
```

### Definition

Key | Type | Optional | Description
--------- | --------- | --------- | ---------
days_before_deadline | integer | no | When the reminder should be sent - number of days before the specified deadline
scheduled_at | datetime | no | Actual calculated time for reminder sending - at 09:00 in the timezone specific for the Loyalty Club
sent_at | datetime | yes | When the reminder has been sent

## DocumentRecipient model

### Example

```json
{
    "id": 44,
    "member_id": 52,
    "last_seen_at": "2020-11-30T17:21:42.350Z",
    "confirmed_at": "2020-11-30T17:21:50.420Z",
    "created_at": "2020-11-30T16:46:28.200Z",
    "updated_at": "2020-11-30T16:46:28.200Z"
}
```

### Definition

Key          | Type     | Optional | Description
---------    | -------- | -------- | ---------
id           | integer  | no       |
member_id    | integer  | no       | ID of MPC member
last_seen_at | datetime | yes      | Last time when the recipient retrieved the Document record
confirmed_at | datetime | yes      | Time of confirmation
created_at   | datetime | no       | Time of creation
updated_at   | datetime | no       | Time of last update