Initialize Currency
API to initialize player's currency.
URL Verification
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/currency/v20240301/init - Method:
PUT - Authentication Required: Yes
DeviceInfo Inheritance
The Req class of this API inherits from DeviceInfo. All properties of DeviceInfo are automatically included.
Request Parameters
This API has no additional request parameters.
Response Data
Res Class
| Field | Type | Description |
|---|---|---|
| items | List<ItemModel> | Initialized currency list |
ItemModel Class
| Field | Type | Description |
|---|---|---|
| currency_code | string | Currency code |
| currency_amount | double | Currency amount owned |
Unity C# Implementation
BaseResponse Class
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 account is in withdrawal grace period (provided only for accounts in withdrawal grace period)BlockKey: Key provided for blocked accounts (provided only for blocked accounts)
ItemModel Class
[Serializable]
public class ItemModel
{
public string currency_code;
public double currency_amount;
}
Initialize Currency Class
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;
public class CurrencyInit
{
static string path = "https://service-api.playnanoo.com/currency/v20240301/init";
[Serializable]
public class Req : DeviceInfo
{
public IEnumerator Send(Action<Res> onSuccess, Action<BaseResponse> onError)
{
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public List<ItemModel> items = new List<ItemModel>();
}
[Serializable]
public class ItemModel
{
public string currency_code;
public double currency_amount;
}
}
Usage Example
public void InitCurrency()
{
CurrencyInit.Req req = new CurrencyInit.Req();
StartCoroutine(req.Send(
onSuccess: res =>
{
Debug.Log("Currency initialization successful");
foreach (var item in res.items)
{
Debug.Log($"Currency code: {item.currency_code}");
Debug.Log($"Amount owned: {item.currency_amount}");
}
},
onError: error =>
{
Debug.LogError($"Currency initialization failed: [{error.ErrorCode}] {error.Message}");
}
));
}
Currency Initialization Caution
This API initializes all of the player's currencies. It should be used with caution.