Use Coupon
API for using a coupon code to receive rewards.
URL Confirmation
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/coupon/v20240301/search - Method:
PUT - Authentication Required: Yes
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| code | string | Required | Coupon code to use |
Response Data
Res Class
| Field | Type | Description |
|---|---|---|
| Items | SerializeReward[] | List of reward items |
SerializeReward Structure
| Field | Type | Description |
|---|---|---|
| item_code | string | Item code |
| item_count | double | Item count |
Unity C# Implementation
BaseResponse Class
The base class for all API responses.
public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}
Field descriptions:
ErrorCode: Error codeMessage: Error messageWithdrawalKey: Key required for recovery if in withdrawal grace period (provided only for accounts in withdrawal grace period)BlockKey: Key provided for blocked accounts (provided only for blocked accounts)
Coupon Use Class
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;
public class CouponUse
{
static string url = "https://service-api.playnanoo.com/coupon/v20240301/search";
[Serializable]
public class Req : DeviceInfo
{
public string code;
public IEnumerator Send(
string coupon_code,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(coupon_code)) this.code = coupon_code;
// PUT method call
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
url,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public List<SerializeReward> Items;
}
[Serializable]
public class SerializeReward
{
public string item_code;
public double item_count;
}
}
Usage Example
public void UseCoupon()
{
CouponUse.Req req = new CouponUse.Req();
StartCoroutine(req.Send(
coupon_code: "PLAYNANOO2024",
onSuccess: res =>
{
// Reward information
foreach (var item in res.Items)
{
Debug.Log($"Reward: {item.item_code} x{item.item_count}");
}
},
onError: (error) =>
{
Debug.LogError($"Coupon usage failed: [{error.ErrorCode}] [{error.Message}]");
}
));
}
Coupon Code
Coupon codes are case-sensitive and can be set as single-use or multi-use.