Skip to main content

Create Guild

API to create a guild.

URL Confirmation

This API uses the service-api.playnanoo.com domain.

API Information

  • URL: https://service-api.playnanoo.com/guild/v20230101/create
  • Method: PUT
  • Authentication Required: Yes

Request Parameters

ParameterTypeRequiredDescription
table_codestringRequiredTable code
namestringRequiredGuild name
member_limitintRequiredMember limit
member_point_typestringRequiredMember point type (keep: keep points, delete: deduct points)
auto_joinstringRequiredAuto join (Y/N)
extra_datastringYesExtra data
DeviceInfo Inheritance

The Req class of this API inherits from DeviceInfo. All properties of DeviceInfo are automatically included.

Response Data

Res Class

FieldTypeDescription
UidstringGuild unique ID
NamestringGuild name

Unity C# Implementation

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class GuildCreate
{
static string path = "https://service-api.playnanoo.com/guild/v20230101/create";

[Serializable]
public class Req : DeviceInfo
{
public string table_code;
public string name;
public int member_limit;
public string member_point_type; // When member leaves: keep = keep points, delete = deduct points
public string auto_join;
public string extra_data;

public IEnumerator Send(
string tableCode,
string name,
int memberLimit,
string memberPointType,
bool autoJoin,
string extraData,
Action<Res> onSuccess,
Action<BaseResponse> onError
)
{
if (!string.IsNullOrEmpty(tableCode)) this.table_code = tableCode;
if (!string.IsNullOrEmpty(name)) this.name = name;
if (!string.IsNullOrEmpty(memberPointType)) this.member_point_type = memberPointType;
if (!string.IsNullOrEmpty(extraData)) this.extra_data = extraData;
this.auto_join = autoJoin ? "Y" : "N";
this.member_limit = memberLimit;

yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}

[Serializable]
public class Res : BaseResponse
{
public string Uid;
public string Name;
}

}

Usage Example

public void CreateGuild()
{
GuildCreate.Req req = new GuildCreate.Req();

StartCoroutine(req.Send(
tableCode: "guild_table",
name: "MyGuild",
memberLimit: 50,
memberPointType: "keep",
autoJoin: false,
extraData: "",
onSuccess: res =>
{
Debug.Log($"Guild UID: {res.Uid}");
Debug.Log($"Guild Name: {res.Name}");
},
onError: (error) =>
{
Debug.LogError($"Guild creation failed: [{error.ErrorCode}] {error.Message}");
}
));
}