---
title: Email
slug: oip-next/s06ihtz6ekewbilzjjvdu
createdAt: 2024-02-21T13:40:05.000Z
---

# Email

## Description

L'entité Email contient la valeur de l'email ainsi que son type.

## Relations

### Ascendantes

| Entité       | Propriété |
| ------------ | --------- |
| ActivePolicy | emails    |
| Company      | emails    |
| Contact      | emails    |
| Customer     | emails    |
| Employee     | emails    |
| Grantee      | emails    |
| Tns          | emails    |
| User         | emails    |

### Descendantes

| Entité  | Propriété |
| ------- | --------- |
| History | history   |

## Liste des propriétés

| Nom       | Type            | Dernière version modifiée | Description                                                    | Getter            | Setter        | Deprecated |
| --------- | --------------- | ------------------------- | -------------------------------------------------------------- | ----------------- | ------------- | ---------- |
| createdAt | `Date`          |                           | Date de création de l'entité `Email`                           | getEmailCreatedAt | Lecture seule | -          |
| createdBy | `String`        |                           | Utilisateur à l'origine de la création de l'entité `Email`     | getEmailCreatedBy | Lecture seule | -          |
| id        | `String`        |                           | Identifiant unique de l'entité `Email`                         | getEmailId        | Lecture seule | -          |
| label     | `String`        |                           | Utile pour nommer et identifier un email particulier.          | getEmailLabel     | setEmailLabel | -          |
| type      | `EmailTypeEnum` | 2.4.0                     | Type de l'email                                                | getEmailType      | setEmailType  | -          |
| updatedAt | `Date`          |                           | Date de modification de l'entité `Email`                       | getEmailUpdatedAt | Lecture seule | -          |
| updatedBy | `String`        |                           | Utilisateur à l'origine de la modification de l'entité `Email` | getEmailUpdatedBy | Lecture seule | -          |
| value     | `String`        | 2.4.0                     | Email, ex:                                                     | getEmailValue     | setEmailValue | -          |

## Enums

### EmailTypeEnum

- `EmailTypeEnum.PERSONAL`
- `EmailTypeEnum.PROFESSIONAL`

## Exemple

```javascript
import { Entities } from '@fasstech/oip-core';
import { getActivePolicyId } from '@fasstech/oip-core/entities/activePolicy';
import { getCompanyId } from '@fasstech/oip-core/entities/company';
import { getEmailLabel, getEmailType, getEmailValue, getemailId, setEmailLabel, setEmailType, setEmailValue } from '@fasstech/oip-core/entities/email';
import { EmailTypeEnum } from '@fasstech/oip-core/entities/email/enums';
import { getProjectId } from '@fasstech/oip-core/entities/project';

(async () => {
  let ProjectEntity = await Entities('Project').get({ id: projectId });
  let CompanyEntity = await Entities('Company').create();
  let ActivePolicyEntity = await Entities('ActivePolicy').create();
  const EmailEntity = await Entities('Email').create();
  
  setEmailLabel('label', EmailEntity);
  setEmailType(EmailTypeEnum.PERSONAL, EmailEntity);
  setEmailValue('value@fasst.io', EmailEntity);
  
  ActivePolicyEntity = await Entities('Email').save(ActivePolicyEntity, EmailEntity);
  CompanyEntity = await Entities('ActivePolicy').save(CompanyEntity, ActivePolicyEntity);
  ProjectEntity = await Entities('Company').save(ProjectEntity, CompanyEntity);
  await Entities('Project').save(ProjectEntity);
  
  const ProjectEntityToTest = await Entities('Project').get({ id: getProjectId(ProjectEntity) });
  const CompanyEntityToTest = await Entities('Company').get(ProjectEntityToTest, getCompanyId(CompanyEntity));
  const ActivePolicyEntityToTest = await Entities('ActivePolicy').get(CompanyEntityToTest, getActivePolicyId(ActivePolicyEntity));
  const EmailEntityToTest = await Entities('Email').get(ActivePolicyEntityToTest, getEmailId(EmailEntity));
  
  getEmailLabel(EmailEntityToTest); // 'label'
  getEmailType(EmailEntityToTest); // EmailTypeEnum.PERSONAL
  getEmailValue(EmailEntityToTest); // 'value@fasst.io'
})();
```
