> For the complete documentation index, see [llms.txt](https://developer.cscmobicorp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.cscmobicorp.com/gsm/gsm-sdk/iii.-gsm-api/gsm-sendy.md).

# GSM Sendy

Dùng để thu thập email của user, phục vụ marketing

## 1. Subscribe

* Dùng để user đăng ký 1 email và nhận một mã giftcode về mail.
* Sau khi user nhập mã giftcode vào game, thì sẽ nhận được phần thưởng và hệ thống sẽ lưu trữ mail của user để thu thập data.

```csharp
void Subscribe(string email, string name, Dictionary<string, string> customFields = null, Action onSuccess = null, Action<long, string> onFail = null)
```

**Các tham số**

* **`email`** *(Required)*: Là email để đăng ký.
* **`name`** *(Optional)*: Là tên của user nếu có.
* **`customFields`** *(Optional)*: Là các trường tùy biến, phục vụ để chèn vào nội dung trong mail
* **`onSuccess`** *Optional)*: Hàm được thực hiện khi thành công.
* **`onFail`** *Optional)*: Hàm được thực khiện khi có lỗi xảy ra.

Code mẫu:

```csharp
GSMSendy.Subscribe("tuyennv@cscmobi.com", "tuyen", new Dictionary<string, string>() { { "giftcode", "SUB2023" } }, () =>
{
    Debug.Log("Subscribe Success");
}, (statusCode,error) =>
{
    if(statusCode==(long)StatusCode.Maintain)
    {
        //Xử lý khi có thông báo bảo trì
    }
    Debug.Log("Subscribe fail" + error);
});
```

## 2. UnSubscribe

* Dùng để hủy đăng ký nhận các email marketing

```csharp
void UnSubscribe(string email, Action onSuccess = null, Action<long, string> onFail = null)
```

**Các tham số**

* **`email`** *(Required)*: Là email để hủy đăng ký.
* **`onSuccess`** *Optional)*: Hàm được thực hiện khi thành công.
* **`onFail`** *Optional)*: Hàm được thực khiện khi có lỗi xảy ra.

Code mẫu:

```csharp
GSMSendy.UnSubscribe("tuyennv@cscmobi.com", () =>
{
    Debug.Log("Unsubscribe Success");
}, (statusCode, error) =>
{
    if (statusCode == (long)StatusCode.Maintain)
    {
        //Xử lý khi có thông báo bảo trì
    }
    Debug.Log("Unsubscribe fail" + error);
});
```

## 3. Delete Subscribe

* Dùng để xóa bỏ thông tin email ra khỏi hệ thống

```csharp
void Delete(string email, Action onSuccess = null, Action<long, string> onFail = null)
```

**Các tham số**

* **`email`** *(Required)*: Là email muốn xóa thông tin.
* **`onSuccess`** *Optional)*: Hàm được thực hiện khi thành công.
* **`onFail`** *Optional)*: Hàm được thực khiện khi có lỗi xảy ra.

Code mẫu:

```csharp
GSMSendy.Delete("tuyennv@cscmobi.com", () =>
{
    Debug.Log("Delete Success ");
}, (statusCode, error) =>
{
    if (statusCode == (long)StatusCode.Maintain)
    {
        //Xử lý khi có thông báo bảo trì
    }
    Debug.Log("Delete fail" + error);
});
```

## 4. Check Status

* Dùng để kiểm tra trạng thái 1 email đã subscribe hoặc unsubscribe với hệ thống

```csharp
void CheckSubscribeStatus(string email, Action<SendySubscribedStatus> onComplete = null, Action<long, string> onFail = null)
```

**Các tham số**

* **`email`** *(Required)*: Là email muốn xóa thông tin.
* **`onComplete`** (*Optional)*: Hàm được thực hiện khi thành công.
* **`onFail`** *Optional)*: Hàm được thực khiện khi có lỗi xảy ra.

Code mẫu:

```csharp
GSMSendy.CheckSubscribeStatus("tuyennv@cscmobi.com", status =>
{
    Debug.Log("Status " + status.ToString());
}, (statusCode, error) =>
{
    if (statusCode == (long)StatusCode.Maintain)
    {
        //Xử lý khi có thông báo bảo trì
    }
    Debug.Log("CheckSubscribeStatus fail" + error);
});
```
