# MGM API

## Endpoints

### Available endpoints

* Upsert affiliate
> [POST] /api/v1/affiliates
> 
> { email: 'affiliate@email' }

If any payments subscription exists, this must return affiliate coupon
```
    {
        "coupon": "LU3214MGM"
    }
```

* List coupon usage
> [GET] /api/v1/affiliates/coupon/__COUPON_CODE__/usage

It will list all coupon usage for resmed products
```
[
    {
        "date": "2020-12-02 18:36:21",
        "status": "A",
        "clientName": "Luciano"
    },
    {
        "date": "2020-12-02 18:42:19",
        "status": "A",
        "clientName": "Luciano"
    }
]
```

Orders statuses:

* A: Waiting Payment
* N: Abandoned
* C: Canceled
* P: Paid
* F: Finished
* E: Shipped

### Create a new TGT sharable link

> Create a sharable link on sanar.link for a given course_slug and user_id

`[Post] /api/v1/trial/link`

```json
{
  "user_id": "5d5c4e40ee0453001c4541da",
  "course_slug": "course_slug"
}
```

Response:

```json
{
  "link": "http://sanar.link/YwBcJ"
}
```

#### Validation

user_id and course_slug are required, when not provided, will return *400* error.

```json
{
  "errors": [
    {
      "value": "5d5c4e40ee0453001c4541da___",
      "msg": "o campo user_id deve ter 24 caracteres",
      "param": "user_id",
      "location": "body"
    },
    {
      "value": "",
      "msg": "o campo course_slug deve ser informado",
      "param": "course_slug",
      "location": "body"
    }
  ]
}
```
