# crm-gateway

> # CRM Templates

Latest version **2.4.2** (published 2021-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install crm-gateway
pnpm add crm-gateway
yarn add crm-gateway
bun add crm-gateway
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.2 |
| Published | 2021-05-10 |
| First published | 2021-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 30 |
| Unpacked size | 235.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jorge.chavarria |

## Links

- npm: https://www.npmjs.com/package/crm-gateway
- npm.io page: https://npm.io/package/crm-gateway

## Dependencies (30)

- [i](https://npm.io/package/i.md) ^0.3.6
- [qs](https://npm.io/package/qs.md) ^6.9.4
- [grpc](https://npm.io/package/grpc.md) ^1.24.2
- [rxjs](https://npm.io/package/rxjs.md) ^6.5.4
- [uuid](https://npm.io/package/uuid.md) ^3.4.0
- [colors](https://npm.io/package/colors.md) ^1.4.0
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.2
- [iterare](https://npm.io/package/iterare.md) ^1.2.1
- [mongoose](https://npm.io/package/mongoose.md) ^5.8.6
- [@nestjs/core](https://npm.io/package/@nestjs/core.md) ^7.5.5
- [cli-progress](https://npm.io/package/cli-progress.md) ^3.8.2
- [html-entities](https://npm.io/package/html-entities.md) ^1.2.1
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) ^7.6.5
- [@nestjs/config](https://npm.io/package/@nestjs/config.md) ^0.6.3
- [@sendgrid/mail](https://npm.io/package/@sendgrid/mail.md) ^7.2.2
- [moment-timezone](https://npm.io/package/moment-timezone.md) ^0.5.32
- [@nestjs/mongoose](https://npm.io/package/@nestjs/mongoose.md) ^7.1.2
- [@nestjs/schedule](https://npm.io/package/@nestjs/schedule.md) ^0.3.1
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.12
- [class-transformer](https://npm.io/package/class-transformer.md) ^0.2.3
- [mongoose-paginate](https://npm.io/package/mongoose-paginate.md) ^5.0.3
- [@grpc/proto-loader](https://npm.io/package/@grpc/proto-loader.md) ^0.5.4
- [@nestjs/microservices](https://npm.io/package/@nestjs/microservices.md) ^7.6.5
- [@gamingenius/crm-types](https://npm.io/package/@gamingenius/crm-types.md) ^5.9.0
- [@gamingenius/nest-grpc](https://npm.io/package/@gamingenius/nest-grpc.md) ^4.6.0
- [@nestjs/platform-express](https://npm.io/package/@nestjs/platform-express.md) ^7.5.5
- [@gamingenius/http-responses](https://npm.io/package/@gamingenius/http-responses.md) ^1.3.0
- [@gamingenius/class-validator](https://npm.io/package/@gamingenius/class-validator.md) ^1.1.2
- [@gamingenius/nest-error-handler](https://npm.io/package/@gamingenius/nest-error-handler.md) ^3.0.1

## Recent versions

- 2.4.2 (latest) — 2021-05-10

## README

# ![image](https://gamanza.com/wp-content/uploads/2019/04/Gamanza-black_bold.png)

# CRM Templates

## [On Site Notifications](./docs/onsite-notifications.md)

## Table of contents

- [Description](#description)
- [Technologies](#technologies)
- [Setup](#setup)
- [Features](#features)
- [Status](#status)
- [gRPC Integration](#grpc-integration)
  - [Email Templates](#email-templates)
  - [Create a template](#create-a-template)
  - [Get all templates](#get-all-templates)
  - [Get template by ID](#get-template-by-id)
  - [Get templates by filter](#get-templates-by-filter)
  - [Get templates with page param](#get-templates-with-page-param)
  - [Get templates with page and limit params](#get-templates-with-page-and-limit-params)
  - [Update a template](update-a-template)
- [Sender](#sender)
  - [Send Campaigns](#send-campaigns)
  - [Sendgrid example](#Sendgrid-example)
  - [Send Email](#Send-a-Test-Email-Directly)
  - [Send Invite Friends Campaign](#Send-Invite-Friends-Email-Campaign)
- [Template Sms](#Template-Sms)
  - [Create a template](#Create-a-template-sms)
  - [Get a template](#Get-a-template-sms)
  - [Get templates name](#Get-templates-name-sms)
  - [Get all template with page and limit params](#Get-all-template-sms)
  - [Update a template](#Update-a-template-sms)
  - [Duplicate a template](#Duplicate-a-template-sms)
- [Sender Sms](#Sender-Sms)
  - [Send Custom Message](#Send-Custom-Message)
  - [Send Test Template Message](#Send-Test-Template-Message)
  - [Send Campaign Message](#Send-Campaign-Message)
- [Rules Engine Sender](#Rules-Engine-Sender)
- [Contact](#contact)

## Description

The **CRM Message Gateway** is responsable for the CRUD of SMS and Email templates, also for sending SMS and Emails from the Campaign Gateway.

## Technologies

- TypeScript - version 3.8.3
- NestJS - version 6.10.14
- Mongoose - version 6.1.2
- gRPC- version 1.24.2

## Setup

Install the dependencies

```bash
$ npm install
```

Create a .env file in the root of the project and add the following lines

> The values of these variables are in [here](https://gamanza-group.atlassian.net/wiki/spaces/C/pages/883785902/Setup).

```bash
# RABBITMQ CONFIG VALUES
RABBITMQ_QUEUE=""
RABBITMQ_EXCHANGE_RESPONSE=""
RABBITMQ_CONNECTION=""

# DB
DB_HOST=""

# Timezone
TZ="utc"

# EMAIL SENDER
UNSUBSCRIBE_URL=""
```

Run the project

```bash
*# development*
$ npm run start

*# watch mode*
$ npm run start:dev

*# production mode*
$ npm run start:prod
```

## Features

- Full CRUD Operations for managing templates
- Send direct email

## Status

Project is: _*in progress*_ because we are still developing the gRPC communication layer

## Documentation

[See documentation on Confluence](https://gamanza-group.atlassian.net/wiki/spaces/C/pages/883261459/Message+Gateway+-+Documentation)

## gRPC Integration

## gRPC Request & Responses

Examples of gRCP request

### Email Templates

#### Create a template

```json
{
  "name": "Welcome Campaign",
  "description": "Welcoming for new registered users.",
  "createdBy": "juan.blanco",
  "companyId": "5dc098efe13604f521bcb6b2",
  "fromEmail": "example@gamanza.com",
  "fromName": "Gamanza Team",
  "replyTo": "no-reply@gamanza.com",
  "bcc": ["____ANY_EMAIL____", "____ANOTHER_EMAIL____"], // Blind Carbon Copy
  "creationMode": "visual", // visual || code
  "tags": ["tag1", "tag2"],
  "templates": [
    {
      "language": "EN",
      "contentHtml": "<h1>Testing1</h1><p>In esse nostrud tempor est pariatur esse.</p>",
      "subject": "Testing 1 (EN)",
      "previewText": "any string",
      "blocks": [
        {
          "type": "SPACE"
        },
        {
          "type": "DIVIDER"
        }
      ]
    },
    {
      "language": "ES",
      "contentHtml": "<h1>Probando1</h1><p>In esse nostrud tempor est pariatur esse.</p>",
      "subject": "Probando 1 (ES)",
      "previewText": "any string",
      "blocks": [
        {
          "type": "HERO_IMAGE",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "TITLE",
          "title": "HTML content"
        },
        {
          "type": "TITLE_PARAGRAPH_BUTTON",
          "title": "title content",
          "buttonLabel": "button label",
          "paragraph": "paragraph content"
        },
        {
          "type": "SUBTITLE",
          "subtitle": "subtitle content"
        },
        {
          "type": "PARAGRAPH",
          "paragraph": "HTML content"
        },
        {
          "type": "BUTTON",
          "buttonLabel": "button label",
          "buttonLink": "http://link.com",
          "buttonType": 1
        },
        {
          "type": "IMAGE",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "TWO_IMAGES",
          "imageLeftUrl": "http://ho.com",
          "imageLeftAlt": "string",
          "imageLeftLink": "http://hosdf.com",
          "imageRightLink": "http://sdfsf.com",
          "imageRightUrl": "http://ho.com",
          "imageRightAlt": "string"
        },
        {
          "type": "FOUR_IMAGES",
          "imageOneUrl": "http://hod.com",
          "imageOneAlt": "string",
          "imageTwoUrl": "http://dfs.com",
          "imageTwoAlt": "string",
          "imageThreeUrl": "http://hosd.com",
          "imageThreeAlt": "string",
          "imageFourUrl": "http://sdfd.com",
          "imageFourAlt": "string",
          "imageOneLink": "http://dfdfd.com",
          "imageThreeLink": "http://fdfdfd.com",
          "imageTwoLink": "http://sdfdfd.com",
          "imageFourLink": "http://sdfdfd.com"
        },
        {
          "type": "FOUR_IMAGES_BUTTONS",
          "imageOneUrl": "http://sdfdfd.com",
          "imageOneAlt": "string",
          "buttonOneLabel": "string",
          "buttonOneLink": "http://sdfdfd.com",
          "imageTwoUrl": "http://sdfdfd.com",
          "imageTwoAlt": "string",
          "buttonTwoLabel": "string",
          "buttonTwoLink": "http://sdfdfd.com",
          "imageThreeUrl": "http://sdfdfd.com",
          "imageThreeAlt": "string",
          "buttonThreeLabel": "string",
          "buttonThreeLink": "http://sdfdfd.com",
          "imageFourUrl": "http://sdfdfd.com",
          "imageFourAlt": "string",
          "buttonFourLabel": "string",
          "buttonFourLink": "http://sdfdfd.com",
          "imageOneLink": "http://sdfdfd.com",
          "imageTwoLink": "http://sdfdfd.com",
          "imageThreeLink": "http://sdfdfd.com",
          "imageFourLink": "http://sdfdfd.com"
        },
        {
          "type": "TITLE_PARAGRAPH",
          "title": "title content",
          "paragraph": "paragraph content"
        },
        {
          "type": "IMAGE_LEFT_TITLE_PARAGRAPH_BUTTON",
          "title": "title content",
          "paragraph": "paragraph content",
          "buttonLabel": "button label",
          "buttonLink": "http://link.com",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "IMAGE_RIGHT_TITLE_PARAGRAPH_BUTTON",
          "title": "title content",
          "paragraph": "paragraph content",
          "buttonLabel": "button label",
          "buttonLink": "http://link.com",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "IMAGE_LEFT_TITLE_PARAGRAPH",
          "title": "title content",
          "paragraph": "paragraph content",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "IMAGE_RIGHT_TITLE_PARAGRAPH",
          "title": "title content",
          "paragraph": "paragraph content",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "IMAGES_TITLE_PARAGRAPH_BUTTON",
          "titleLeft": "string",
          "paragraphLeft": "string",
          "buttonLeftLabel": "string",
          "buttonLeftLink": "http://link.com",
          "imageLeftUrl": "http://link.com",
          "imageLeftAlt": "string",
          "imageLeftLink": "http://link.com",
          "titleRight": "string",
          "paragraphRight": "string",
          "buttonRightLabel": "string",
          "buttonRightLink": "http://link.com",
          "imageRightUrl": "http://link.com",
          "imageRightAlt": "string",
          "imageRightLink": "http://link.com"
        },
        {
          "type": "CUSTOM_NAV_1",
          "nav": "nav content",
          "imageAlt": "image alt",
          "imageLink": "http://link.com",
          "imageUrl": "http://link.com",
          "description": "description sksfd",
          "buttonLink": "http://link.com"
        },
        {
          "type": "CUSTOM_HEADER_1",
          "imageAlt": "image alt",
          "imageLink": "http://link.com"
        },
        {
          "type": "CUSTOM_HEADER_2",
          "imageAlt": "image alt",
          "imageLink": "http://link.com",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_FOOTER_1",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_FOOTER_2",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_SIGN",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_TERMS",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_SOCIAL_MEDIA",
          "nav": "tomela"
        },
        {
          "type": "CUSTOM_SMALL_IMAGE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_BULLET_PARAGRAPH_BUTTON",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_CARD_1",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_CARD_2",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_CARD_ICON_1",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_CARD_ICON_2",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_DIVIDER"
        },
        {
          "type": "CUSTOM_DIVIDER_PARAGRAPH"
        },
        {
          "type": "SPACE"
        },
        {
          "type": "DIVIDER"
        },
        {
          "type": "CENTER_IMAGE",
          "imageUrl": "http://image-source.com",
          "imageAlt": "image alt",
          "imageLink": "http://image-link.com"
        },
        {
          "type": "THREE_IMAGES",
          "imageOneUrl": "http://image-source.com",
          "imageOneAlt": "image alt",
          "imageOneLink": "http://image-link.com",
          "imageTwoUrl": "http://image-source.com",
          "imageTwoAlt": "image alt",
          "imageTwoLink": "http://image-link.com",
          "imageThreeUrl": "http://image-source.com",
          "imageThreeAlt": "image alt",
          "imageThreeLink": "http://image-link.com"
        },
        {
          "type": "THREE_IMAGES_BUTTONS",
          "imageOneUrl": "http://image-source.com",
          "imageOneAlt": "image alt",
          "imageOneLink": "http://image-link.com",
          "imageTwoUrl": "http://image-source.com",
          "imageTwoAlt": "image alt",
          "imageTwoLink": "http://image-link.com",
          "imageThreeUrl": "http://image-source.com",
          "imageThreeAlt": "image alt",
          "imageThreeLink": "http://image-link.com",
          "buttonOneLabel": "button label",
          "buttonOneLink": "http://button-link.com",
          "buttonTwoLabel": "button label",
          "buttonTwoLink": "http://button-link.com",
          "buttonThreeLabel": "button label",
          "buttonThreeLink": "http://button-link.com"
        },
        {
          "type": "CUSTOM_SMALL_IMAGE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_MEDIUM_IMAGE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_BIG_IMAGE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_SMALL_IMAGE_TITLE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_MEDIUM_IMAGE_TITLE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_BIG_IMAGE_TITLE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_TITLE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_IMAGE_DIVIDER_TITLE_PARAGRAPH_DIVIDER",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_PARAGRAPH_BUTTON_PARAGRAPH",
          "title": "any other property from custom block",
          "subtitle": "this is the subtitle",

          "imageUrl": "http://image-source.com",
          "imageAlt": "image alt",
          "imageLink": "http://image-link.com",

          "buttonLabel": "button label",
          "buttonLink": "http://example.com",
          "nav": "this is the nav",

          "description": "this is the description",
          "descriptionTwo": "this is the description",
          "descriptionThree": "this is the description",
          "descriptionFour": "this is the description",
          "descriptionFive": "this is the description",
          "descriptionSix": "this is the description",

          "imageOneUrl": "http://image-source.com",
          "imageOneAlt": "image alt",
          "imageOneLink": "http://image-link.com",

          "imageTwoUrl": "http://image-source.com",
          "imageTwoAlt": "image alt",
          "imageTwoLink": "http://image-link.com",

          "imageThreeUrl": "http://image-source.com",
          "imageThreeAlt": "image alt",
          "imageThreeLink": "http://image-link.com",

          "imageFourUrl": "http://image-source.com",
          "imageFourAlt": "image alt",
          "imageFourLink": "http://image-link.com",

          "imageFiveUrl": "http://image-source.com",
          "imageFiveAlt": "image alt",
          "imageFiveLink": "http://image-link.com",

          "imageSixUrl": "http://image-source.com",
          "imageSixAlt": "image alt",
          "imageSixLink": "http://image-link.com"
        },
        {
          "type": "CUSTOM_BULLETS",
          "title": "any other property from custom block",
          "bullets": [
            {
              "paragraph": "paragraph is required",
              "imageUrl": "http://image-source.com",
              "imageAlt": "image alt",
              "imageLink": "http://image-link.com"
            }
          ]
        }
      ]
    }
  ]
}
```

#### Response

```json
{
  "_id": "5f4d439f44e70e10ed4b67f0",
  "name": "Welcome Campaign",
  "description": "Welcoming for new registered users.",
  "createdBy": "juan.celeste",
  "companyId": "5da773139fbffffe3e7417ca",
  "fromEmail": "example@gamanza.com",
  "fromName": "Gamanza Team",
  "replyTo": "no-reply@gamanza.com",
  "creationMode": "visual",
  "tags": ["tag1", "tag2"],
  "templates": [
    {
      "language": "EN",
      "contentHtml": "<h1>Testing1</h1><p>In esse nostrud tempor est pariatur esse.</p>",
      "subject": "Testing 1 (EN)",
      "previewText": "any string",
      "blocks": [
        {
          "type": "SPACE"
        },
        {
          "type": "DIVIDER"
        }
      ]
    },
    {
      "language": "ES",
      "contentHtml": "<h1>Probando1</h1><p>In esse nostrud tempor est pariatur esse.</p>",
      "subject": "Probando 1 (ES)",
      "previewText": "any string",
      "blocks": [
        {
          "type": "HERO_IMAGE",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "TITLE",
          "title": "HTML content"
        },
        {
          "type": "TITLE_PARAGRAPH_BUTTON",
          "title": "title content",
          "buttonLabel": "button label",
          "paragraph": "paragraph content"
        },
        {
          "type": "SUBTITLE",
          "subtitle": "subtitle content"
        },
        {
          "type": "PARAGRAPH",
          "paragraph": "HTML content"
        },
        {
          "type": "BUTTON",
          "buttonLabel": "button label",
          "buttonLink": "http://link.com",
          "buttonType": 1
        },
        {
          "type": "IMAGE",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "TWO_IMAGES",
          "imageLeftUrl": "http://ho.com",
          "imageLeftAlt": "string",
          "imageLeftLink": "http://hosdf.com",
          "imageRightLink": "http://sdfsf.com",
          "imageRightUrl": "http://ho.com",
          "imageRightAlt": "string"
        },
        {
          "type": "FOUR_IMAGES",
          "imageOneUrl": "http://hod.com",
          "imageOneAlt": "string",
          "imageTwoUrl": "http://dfs.com",
          "imageTwoAlt": "string",
          "imageThreeUrl": "http://hosd.com",
          "imageThreeAlt": "string",
          "imageFourUrl": "http://sdfd.com",
          "imageFourAlt": "string",
          "imageOneLink": "http://dfdfd.com",
          "imageThreeLink": "http://fdfdfd.com",
          "imageTwoLink": "http://sdfdfd.com",
          "imageFourLink": "http://sdfdfd.com"
        },
        {
          "type": "FOUR_IMAGES_BUTTONS",
          "imageOneUrl": "http://sdfdfd.com",
          "imageOneAlt": "string",
          "buttonOneLabel": "string",
          "buttonOneLink": "http://sdfdfd.com",
          "imageTwoUrl": "http://sdfdfd.com",
          "imageTwoAlt": "string",
          "buttonTwoLabel": "string",
          "buttonTwoLink": "http://sdfdfd.com",
          "imageThreeUrl": "http://sdfdfd.com",
          "imageThreeAlt": "string",
          "buttonThreeLabel": "string",
          "buttonThreeLink": "http://sdfdfd.com",
          "imageFourUrl": "http://sdfdfd.com",
          "imageFourAlt": "string",
          "buttonFourLabel": "string",
          "buttonFourLink": "http://sdfdfd.com",
          "imageOneLink": "http://sdfdfd.com",
          "imageTwoLink": "http://sdfdfd.com",
          "imageThreeLink": "http://sdfdfd.com",
          "imageFourLink": "http://sdfdfd.com"
        },
        {
          "type": "TITLE_PARAGRAPH",
          "title": "title content",
          "paragraph": "paragraph content"
        },
        {
          "type": "IMAGE_LEFT_TITLE_PARAGRAPH_BUTTON",
          "title": "title content",
          "paragraph": "paragraph content",
          "buttonLabel": "button label",
          "buttonLink": "http://link.com",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "IMAGE_RIGHT_TITLE_PARAGRAPH_BUTTON",
          "title": "title content",
          "paragraph": "paragraph content",
          "buttonLabel": "button label",
          "buttonLink": "http://link.com",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "IMAGE_LEFT_TITLE_PARAGRAPH",
          "title": "title content",
          "paragraph": "paragraph content",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "IMAGE_RIGHT_TITLE_PARAGRAPH",
          "title": "title content",
          "paragraph": "paragraph content",
          "imageUrl": "http://link.com",
          "imageAlt": "string",
          "imageLink": "http://link.com"
        },
        {
          "type": "IMAGES_TITLE_PARAGRAPH_BUTTON",
          "titleLeft": "string",
          "paragraphLeft": "string",
          "buttonLeftLabel": "string",
          "buttonLeftLink": "http://link.com",
          "imageLeftUrl": "http://link.com",
          "imageLeftAlt": "string",
          "imageLeftLink": "http://link.com",
          "titleRight": "string",
          "paragraphRight": "string",
          "buttonRightLabel": "string",
          "buttonRightLink": "http://link.com",
          "imageRightUrl": "http://link.com",
          "imageRightAlt": "string",
          "imageRightLink": "http://link.com"
        },
        {
          "type": "CUSTOM_NAV_1",
          "nav": "nav content",
          "imageAlt": "image alt",
          "imageLink": "http://link.com",
          "imageUrl": "http://link.com",
          "description": "description sksfd",
          "buttonLink": "http://link.com"
        },
        {
          "type": "CUSTOM_HEADER_1",
          "imageAlt": "image alt",
          "imageLink": "http://link.com"
        },
        {
          "type": "CUSTOM_HEADER_2",
          "imageAlt": "image alt",
          "imageLink": "http://link.com",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_FOOTER_1",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_FOOTER_2",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_SIGN",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_TERMS",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_SOCIAL_MEDIA",
          "nav": "tomela"
        },
        {
          "type": "CUSTOM_SMALL_IMAGE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_BULLET_PARAGRAPH_BUTTON",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_CARD_1",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_CARD_2",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_CARD_ICON_1",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_CARD_ICON_2",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_DIVIDER"
        },
        {
          "type": "CUSTOM_DIVIDER_PARAGRAPH"
        },
        {
          "type": "SPACE"
        },
        {
          "type": "DIVIDER"
        },
        {
          "type": "CENTER_IMAGE",
          "imageUrl": "http://image-source.com",
          "imageAlt": "image alt",
          "imageLink": "http://image-link.com"
        },
        {
          "type": "THREE_IMAGES",
          "imageOneUrl": "http://image-source.com",
          "imageOneAlt": "image alt",
          "imageOneLink": "http://image-link.com",
          "imageTwoUrl": "http://image-source.com",
          "imageTwoAlt": "image alt",
          "imageTwoLink": "http://image-link.com",
          "imageThreeUrl": "http://image-source.com",
          "imageThreeAlt": "image alt",
          "imageThreeLink": "http://image-link.com"
        },
        {
          "type": "THREE_IMAGES_BUTTONS",
          "imageOneUrl": "http://image-source.com",
          "imageOneAlt": "image alt",
          "imageOneLink": "http://image-link.com",
          "imageTwoUrl": "http://image-source.com",
          "imageTwoAlt": "image alt",
          "imageTwoLink": "http://image-link.com",
          "imageThreeUrl": "http://image-source.com",
          "imageThreeAlt": "image alt",
          "imageThreeLink": "http://image-link.com",
          "buttonOneLabel": "button label",
          "buttonOneLink": "http://button-link.com",
          "buttonTwoLabel": "button label",
          "buttonTwoLink": "http://button-link.com",
          "buttonThreeLabel": "button label",
          "buttonThreeLink": "http://button-link.com"
        },
        {
          "type": "CUSTOM_SMALL_IMAGE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_MEDIUM_IMAGE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_BIG_IMAGE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_SMALL_IMAGE_TITLE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_MEDIUM_IMAGE_TITLE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_BIG_IMAGE_TITLE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_TITLE_PARAGRAPH",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_IMAGE_DIVIDER_TITLE_PARAGRAPH_DIVIDER",
          "title": "any other property from custom block"
        },
        {
          "type": "CUSTOM_PARAGRAPH_BUTTON_PARAGRAPH",
          "title": "any other property from custom block",
          "subtitle": "this is the subtitle",

          "imageUrl": "http://image-source.com",
          "imageAlt": "image alt",
          "imageLink": "http://image-link.com",

          "buttonLabel": "button label",
          "buttonLink": "http://example.com",
          "nav": "this is the nav",

          "description": "this is the description",
          "descriptionTwo": "this is the description",
          "descriptionThree": "this is the description",
          "descriptionFour": "this is the description",
          "descriptionFive": "this is the description",
          "descriptionSix": "this is the description",

          "imageOneUrl": "http://image-source.com",
          "imageOneAlt": "image alt",
          "imageOneLink": "http://image-link.com",

          "imageTwoUrl": "http://image-source.com",
          "imageTwoAlt": "image alt",
          "imageTwoLink": "http://image-link.com",

          "imageThreeUrl": "http://image-source.com",
          "imageThreeAlt": "image alt",
          "imageThreeLink": "http://image-link.com",

          "imageFourUrl": "http://image-source.com",
          "imageFourAlt": "image alt",
          "imageFourLink": "http://image-link.com",

          "imageFiveUrl": "http://image-source.com",
          "imageFiveAlt": "image alt",
          "imageFiveLink": "http://image-link.com",

          "imageSixUrl": "http://image-source.com",
          "imageSixAlt": "image alt",
          "imageSixLink": "http://image-link.com"
        },
        {
          "type": "CUSTOM_BULLETS",
          "title": "any other property from custom block",
          "bullets": [
            {
              "paragraph": "paragraph is required",
              "imageUrl": "http://image-source.com",
              "imageAlt": "image alt",
              "imageLink": "http://image-link.com"
            }
          ]
        }
      ]
    }
  ],
  "isDeleted": false,
  "active": true,
  "createdAt": "Mon Aug 31 2020 18:38:23 GMT+0000 (GMT)",
  "updatedAt": "Mon Aug 31 2020 18:38:23 GMT+0000 (GMT)"
}
```

#### Get all templates

> Only isArchive is required.

```json
{
  "isArchive": false
}
```

#### Response

```json
{
  "docs": [
    {
      "active": true,
      "isDeleted": false,
      "_id": "5e3d8011a8989a3b7901a396",
      "name": "Welcome Campaign",
      "description": "Welcoming for new registered users.",
      "createdBy": "juan.blanco",
      "companyId": "5dc098efe13604f521bcb6b2",
      "fromEmail": "example@gamanza.com",
      "fromName": "Gamanza Team",
      "replyTo": "no-reply@gamanza.com",
      "bcc": ["example@test.com", "example2@test.com"],
      "creationMode": "code",
      "templates": [
        {
          "_id": "5e3d8011a8989a3b7901a397",
          "subject": "Bienvenido!",
          "language": "ES",
          "contentHtml": "<h4>Hola {{FirstName}} {{LastName}}</h4> <p>Que gusto nos da tenerte aqui!</p>"
        },
        {
          "_id": "5e3d8011a8989a3b7901a398",
          "subject": "Welcome!",
          "language": "EN",
          "contentHtml": "<h4>Hello {{FirstName}} {{LastName}}</h4> <p>It is a pleasure having you here. </p>"
        }
      ],
      "createdAt": "2020-02-07T15:19:45.035Z",
      "updatedAt": "2020-02-07T15:19:45.035Z",
      "__v": 0
    }
  ],
  "total": 1,
  "limit": 25,
  "page": 1,
  "pages": 1
}
```

#### Get template by Id

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

#### Response

```json
{
  "active": true,
  "isDeleted": false,
  "_id": "5e3d8011a8989a3b7901a396",
  "name": "Welcome Campaign",
  "description": "Welcoming for new registered users.",
  "createdBy": "juan.blanco",
  "companyId": "5dc098efe13604f521bcb6b2",
  "fromEmail": "example@gamanza.com",
  "fromName": "Gamanza Team",
  "replyTo": "no-reply@gamanza.com",
  "bcc": ["example@test.com", "example2@test.com"], // Blind Carbon Copy
  "creationMode": "code",
  "templates": [
    {
      "_id": "5e3d8011a8989a3b7901a397",
      "subject": "Bienvenido!",
      "language": "ES",
      "contentHtml": "<h4>Hola {{FirstName}} {{LastName}}</h4> <p>Que gusto nos da tenerte aqui!</p>"
    },
    {
      "_id": "5e3d8011a8989a3b7901a398",
      "subject": "Welcome!",
      "language": "EN",
      "contentHtml": "<h4>Hello {{FirstName}} {{LastName}}</h4> <p>It is a pleasure having you here. </p>"
    }
  ],
  "createdAt": "2020-02-07T15:19:45.035Z",
  "updatedAt": "2020-02-07T15:19:45.035Z",
  "__v": 0
}
```

#### Get Templates name and ID by companyID

```json
{
  "companyId": "5df958506e4f7e5cac6f847f"
}
```

#### Response

```json
{
  "docs": [
    {
      "_id": "5e56f0b0ded5283d1c70a8c8",
      "name": "Welcome Campaign3"
    },
    {
      "_id": "5e56f162ded5283d1c70a8ce",
      "name": "Welcome Campaign"
    },
    {
      "_id": "5e56f16eded5283d1c70a8d1",
      "name": "Welcome Campaign2"
    }
  ]
}
```

#### Get template languages by Id

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

#### Response

```json
{
  "languages": ["ES", "EN"]
}
```

#### Get templates by filter

> Only isArchive is required.
> You can choose either non archive or archive templates just passing isArchive value
> lenguaje, createdBy and company are arrays of values
> searchParam (name and description)

```json
{
  "isArchive": false,
  "limit": 10,
  "page": 1,
  "searchParam": "wel",
  "createdBy": ["juan.blanco"],
  "companyId": ["5dc098efe13604f521bcb6b2"],
  "subject": "test",
  "language": ["ES"]
}
```

#### Response

```json
{
  "docs": [
    {
      "active": true,
      "isDeleted": false,
      "_id": "5e3d8011a8989a3b7901a396",
      "name": "Welcome Campaign",
      "description": "Welcoming for new registered users.",
      "createdBy": "juan.blanco",
      "companyId": "5dc098efe13604f521bcb6b2",
      "fromEmail": "example@gamanza.com",
      "fromName": "Gamanza Team",
      "replyTo": "no-reply@gamanza.com",
      "bcc": ["example@test.com", "example2@test.com"],
      "creationMode": "code",
      "templates": [
        {
          "_id": "5e3d8011a8989a3b7901a397",
          "subject": "Bienvenido!",
          "language": "ES",
          "contentHtml": "<h4>Hola {{FirstName}} {{LastName}}</h4> <p>Que gusto nos da tenerte aqui!</p>"
        },
        {
          "_id": "5e3d8011a8989a3b7901a398",
          "subject": "Welcome!",
          "language": "EN",
          "contentHtml": "<h4>Hello {{FirstName}} {{LastName}}</h4> <p>It is a pleasure having you here. </p>"
        }
      ],
      "createdAt": "2020-02-07T15:19:45.035Z",
      "updatedAt": "2020-02-07T15:19:45.035Z",
      "__v": 0
    }
  ],
  "total": 1,
  "limit": 10,
  "page": 1,
  "pages": 1
}
```

#### Get templates with `page` param

```json
{
  "page": 2
}
```

#### Get templates with `page` and `limit` params

```json
{
  "page": 1,
  "limit": 50
}
```

#### Response

```json
{
  "docs": [
    {
      "active": true,
      "isDeleted": false,
      "_id": "5e3d8011a8989a3b7901a396",
      "name": "Welcome Campaign",
      "description": "Welcoming for new registered users.",
      "createdBy": "juan.blanco",
      "companyId": "5dc098efe13604f521bcb6b2",
      "fromEmail": "example@gamanza.com",
      "fromName": "Gamanza Team",
      "replyTo": "no-reply@gamanza.com",
      "bcc": ["example@test.com", "example2@test.com"],
      "creationMode": "code",
      "templates": [
        {
          "_id": "5e3d8011a8989a3b7901a397",
          "subject": "Bienvenido!",
          "language": "ES",
          "contentHtml": "<h4>Hola {{FirstName}} {{LastName}}</h4> <p>Que gusto nos da tenerte aqui!</p>"
        },
        {
          "_id": "5e3d8011a8989a3b7901a398",
          "subject": "Welcome!",
          "language": "EN",
          "contentHtml": "<h4>Hello {{FirstName}} {{LastName}}</h4> <p>It is a pleasure having you here. </p>"
        }
      ],
      "createdAt": "2020-02-07T15:19:45.035Z",
      "updatedAt": "2020-02-07T15:19:45.035Z",
      "__v": 0
    }
  ],
  "total": 1,
  "limit": 50,
  "page": 1,
  "pages": 1
}
```

#### Update a template

You can update any property of the template, only `id` is required.

```json
{
  "id": "5dc0944ffce6a5da9c67e845",
  "name": "New Promo Code"
}
```

#### Response

```json
{
  "templates": [
    {
      "language": "ES",
      "contentHtml": "<h4>Hola {{FirstName}} {{LastName}}</h4> <p>Que gusto nos da tenerte aqui!</p>",
      "subject": "Bienvenido!"
    },
    {
      "language": "EN",
      "contentHtml": "<h4>Hello {{FirstName}} {{LastName}}</h4> <p>It is a pleasure having you here. </p>",
      "subject": "Welcome!"
    }
  ],
  "_id": "5e94d22f0904b549d52b09de",
  "name": "New Promo Code",
  "description": "Welcoming for new registered users.",
  "createdBy": "juan.blanco",
  "companyId": "5dc098efe13604f521bcb6b2",
  "fromEmail": "example@gamanza.com",
  "fromName": "Gamanza Team",
  "replyTo": "no-reply@gamanza.com",
  "bcc": ["example@test.com", "example2@test.com"],
  "creationMode": "code",
  "isDeleted": false,
  "active": true,
  "createdAt": "Mon Apr 13 2020 20:57:19 GMT+0000 (GMT)",
  "updatedAt": "Tue Apr 14 2020 20:21:54 GMT+0000 (GMT)",
  "__V": 0
}
```

#### Duplicate a template

You can duplicate an existing template.

> All the following properties are required.

```json
{
  "id": "5e04ee0d54cb767040a14c04",
  "createdBy": "juan.blanco"
}
```

#### Response

```json
{
  "active": true,
  "name": "Welcome Campaign!_1",
  "description": "Welcoming for new registered users.",
  "fromEmail": "example@gamanza.com",
  "fromName": "Gamanza Team",
  "replyTo": "no-reply@gamanza.com",
  "bcc": ["example@test.com", "example2@test.com"],
  "creationMode": "code",
  "templates": [
    {
      "_id": "5e171598b8f0051d8dff5b28",
      "subject": "Bienvenido!",
      "language": "ES",
      "contentHtml": "<h4>Hola {{FirstName}} {{LastName}}</h4> <p>Que gusto nos da tenerte aqui!</p>"
    },
    {
      "_id": "5e171598b8f0051d8dff5b27",
      "subject": "Welcome!",
      "language": "EN",
      "contentHtml": "<h4>Hello {{FirstName}} {{LastName}}</h4> <p>It is a pleasure having you here. </p>"
    }
  ],
  "createdAt": "2020-01-09T14:39:59.097Z",
  "updatedAt": "2020-01-09T14:39:59.097Z",
  "__v": 0
}
```

#### Change status

```json
{
  "id": "5e3d8011a8989a3b7901a396",
  "active": false
}
```

#### Response

```json
{
  "active": false,
  "isDeleted": false,
  "_id": "5e3d8011a8989a3b7901a396",
  "name": "New Promo Code 22",
  "description": "Welcoming for new registered users.",
  "createdBy": "juan.blanco",
  "companyId": "5dc098efe13604f521bcb6b2",
  "fromEmail": "example@gamanza.com",
  "fromName": "Gamanza Team",
  "replyTo": "no-reply@gamanza.com",
  "bcc": ["example@test.com", "example2@test.com"],
  "creationMode": "code",
  "templates": [
    {
      "_id": "5e3d8011a8989a3b7901a397",
      "subject": "Bienvenido!",
      "language": "ES",
      "contentHtml": "<h4>Hola {{FirstName}} {{LastName}}</h4> <p>Que gusto nos da tenerte aqui!</p>"
    },
    {
      "_id": "5e3d8011a8989a3b7901a398",
      "subject": "Welcome!",
      "language": "EN",
      "contentHtml": "<h4>Hello {{FirstName}} {{LastName}}</h4> <p>It is a pleasure having you here. </p>"
    }
  ],
  "createdAt": "2020-02-07T15:19:45.035Z",
  "updatedAt": "2020-02-07T16:11:38.756Z",
  "__v": 0
}
```

#### ARCHIVE a template by ID

You can archive a template using the property `isDeleted`

> id (Template ID)

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

#### Response

```json
{
  "active": false,
  "isDeleted": true,
  "_id": "5e3d8011a8989a3b7901a396",
  "name": "New Promo Code 22",
  "description": "Welcoming for new registered users.",
  "createdBy": "juan.blanco",
  "companyId": "5dc098efe13604f521bcb6b2",
  "fromEmail": "example@gamanza.com",
  "fromName": "Gamanza Team",
  "replyTo": "no-reply@gamanza.com",
  "bcc": ["example@test.com", "example2@test.com"],
  "creationMode": "code",
  "templates": [
    {
      "_id": "5e3d8011a8989a3b7901a397",
      "subject": "Bienvenido!",
      "language": "ES",
      "contentHtml": "<h4>Hola {{FirstName}} {{LastName}}</h4> <p>Que gusto nos da tenerte aqui!</p>"
    },
    {
      "_id": "5e3d8011a8989a3b7901a398",
      "subject": "Welcome!",
      "language": "EN",
      "contentHtml": "<h4>Hello {{FirstName}} {{LastName}}</h4> <p>It is a pleasure having you here. </p>"
    }
  ],
  "createdAt": "2020-02-07T15:19:45.035Z",
  "updatedAt": "2020-02-07T16:17:24.282Z",
  "__v": 0
}
```

#### UNARCHIVE a template by ID

You can unarchive a template using the property `isDeleted`

> id (Template ID)

```json
{
  "id": "5e3d8011a8989a3b7901a396",
  "isDeleted": false
}
```

#### Response

```json
{
  "active": false,
  "isDeleted": false,
  "_id": "5e3d8011a8989a3b7901a396",
  "name": "New Promo Code 22",
  "description": "Welcoming for new registered users.",
  "createdBy": "juan.blanco",
  "companyId": "5dc098efe13604f521bcb6b2",
  "fromEmail": "example@gamanza.com",
  "fromName": "Gamanza Team",
  "replyTo": "no-reply@gamanza.com",
  "bcc": ["example@test.com", "example2@test.com"],
  "creationMode": "code",
  "templates": [
    {
      "_id": "5e3d8011a8989a3b7901a397",
      "subject": "Bienvenido!",
      "language": "ES",
      "contentHtml": "<h4>Hola {{FirstName}} {{LastName}}</h4> <p>Que gusto nos da tenerte aqui!</p>"
    },
    {
      "_id": "5e3d8011a8989a3b7901a398",
      "subject": "Welcome!",
      "language": "EN",
      "contentHtml": "<h4>Hello {{FirstName}} {{LastName}}</h4> <p>It is a pleasure having you here. </p>"
    }
  ],
  "createdAt": "2020-02-07T15:19:45.035Z",
  "updatedAt": "2020-02-07T16:19:24.581Z",
  "__v": 0
}
```

## Sender

### Send Campaigns

To send a campaign the following data is necessary. All properties are optional, a property is only required when a template placeholder requires any property for replacing.

```json
{
  "templateId": "5e31f63825f6f12bb00a6b15",
  "campaignId": "5e31f7291cb2cf3111dcbcc9",
  "type": 1, // CAMPAIGN = 1, TRIGGER = 2,
  "channel": 1, // EMAIL = 1, SMS = 2
  "provider": {
    "apiKey": "THE_PROVIDER_API_KEY",
    "defaultLanguage": "EN"
  },
  "users": [
    {
      "UserName": "angel",
      "FirstName": "Angel",
      "LastName": "Rodriguez",
      "Country": "CR",
      "City": "San Pablo",
      "PlayerLanguage": "ES",
      "AllowsEmails": true,
      "AllowsSMS": false,
      "EmailAddress": "___YOUR__EMAIL___",
      "MobileNumber": "88888888",
      "Currency": "USD",
      "DateBirth": "2019-11-06T22:12:08.794Z",
      "Age": 29,
      "Gender": "m",
      "AccountStatus": "active",
      "RegistrationDate": "2019-11-06T22:12:08.794Z",
      "LastLogin": "2019-11-06T22:12:08.794Z",
      "FirstDeposit": "2019-11-06T22:12:08.794Z",
      "PostalCode": 9485,
      "Nationality": "USA",
      "PlayerId": "5e821ba071f32029881e4a55"
    }
  ],
  "EventContent": ""
}
```

#### Send a Test Email Directly

## Email Types

```typescript
export enum SendDirectEmailType {
  RESET_PASSWORD = 0,
  WELCOME_USER = 1,
  TEST_CAMPAIGN = 2,
  TEST_PROVIDER = 3,
}
```

To send direct email is necessary the following data.

> All properties are optional. Placeholders like URL and Username are required when the email type is 0.Reset Password or 1.Welcome User
> type SendDirectEmailType Enum

```json
{
  "type": 1,
  "companyId": "5e8c5a2e23f79a78edf7e8ba",
  "provider": {
    "apiKey": "THE_PROVIDER_API_KEY",
    "defaultLanguage": "EN"
  },
  "from": "admin@gamanza.com",
  "fromName": "admin",
  "to": "email@gamanza.com",
  "replyTo": "no-reply@gamanza.com",
  "replyToName": "Not Reply",
  "subject": "Dear {{FirstName}} {{LastName}}",
  "HTMLBody": "<h4>Test {{FirstName}} {{LastName}} 😏</h4>",
  "placeholders": {
    "URL": "___SOME_URL___",
    "UserName": "juan.blanco",
    "FirstName": "Juan",
    "LastName": "Blanco",
    "Country": "US",
    "City": "Tres Rios",
    "PlayerLanguage": "EN",
    "AllowsEmails": true,
    "AllowsSMS": false,
    "EmailAddress": "___YOUR__EMAIL___",
    "MobileNumber": "",
    "Currency": "USD",
    "DateBirth": "2019-11-06T22:12:08.794Z",
    "Age": 30,
    "Gender": "m",
    "AccountStatus": "",
    "RegistrationDate": "2019-11-06T22:12:08.794Z",
    "LastLogin": "2019-11-06T22:12:08.794Z",
    "FirstDeposit": "2019-11-06T22:12:08.794Z",
    "PostalCode": 9485,
    "Nationality": "USA",
    "PlayerId": "5e821ba071f32029881e4a55",
    "EventContent": ""
  }
}
```

#### **Sendgrid** example

```json
{
  "type": 0,
  "companyId": "5e3053866e65eb23f049598a",
  "provider": {
    "apiKey": "SENDGRID_API_KEY",
    "defaultLanguage": "EU"
  },
  "from": "admin@gamanza.com",
  "fromName": "admin",
  "to": "carlos.vanegas@gamanza.com",
  "replyTo": "no-reply@gamanza.com",
  "replyToName": "Not Reply",
  "subject": "Reset Password",
  "HTMLBody": "<h4>Hello {{FirstName}} {{LastName}}, to reset your password please click on the following link: {{URL}}</h4>",
  "placeholders": {
    "URL": "https://gamanza.com/reset-password?email={{EmailAdress}}",
    "EmailAddress": "___YOUR__EMAIL___",
    "FirstName": "Angel",
    "LastName": "Rodriguez",
    "UserName": "angel.rodriguez"
  }
}
```

#### Send Invite Friends Email Campaign

```ts
export enum InviteFriendsType {
  TOKEN = 1,
  CODE,
  USERNAME,
}
```

```ts
export enum InviteFriendsMethod {
  EMAIL = 1,
  SMS,
}
```

```json
{
  "campaignId": "5eced387c0bcb0f211219b48",
  "provider": {
    "apiKey": "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",
    "defaultLanguage": "EN"
  },
  "channel": 1, // 1.EMAIL, 2.SMS
  "type": 2, // 1.CAMPAIGN, 2.TRIGGER
  "templateId": "5f10d6ac2a4c170f4a78b00b",
  "trigger": 23, // 23. REFERS A FRIEND (INVIRED), 27. REFERS A FRIEND (PLAYER)
  "users": [
    {
      "Type": 1, // InviteFriendsType Enum
      "TypeValue": "48af20fa61cc30474a2b83581e8a9694321fce763e1abb78d9d8148445210319b4db7f8d4c9d7f79a8b0a12fa91d7b935730a7d5ebcb965999fda8b032182b8b",
      "Method": 1,
      "MethodValue": "angel.rodriguez@gamanza.com", // InviteFriendsMethod Enum
      "Name": "Angel Rodriguez",
      "PlayerLanguage": "EN",
      "Gender": "m",
      "Date": "2020-05-05T13:40:28.936Z",
      "PlayerId": "f37e7dfe-5de0-4494-886c-437d496e4218",
      "FirstName": "Jose",
      "LastName": "Rodriguez",
      "UserName": "jose.rodriguez",
      "EmailAddress": "angeldcora@gmail.com",
      "EventContent": "mega string",
      "ReferredFirstName": "Angel",
      "ReferredLastName": "Rodriguez",
      "ReferredLanguage": "EN",
      "ReferredGender": "f",
      "ReferredEmail": "angel.rodriguez@gamanza.com",
      "ReferredMobile": ""
    }
  ]
}
```

## Sender SMS

### Send Custom Message

To send a personalized message, an array with the phone number and the text to send is required.

```json
{
  "mobileNumbers": ["50698073088", "50660470099"],
  "text": "Hello"
}
```

#### Response

```json
{
  "success": true
}
```

### Send Test Template Message

```json
{
  "mobileNumbers": "50684073281,50684073582",
  "templateContents": [
    {
      "language": "EN",
      "content": "Hello EN",
      "title": "title 1"
    },
    {
      "language": "DE",
      "content": "Hi DE",
      "title": "title 2"
    }
  ]
}
```

#### Response

```json
{
  "success": true
}
```

### Send Campaign Message

```json
{
  "users": [
    {
      "UserName": "angel",
      "FirstName": "Angel",
      "LastName": "Rodriguez",
      "Country": "CR",
      "City": "San Pablo",
      "PlayerLanguage": "ES",
      "AllowsEmails": true,
      "AllowsSMS": false,
      "EmailAddress": "asdasd@gmail.com",
      "MobileNumber": "50670470009",
      "Currency": "USD",
      "DateBirth": "2019-11-06T22:12:08.794Z",
      "Age": 29,
      "Gender": "m",
      "AccountStatus": "active",
      "RegistrationDate": "2019-11-06T22:12:08.794Z",
      "LastLogin": "2019-11-06T22:12:08.794Z",
      "FirstDeposit": "2019-11-06T22:12:08.794Z",
      "PostalCode": 9485,
      "Nationality": "USA",
      "PlayerId": "5e821ba071f32029881e4a55"
    }
  ],
  "templateId": "5ed6c10b15f355115334ff5b",
  "campaignId": "5eecfa7f7da9be62226a214a",
  "defaultLanguage": "EN"
}
```

#### Response

```json
{
  "success": true
}
```

## Template SMS

#### Create a template sms

```json
{
  "name": "Wellcome",
  "description": "Wellcome new player",
  "createdBy": "Angel",
  "companyId": "5ef27a1487aaa93d828686b8",
  "templateContents": [
    {
      "language": "EN",
      "content": "Wellcome new player",
      "title": "Gamanza"
    }
  ],
  "tags": ["Hello"]
}
```

#### Response

```json
{
  "templateContents": [
    {
      "language": "EN",
      "content": "Hello",
      "title": "Hello"
    }
  ],
  "tags": ["Hello"],
  "_id": "5f1b48fdb5c7ce42db1c751a",
  "name": "Hello",
  "description": "Hello",
  "createdBy": "Hello",
  "companyId": "5ed925790dffa90aee3aef6a",
  "isDeleted": false,
  "active": true,
  "createdAt": "Fri Jul 24 2020 20:47:57 GMT+0000 (GMT)",
  "updatedAt": "Fri Jul 24 2020 20:47:57 GMT+0000 (GMT)",
  "__V": 0
}
```

#### Get a template sms

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

#### Response

```json
{
  "templateContents": [
    {
      "language": "EN",
      "content": "Wellcome new player",
      "title": "Gamanza"
    }
  ],
  "tags": ["Hello"],
  "_id": "5ed925790dffa90aee3aef6a",
  "name": "Wellcome",
  "description": "Wellcome new player",
  "createdBy": "user1",
  "companyId": "507f191e810c19729de860ea",
  "isDeleted": true,
  "active": true,
  "createdAt": "Thu Jun 04 2020 16:46:49 GMT+0000 (GMT)",
  "updatedAt": "Fri Jul 24 2020 17:41:00 GMT+0000 (GMT)",
  "__V": 0
}
```

#### Get templates name sms

```json
{
  "companyId": "507f191e810c19729de861ea"
}
```

#### Response

```json
{
  "templates": [
    {
      "id": "",
      "name": "Hello1"
    },
    {
      "id": "",
      "name": "Hello 1"
    }
  ]
}
```

#### Get all template sms

```json
{
  "language": ["EN"],
  "tags": ["Hello"],
  "createdBy": ["user1"],
  "companyId": ["507f191e810c19729de860ea"],
  "limit": 10,
  "page": 1,
  "isArchive": false
}
```

#### Response

```json
{
  "docs": [
    {
      "templateContents": [
        {
          "language": "EN",
          "content": "{{TitleFirstName}} {{FirstName}}, Welcome to Pasino",
          "title": ""
        },
        {
          "language": "DE",
          "content": "{{FirstName}}, Willkommen zu Pasino",
          "title": ""
        },
        {
          "language": "FR",
          "content": "{{TitleFirstName}} {{FirstName}}, Bienvenue à Pasino",
          "title": ""
        },
        {
          "language": "IT",
          "content": "{{FirstName}}, Benvenuto a Pasino",
          "title": ""
        }
      ],
      "tags": ["Hello"],
      "_id": "5ed6c10b15f355115334ff5b",
      "name": "sms1",
      "description": "description2",
      "createdBy": "user1",
      "companyId": "507f191e810c19729de860ea",
      "isDeleted": false,
      "active": false,
      "createdAt": "Tue Jun 02 2020 21:13:47 GMT+0000 (GMT)",
      "updatedAt": "Mon Jul 13 2020 22:35:48 GMT+0000 (GMT)",
      "__V": 0
    }
  ],
  "total": 1,
  "limit": 10,
  "page": 1,
  "pages": 1
}
```

#### Update a template sms

```json
{
  "id": "5ef27a1487aaa93d828686b8",
  "name": "Wellcome",
  "description": "Wellcome new player",
  "templateContents": [
    {
      "language": "EN",
      "content": "Wellcome new player",
      "title": "Gamanza"
    }
  ],
  "isDeleted": true,
  "tags": ["Hello"]
}
```

#### Response

```json
{
  "templateContents": [
    {
      "language": "EN",
      "content": "Wellcome new player",
      "title": "Gamanza"
    }
  ],
  "tags": ["Hello"],
  "_id": "5ed925790dffa90aee3aef6a",
  "name": "Wellcome",
  "description": "Wellcome new player",
  "createdBy": "user1",
  "companyId": "507f191e810c19729de860ea",
  "isDeleted": true,
  "active": true,
  "createdAt": "Thu Jun 04 2020 16:46:49 GMT+0000 (GMT)",
  "updatedAt": "Fri Jul 24 2020 17:41:00 GMT+0000 (GMT)",
  "__V": 0
}
```

#### Duplicate a template sms

```json
{
  "id": "5f3ef786c097231fe6708b16",
  "createdBy": "Juan"
}
```

#### Response

```json
{
  "templateContents": [
    {
      "language": "ES",
      "content": "Hello",
      "title": "Hello"
    }
  ],
  "tags": ["Hello"],
  "_id": "5f4576d4ea7957341251e061",
  "name": "Hello 5_copy_copy_copy",
  "description": "Hello",
  "createdBy": "Juan",
  "companyId": "5ed925790dffa90aee3aef6b",
  "isDeleted": false,
  "active": true,
  "createdAt": "Tue Aug 25 2020 20:38:44 GMT+0000 (GMT)",
  "updatedAt": "Tue Aug 25 2020 20:38:44 GMT+0000 (GMT)",
  "__V": 0
}
```

## Rules Engine Sender

> For sending rules engine using the email sender or the sms sender you need only to change the `channel`

### Send using email sender

```json
{
  "provider": {
    "apiKey": "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",
    "defaultLanguage": "ES"
  },
  "templateId": "5f7f43978f058d13fcb115c5",
  "channel": 1, // for email sender
  "contacts": ["___SOME@EMAIL.COM___", "___SOME@EMAIL.COM___"],
  "placeholders": {
    "UserName": "Hello",
    "FirstName": "Hello",
    "LastName": "Hello",
    "Country": "CR",
    "City": "Hello",
    "PlayerLanguage": "ES",
    "AllowsEmails": true,
    "AllowsSMS": true,
    "EmailAddress": "test@test.com",
    "MobileNumber": "Hello",
    "Currency": "USD",
    "DateBirth": "2020-07-21T16:06:29.383+00:00",
    "Age": 10,
    "Gender": "f",
    "AccountStatus": "Hello",
    "RegistrationDate": "2020-07-21T16:06:29.383+00:00",
    "LastLogin": "2020-07-21T16:06:29.383+00:00",
    "FirstDeposit": "2020-07-21T16:06:29.383+00:00",
    "PostalCode": 10,
    "Nationality": "Hello",
    "PlayerId": "e961d6d7-c049-4ecc-9ab9-16f313bec170",
    "Amount": 10,
    "TransactionType": "Hello",
    "Date": "2020-07-21T16:06:29.383+00:00",
    "TransactionStatus": 10,
    "PaymentProvider": "Hello",
    "PaymentMethod": "Hello",
    "DepositId": "854cebe0-263b-48ab-978e-babe56be2908",
    "DepositCount": 10,
    "BonusName": "Hello",
    "BonusType": "Hello",
    "BonusId": 10,
    "FreeSpinAmount": 10,
    "Game": "Hello",
    "SpinValue": "Hello",
    "WageringRequirement": 10,
    "ExpirationDate": "2020-07-21T16:06:29.383+00:00",
    "BonusGrantedAmount": 10,
    "BonusReleasedAmount": 10,
    "Message": "Hello",
    "Action": "Hello",
    "PlayerTag": ["Hello"],
    "Category": "Hello",
    "Priority": "Hello",
    "DeviceOS": "Hello",
    "DeviceBrowser": "Hello",
    "TotalSession": 10,
    "TotalCoolOff": 10,
    "Score": 10,
    "Context": "Hello",
    "Count": 10,
    "TotalAmount": 10,
    "LimitPeriodId": "Hello",
    "LimitAmount": 10,
    "DepositPaymentMethod": "Hello",
    "DepositAmount": 10,
    "DepositReason": "Hello",
    "CoolOffs": "Hello",
    "Sessions": "Hello",
    "Answers": "Hello",
    "Devices": "Hello",
    "LimitsChanges": "Hello",
    "Withdraws": "Hello",
    "TagAssigned": "Hello",
    "TagCategory": "Hello",
    "ActionTag": "assigned", // assigned | unassigned
    "NoteCount": 10,
    "NoteCategoryCount": 10,
    "NoteCategory": "Hello",
    "Note": "Hello",
    "NotePriority": "Hello"
  }
}
```

### For SMS sender

```json
{
  "provider": {
    "apiKey": "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",
    "defaultLanguage": "ES"
  },
  "templateId": "5f1b48fdb5c7ce42db1c751a",
  "channel": 2, // for SMS sender
  "contacts": ["___SOME-PHONE-NUMBER___", "___SOME-PHONE-NUMBER___"],
  "placeholders": {
    "UserName": "Hello",
    "FirstName": "Angel",
    "LastName": "Hello",
    "Country": "CR",
    "City": "Hello",
    "PlayerLanguage": "ES",
    "AllowsEmails": true,
    "AllowsSMS": true,
    "EmailAddress": "test@test.com",
    "MobileNumber": "Hello",
    "Currency": "USD",
    "DateBirth": "2020-07-21T16:06:29.383+00:00",
    "Age": 10,
    "Gender": "f",
    "AccountStatus": "Hello",
    "RegistrationDate": "2020-07-21T16:06:29.383+00:00",
    "LastLogin": "2020-07-21T16:06:29.383+00:00",
    "FirstDeposit": "2020-07-21T16:06:29.383+00:00",
    "PostalCode": 10,
    "Nationality": "Hello",
    "PlayerId": "e961d6d7-c049-4ecc-9ab9-16f313bec170",
    "Amount": 10,
    "TransactionType": "Hello",
    "Date": "2020-07-21T16:06:29.383+00:00",
    "TransactionStatus": 10,
    "PaymentProvider": "Hello",
    "PaymentMethod": "Hello",
    "DepositId": "854cebe0-263b-48ab-978e-babe56be2908",
    "DepositCount": 10,
    "BonusName": "Hello",
    "BonusType": "Hello",
    "BonusId": 10,
    "FreeSpinAmount": 10,
    "Game": "Hello",
    "SpinValue": "Hello",
    "WageringRequirement": 10,
    "ExpirationDate": "2020-07-21T16:06:29.383+00:00",
    "BonusGrantedAmount": 10,
    "BonusReleasedAmount": 10,
    "Message": "Hello",
    "Action": "Hello",
    "PlayerTag": ["Hello"],
    "Category": "Hello",
    "Priority": "Hello",
    "DeviceOS": "Hello",
    "DeviceBrowser": "Hello",
    "TotalSession": 10,
    "TotalCoolOff": 10,
    "Score": 10,
    "Context": "Hello",
    "Count": 10,
    "TotalAmount": 10,
    "LimitPeriodId": "Hello",
    "LimitAmount": 10,
    "DepositPaymentMethod": "Hello",
    "DepositAmount": 10,
    "DepositReason": "Hello",
    "CoolOffs": "Hello",
    "Sessions": "Hello",
    "Answers": "Hello",
    "Devices": "Hello",
    "LimitsChanges": "Hello",
    "Withdraws": "Hello",
    "TagAssigned": "Hello",
    "TagCategory": "Hello",
    "ActionTag": "assigned", // assigned | unassigned
    "NoteCount": 10,
    "NoteCategoryCount": 10,
    "NoteCategory": "Hello",
    "Note": "Hello",
    "NotePriority": "Hello"
  }
}
```

## Contact

- Authors - [Angel Rodriguez](https://gamanza-group.atlassian.net/jira/people/5d653fe29eb3300c0f6f3c68), [Carlos Vanegas](https://gamanza-group.atlassian.net/jira/people/5d6e8d75f989e00d8c7e828f)
- Emails - [angel.rodriguez@gamanza.com](mailto:angel.rodriguez@gamanza.com), [carlos.vanegas@gamanza.com](carlos.vanegas@gamanza.com)

---
_Source: https://npm.io/package/crm-gateway · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
