API Reference of GS2-Chat SDK

Model

Namespace

Namespace

Namespace is a mechanism that allows multiple uses of the same service for different purposes within a single project. Basically, GS2 services have a layer called namespace, and different namespaces are treated as completely different data spaces, even for the same service.

Therefore, it is necessary to create a namespace before starting to use each service.

TypeConditionRequireDefaultLimitationDescription
namespaceIdstring~ 1024 charsNamespace GRN
namestring~ 32 charsNamespace name
descriptionstring~ 1024 charsDescription
allowCreateRoombooltrueAllow game players to create rooms
postMessageScriptScriptSettingScript to run when you post a message
createRoomScriptScriptSettingScript to run when a room is created
deleteRoomScriptScriptSettingScript to run when a room is deleted
subscribeRoomScriptScriptSettingScript to run when a room is subscribed
unsubscribeRoomScriptScriptSettingScript to run when a room is unsubscribed
postNotificationNotificationSettingPush notifications when new posts come to the rooms to which you are subscribed
logSettingLogSettingLog output settings
createdAtlongDatetime of creation
updatedAtlongDatetime of last update
revisionlong0~ 9223372036854775805Revision

Room

Room

A room represents the area within which chat messages can be delivered. GS2-Chat rooms do not have the concept of participation. Therefore, you do not need to be a member of a room to receive messages, as long as you know the name of the room.

If you wish to limit the number of game players who can view the messages in a room, there are two options. The first is to set a password for the room. Second, you can whitelist the room and limit the game players by setting their user IDs in the whitelist.

Note that if you set a password, even the game administrator will not be able to retrieve messages without knowing the password. This is because this may fall under the secret of communication stipulated in the Constitution of Japan.

If you subscribe to a room, you can receive GS2-Gateway push notifications when new messages are sent to the room. By using this notification function, you will be able to know if there are any new messages without polling the room.

TypeConditionRequireDefaultLimitationDescription
roomIdstring~ 1024 charsRoom GRN
namestringUUID~ 128 charsRoom Name
userIdstring~ 128 charsOwner User ID
metadatastring~ 1024 charsmetadata
passwordstring~ 128 charsPassword required to access the room
whiteListUserIdsList<string>[]~ 1000 itemsList of user IDs with access to the room
createdAtlongDatetime of creation
updatedAtlongDatetime of last update
revisionlong0~ 9223372036854775805Revision

Message

Message

Messages are data posted to a room.

It has a field called category, which allows classification of messages. For example, a category of 0 is interpreted as a normal text message, while a category of If 1, the client can be run to process it as a stamp (sticker).

Posted messages are automatically deleted one hour after submission. This time cannot be changed.

TypeConditionRequireDefaultLimitationDescription
messageIdstring~ 1024 charsMessage GRN
roomNamestringUUID~ 128 charsRoom Name
namestringUUID~ 36 charsMessage name
userIdstring~ 128 charsUser Id
categoryint0~ 2147483645Type number when you want to classify message types.
metadatastring~ 1024 charsmetadata
createdAtlongDatetime of creation
revisionlong0~ 9223372036854775805Revision

Subscribe

Subscribe

By subscribing to a room, you will be instantly informed of new messages for that room. When subscribing, you can specify the category of the message. This feature can be used to subscribe only to messages that are of high importance to you.

TypeConditionRequireDefaultLimitationDescription
subscribeIdstring~ 1024 charsSubscription GRN
userIdstring~ 128 charsUser Id
roomNamestring~ 128 charsRoom name to subscribe to
notificationTypesList<NotificationType>[]~ 100 itemsCategory list to receive notifications of new messages
createdAtlongDatetime of creation
revisionlong0~ 9223372036854775805Revision

NotificationType

Notification Type

Setting categories for receiving new message notifications

TypeConditionRequireDefaultLimitationDescription
categoryint0~ 2147483646Categories for which you receive new message notifications
enableTransferMobilePushNotificationboolfalseTransfer to mobile push notifications when you were offline?

ScriptSetting

Script settings

In GS2, you can associate custom scripts with microservice events and execute them. This model holds the settings for triggering script execution.

There are two main ways to execute a script: synchronous execution and asynchronous execution. Synchronous execution blocks processing until the script has finished executing. Instead, you can use the script execution result to stop the execution of the API or to tamper with the result of the API.

On the other hand, asynchronous execution does not block processing until the script has finished executing. Instead, you can use the script execution result to stop the execution of the API or to tamper with the result of the API. However, asynchronous execution does not block processing until the script has finished executing, so it is generally recommended to use asynchronous execution.

There are two types of asynchronous execution methods: GS2-Script and Amazon EventBridge. By using Amazon EventBridge, you can write processing in languages other than Lua.

TypeConditionRequireDefaultLimitationDescription
triggerScriptIdstring~ 1024 charsScript GRN of synchronous execution script
doneTriggerTargetTypeenum [
“none”,
“gs2_script”,
“aws”
]
“none”~ 128 charsHow to execute asynchronous scripts
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsScript GRN of asynchronous execution script
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsGS2-JobQueue namespace to execute asynchronous execution scripts

NotificationSetting

Push notification settings

This is a setting for sending push notifications when an event occurs in a GS2 microservice. The push notification here refers to the processing via the WebSocket interface provided by GS2-Gateway, and is different from the push notification of a smartphone. For example, when a matchmaking is completed or a friend request is received, the GS2-Gateway can send a push notification via the WebSocket interface, and the game client can detect the change of the state.

GS2-Gateway’s push notifications can be used to send additional processing to mobile push notifications when the destination device is offline. If you use mobile push notifications well, you may be able to realize a flow in which you can notify the player by using mobile push notifications even if you end the game during matchmaking and return to the game.

TypeConditionRequireDefaultLimitationDescription
gatewayNamespaceIdstring“grn:gs2:{region}:{ownerId}:gateway:default”~ 1024 charsGS2-Gateway namespace to use for push notifications
enableTransferMobileNotificationbool?falseForwarding to mobile push notification
soundstring{enableTransferMobileNotification} == true~ 1024 charsSound file name to be used for mobile push notifications

LogSetting

Log setting

This type manages log output settings. This type holds the identifier of the log namespace used to output log data. The log namespace ID specifies the GS2-Log namespace to aggregate and store the log data. Through this setting, API request and response log data under this namespace will be output to the target GS2-Log. GS2-Log provides logs in real time, which can be used for system monitoring, analysis, debugging, etc.

TypeConditionRequireDefaultLimitationDescription
loggingNamespaceIdstring~ 1024 charsNamespace GRN

Methods

describeNamespaces

Get list of namespaces

Get a list of all namespaces in the project. You can use the optional page token to start acquiring data from a specific location in the list. You can also limit the number of namespaces to be acquired.

Request

TypeConditionRequireDefaultLimitationDescription
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<Namespace>List of Namespace
nextPageTokenstringPage token to retrieve the rest of the listing

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &chat.DescribeNamespacesRequest {
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeNamespacesRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeNamespaces(
        (new DescribeNamespacesRequest())
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeNamespacesRequest;
import io.gs2.chat.result.DescribeNamespacesResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DescribeNamespacesResult result = client.describeNamespaces(
        new DescribeNamespacesRequest()
            .withPageToken(null)
            .withLimit(null)
    );
    List<Namespace> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DescribeNamespacesRequest;
using Gs2.Gs2Chat.Result.DescribeNamespacesResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
    new Gs2.Gs2Chat.Request.DescribeNamespacesRequest()
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.describeNamespaces(
        new Gs2Chat.DescribeNamespacesRequest()
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.describe_namespaces(
        chat.DescribeNamespacesRequest()
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.describe_namespaces({
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

createNamespace

Create new namespace

You must specify detailed information including the name, description, and various settings of the namespace.

Request

TypeConditionRequireDefaultLimitationDescription
namestring~ 32 charsNamespace name
descriptionstring~ 1024 charsDescription
allowCreateRoombooltrueAllow game players to create rooms
postMessageScriptScriptSettingScript to run when you post a message
createRoomScriptScriptSettingScript to run when a room is created
deleteRoomScriptScriptSettingScript to run when a room is deleted
subscribeRoomScriptScriptSettingScript to run when a room is subscribed
unsubscribeRoomScriptScriptSettingScript to run when a room is unsubscribed
postNotificationNotificationSettingPush notifications when new posts come to the rooms to which you are subscribed
logSettingLogSettingLog output settings

Result

TypeDescription
itemNamespaceNamespace created

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &chat.CreateNamespaceRequest {
        Name: pointy.String("namespace1"),
        Description: nil,
        AllowCreateRoom: nil,
        PostMessageScript: nil,
        CreateRoomScript: nil,
        DeleteRoomScript: nil,
        SubscribeRoomScript: nil,
        UnsubscribeRoomScript: nil,
        PostNotification: nil,
        LogSetting: &chat.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CreateNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName(self::namespace1)
            ->withDescription(null)
            ->withAllowCreateRoom(null)
            ->withPostMessageScript(null)
            ->withCreateRoomScript(null)
            ->withDeleteRoomScript(null)
            ->withSubscribeRoomScript(null)
            ->withUnsubscribeRoomScript(null)
            ->withPostNotification(null)
            ->withLogSetting((new \Gs2\Chat\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:\namespace1"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CreateNamespaceRequest;
import io.gs2.chat.result.CreateNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    CreateNamespaceResult result = client.createNamespace(
        new CreateNamespaceRequest()
            .withName("namespace1")
            .withDescription(null)
            .withAllowCreateRoom(null)
            .withPostMessageScript(null)
            .withCreateRoomScript(null)
            .withDeleteRoomScript(null)
            .withSubscribeRoomScript(null)
            .withUnsubscribeRoomScript(null)
            .withPostNotification(null)
            .withLogSetting(new io.gs2.chat.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CreateNamespaceRequest;
using Gs2.Gs2Chat.Result.CreateNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
    new Gs2.Gs2Chat.Request.CreateNamespaceRequest()
        .WithName("namespace1")
        .WithDescription(null)
        .WithAllowCreateRoom(null)
        .WithPostMessageScript(null)
        .WithCreateRoomScript(null)
        .WithDeleteRoomScript(null)
        .WithSubscribeRoomScript(null)
        .WithUnsubscribeRoomScript(null)
        .WithPostNotification(null)
        .WithLogSetting(new Gs2.Gs2Chat.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.createNamespace(
        new Gs2Chat.CreateNamespaceRequest()
            .withName("namespace1")
            .withDescription(null)
            .withAllowCreateRoom(null)
            .withPostMessageScript(null)
            .withCreateRoomScript(null)
            .withDeleteRoomScript(null)
            .withSubscribeRoomScript(null)
            .withUnsubscribeRoomScript(null)
            .withPostNotification(null)
            .withLogSetting(new Gs2Chat.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.create_namespace(
        chat.CreateNamespaceRequest()
            .with_name(self.hash1)
            .with_description(None)
            .with_allow_create_room(None)
            .with_post_message_script(None)
            .with_create_room_script(None)
            .with_delete_room_script(None)
            .with_subscribe_room_script(None)
            .with_unsubscribe_room_script(None)
            .with_post_notification(None)
            .with_log_setting(
                chat.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.create_namespace({
    name="namespace1",
    description=nil,
    allowCreateRoom=nil,
    postMessageScript=nil,
    createRoomScript=nil,
    deleteRoomScript=nil,
    subscribeRoomScript=nil,
    unsubscribeRoomScript=nil,
    postNotification=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

getNamespaceStatus

Get namespace status

Get the current status of the specified namespace. This includes whether the namespace is active, pending, or in some other state.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name

Result

TypeDescription
statusstring

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &chat.GetNamespaceStatusRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
status := result.Status
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetNamespaceStatusRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getNamespaceStatus(
        (new GetNamespaceStatusRequest())
            ->withNamespaceName(self::namespace1)
    );
    $status = $result->getStatus();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetNamespaceStatusRequest;
import io.gs2.chat.result.GetNamespaceStatusResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    GetNamespaceStatusResult result = client.getNamespaceStatus(
        new GetNamespaceStatusRequest()
            .withNamespaceName("namespace1")
    );
    String status = result.getStatus();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetNamespaceStatusRequest;
using Gs2.Gs2Chat.Result.GetNamespaceStatusResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
    new Gs2.Gs2Chat.Request.GetNamespaceStatusRequest()
        .WithNamespaceName("namespace1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var status = result.Status;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.getNamespaceStatus(
        new Gs2Chat.GetNamespaceStatusRequest()
            .withNamespaceName("namespace1")
    );
    const status = result.getStatus();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.get_namespace_status(
        chat.GetNamespaceStatusRequest()
            .with_namespace_name(self.hash1)
    )
    status = result.status
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_namespace_status({
    namespaceName="namespace1",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
status = result.status;

getNamespace

Get namespace

Get detailed information about the specified namespace. This includes the name, description, and other settings of the namespace.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name

Result

TypeDescription
itemNamespaceNamespace

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &chat.GetNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getNamespace(
        (new GetNamespaceRequest())
            ->withNamespaceName(self::namespace1)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetNamespaceRequest;
import io.gs2.chat.result.GetNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    GetNamespaceResult result = client.getNamespace(
        new GetNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetNamespaceRequest;
using Gs2.Gs2Chat.Result.GetNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
    new Gs2.Gs2Chat.Request.GetNamespaceRequest()
        .WithNamespaceName("namespace1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.getNamespace(
        new Gs2Chat.GetNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.get_namespace(
        chat.GetNamespaceRequest()
            .with_namespace_name(self.hash1)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_namespace({
    namespaceName="namespace1",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

updateNamespace

Update namespace

Update the settings of the specified namespace. You can change the description of the namespace and specific settings.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
descriptionstring~ 1024 charsDescription
allowCreateRoombooltrueAllow game players to create rooms
postMessageScriptScriptSettingScript to run when you post a message
createRoomScriptScriptSettingScript to run when a room is created
deleteRoomScriptScriptSettingScript to run when a room is deleted
subscribeRoomScriptScriptSettingScript to run when a room is subscribed
unsubscribeRoomScriptScriptSettingScript to run when a room is unsubscribed
postNotificationNotificationSettingPush notifications when new posts come to the rooms to which you are subscribed
logSettingLogSettingLog output settings

Result

TypeDescription
itemNamespaceUpdated namespace

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &chat.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
        Description: pointy.String("description1"),
        AllowCreateRoom: pointy.Bool(false),
        PostMessageScript: nil,
        CreateRoomScript: nil,
        DeleteRoomScript: nil,
        SubscribeRoomScript: nil,
        UnsubscribeRoomScript: nil,
        PostNotification: nil,
        LogSetting: &chat.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UpdateNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateNamespace(
        (new UpdateNamespaceRequest())
            ->withNamespaceName(self::namespace1)
            ->withDescription("description1")
            ->withAllowCreateRoom(False)
            ->withPostMessageScript(null)
            ->withCreateRoomScript(null)
            ->withDeleteRoomScript(null)
            ->withSubscribeRoomScript(null)
            ->withUnsubscribeRoomScript(null)
            ->withPostNotification(null)
            ->withLogSetting((new \Gs2\Chat\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:\namespace1"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UpdateNamespaceRequest;
import io.gs2.chat.result.UpdateNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withAllowCreateRoom(false)
            .withPostMessageScript(null)
            .withCreateRoomScript(null)
            .withDeleteRoomScript(null)
            .withSubscribeRoomScript(null)
            .withUnsubscribeRoomScript(null)
            .withPostNotification(null)
            .withLogSetting(new io.gs2.chat.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UpdateNamespaceRequest;
using Gs2.Gs2Chat.Result.UpdateNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
    new Gs2.Gs2Chat.Request.UpdateNamespaceRequest()
        .WithNamespaceName("namespace1")
        .WithDescription("description1")
        .WithAllowCreateRoom(false)
        .WithPostMessageScript(null)
        .WithCreateRoomScript(null)
        .WithDeleteRoomScript(null)
        .WithSubscribeRoomScript(null)
        .WithUnsubscribeRoomScript(null)
        .WithPostNotification(null)
        .WithLogSetting(new Gs2.Gs2Chat.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.updateNamespace(
        new Gs2Chat.UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withAllowCreateRoom(false)
            .withPostMessageScript(null)
            .withCreateRoomScript(null)
            .withDeleteRoomScript(null)
            .withSubscribeRoomScript(null)
            .withUnsubscribeRoomScript(null)
            .withPostNotification(null)
            .withLogSetting(new Gs2Chat.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.update_namespace(
        chat.UpdateNamespaceRequest()
            .with_namespace_name(self.hash1)
            .with_description('description1')
            .with_allow_create_room(False)
            .with_post_message_script(None)
            .with_create_room_script(None)
            .with_delete_room_script(None)
            .with_subscribe_room_script(None)
            .with_unsubscribe_room_script(None)
            .with_post_notification(None)
            .with_log_setting(
                chat.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.update_namespace({
    namespaceName="namespace1",
    description="description1",
    allowCreateRoom=false,
    postMessageScript=nil,
    createRoomScript=nil,
    deleteRoomScript=nil,
    subscribeRoomScript=nil,
    unsubscribeRoomScript=nil,
    postNotification=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

deleteNamespace

Delete namespace

Delete the specified namespace. This operation is irreversible and all data associated with the deleted namespace will be lost.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name

Result

TypeDescription
itemNamespaceDeleted namespace

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DeleteNamespace(
    &chat.DeleteNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DeleteNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteNamespace(
        (new DeleteNamespaceRequest())
            ->withNamespaceName(self::namespace1)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DeleteNamespaceRequest;
import io.gs2.chat.result.DeleteNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DeleteNamespaceResult result = client.deleteNamespace(
        new DeleteNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DeleteNamespaceRequest;
using Gs2.Gs2Chat.Result.DeleteNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
    new Gs2.Gs2Chat.Request.DeleteNamespaceRequest()
        .WithNamespaceName("namespace1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.deleteNamespace(
        new Gs2Chat.DeleteNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.delete_namespace(
        chat.DeleteNamespaceRequest()
            .with_namespace_name(self.hash1)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.delete_namespace({
    namespaceName="namespace1",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

dumpUserDataByUserId

Get dump data of the data associated with the specified user ID

Can be used to meet legal requirements for the protection of personal information, or to back up or migrate data.

Request

TypeConditionRequireDefaultLimitationDescription
userIdstring~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DumpUserDataByUserId(
    &chat.DumpUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DumpUserDataByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->dumpUserDataByUserId(
        (new DumpUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DumpUserDataByUserIdRequest;
import io.gs2.chat.result.DumpUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DumpUserDataByUserIdResult result = client.dumpUserDataByUserId(
        new DumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DumpUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.DumpUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DumpUserDataByUserIdResult> asyncResult = null;
yield return client.DumpUserDataByUserId(
    new Gs2.Gs2Chat.Request.DumpUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.dumpUserDataByUserId(
        new Gs2Chat.DumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.dump_user_data_by_user_id(
        chat.DumpUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.dump_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result

checkDumpUserDataByUserId

Check if the dump of the data associated with the specified user ID is complete

Request

TypeConditionRequireDefaultLimitationDescription
userIdstring~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
urlstringURL of output data

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CheckDumpUserDataByUserId(
    &chat.CheckDumpUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
url := result.Url
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CheckDumpUserDataByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->checkDumpUserDataByUserId(
        (new CheckDumpUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
    $url = $result->getUrl();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CheckDumpUserDataByUserIdRequest;
import io.gs2.chat.result.CheckDumpUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    CheckDumpUserDataByUserIdResult result = client.checkDumpUserDataByUserId(
        new CheckDumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    String url = result.getUrl();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CheckDumpUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.CheckDumpUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CheckDumpUserDataByUserIdResult> asyncResult = null;
yield return client.CheckDumpUserDataByUserId(
    new Gs2.Gs2Chat.Request.CheckDumpUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var url = result.Url;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.checkDumpUserDataByUserId(
        new Gs2Chat.CheckDumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    const url = result.getUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.check_dump_user_data_by_user_id(
        chat.CheckDumpUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
    url = result.url
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.check_dump_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
url = result.url;

cleanUserDataByUserId

Delete user data

Execute cleaning of data associated with the specified user ID This allows you to safely delete specific user data from the project.

Request

TypeConditionRequireDefaultLimitationDescription
userIdstring~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CleanUserDataByUserId(
    &chat.CleanUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CleanUserDataByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->cleanUserDataByUserId(
        (new CleanUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CleanUserDataByUserIdRequest;
import io.gs2.chat.result.CleanUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    CleanUserDataByUserIdResult result = client.cleanUserDataByUserId(
        new CleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CleanUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.CleanUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CleanUserDataByUserIdResult> asyncResult = null;
yield return client.CleanUserDataByUserId(
    new Gs2.Gs2Chat.Request.CleanUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.cleanUserDataByUserId(
        new Gs2Chat.CleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.clean_user_data_by_user_id(
        chat.CleanUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.clean_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result

checkCleanUserDataByUserId

Check if the cleaning of the data associated with the specified user ID is complete

Request

TypeConditionRequireDefaultLimitationDescription
userIdstring~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CheckCleanUserDataByUserId(
    &chat.CheckCleanUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CheckCleanUserDataByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->checkCleanUserDataByUserId(
        (new CheckCleanUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CheckCleanUserDataByUserIdRequest;
import io.gs2.chat.result.CheckCleanUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    CheckCleanUserDataByUserIdResult result = client.checkCleanUserDataByUserId(
        new CheckCleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CheckCleanUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.CheckCleanUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CheckCleanUserDataByUserIdResult> asyncResult = null;
yield return client.CheckCleanUserDataByUserId(
    new Gs2.Gs2Chat.Request.CheckCleanUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.checkCleanUserDataByUserId(
        new Gs2Chat.CheckCleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.check_clean_user_data_by_user_id(
        chat.CheckCleanUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.check_clean_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result

prepareImportUserDataByUserId

Execute import of data associated with the specified user ID

The data that can be used for import is limited to the data exported by GS2, and old data may fail to import. You can import data with a user ID different from the one you exported, but if the user ID is included in the payload of the user data, this may not be the case.

You can start the actual import process by uploading the exported zip file to the URL returned in the return value of this API and calling importUserDataByUserId.

Request

TypeConditionRequireDefaultLimitationDescription
userIdstring~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
uploadTokenstringToken used to reflect results after upload
uploadUrlstringURL used to upload user data

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.PrepareImportUserDataByUserId(
    &chat.PrepareImportUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrl
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\PrepareImportUserDataByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->prepareImportUserDataByUserId(
        (new PrepareImportUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
    $uploadToken = $result->getUploadToken();
    $uploadUrl = $result->getUploadUrl();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.PrepareImportUserDataByUserIdRequest;
import io.gs2.chat.result.PrepareImportUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    PrepareImportUserDataByUserIdResult result = client.prepareImportUserDataByUserId(
        new PrepareImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    String uploadToken = result.getUploadToken();
    String uploadUrl = result.getUploadUrl();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.PrepareImportUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.PrepareImportUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.PrepareImportUserDataByUserIdResult> asyncResult = null;
yield return client.PrepareImportUserDataByUserId(
    new Gs2.Gs2Chat.Request.PrepareImportUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var uploadToken = result.UploadToken;
var uploadUrl = result.UploadUrl;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.prepareImportUserDataByUserId(
        new Gs2Chat.PrepareImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    const uploadToken = result.getUploadToken();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.prepare_import_user_data_by_user_id(
        chat.PrepareImportUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
    upload_token = result.upload_token
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.prepare_import_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;

importUserDataByUserId

Execute import of data associated with the specified user ID

The data that can be used for import is limited to the data exported by GS2, and old data may fail to import. You can import data with a user ID different from the one you exported, but if the user ID is included in the payload of the user data, this may not be the case.

Before calling this API, you must call prepareImportUserDataByUserId to complete the upload preparation.

Request

TypeConditionRequireDefaultLimitationDescription
userIdstring~ 128 charsUser Id
uploadTokenstring~ 1024 charsToken received in preparation for upload
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.ImportUserDataByUserId(
    &chat.ImportUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        UploadToken: pointy.String("upload-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\ImportUserDataByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->importUserDataByUserId(
        (new ImportUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withUploadToken("upload-0001")
            ->withTimeOffsetToken(null)
    );
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.ImportUserDataByUserIdRequest;
import io.gs2.chat.result.ImportUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    ImportUserDataByUserIdResult result = client.importUserDataByUserId(
        new ImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.ImportUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.ImportUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.ImportUserDataByUserIdResult> asyncResult = null;
yield return client.ImportUserDataByUserId(
    new Gs2.Gs2Chat.Request.ImportUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithUploadToken("upload-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.importUserDataByUserId(
        new Gs2Chat.ImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.import_user_data_by_user_id(
        chat.ImportUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_upload_token('upload-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.import_user_data_by_user_id({
    userId="user-0001",
    uploadToken="upload-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result

checkImportUserDataByUserId

Check if the import of the data associated with the specified user ID is complete

Request

TypeConditionRequireDefaultLimitationDescription
userIdstring~ 128 charsUser Id
uploadTokenstring~ 1024 charsToken received in preparation for upload
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
urlstringURL of log data

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CheckImportUserDataByUserId(
    &chat.CheckImportUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        UploadToken: pointy.String("upload-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
url := result.Url
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CheckImportUserDataByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->checkImportUserDataByUserId(
        (new CheckImportUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withUploadToken("upload-0001")
            ->withTimeOffsetToken(null)
    );
    $url = $result->getUrl();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CheckImportUserDataByUserIdRequest;
import io.gs2.chat.result.CheckImportUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    CheckImportUserDataByUserIdResult result = client.checkImportUserDataByUserId(
        new CheckImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
    String url = result.getUrl();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CheckImportUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.CheckImportUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CheckImportUserDataByUserIdResult> asyncResult = null;
yield return client.CheckImportUserDataByUserId(
    new Gs2.Gs2Chat.Request.CheckImportUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithUploadToken("upload-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var url = result.Url;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.checkImportUserDataByUserId(
        new Gs2Chat.CheckImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
    const url = result.getUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.check_import_user_data_by_user_id(
        chat.CheckImportUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_upload_token('upload-0001')
            .with_time_offset_token(None)
    )
    url = result.url
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.check_import_user_data_by_user_id({
    userId="user-0001",
    uploadToken="upload-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
url = result.url;

describeRooms

Get list of rooms

You can get a list of rooms by specifying a page token and a limit on the number of acquisitions. This allows you to check the overview of existing rooms.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<Room>List of Room
nextPageTokenstringPage token to retrieve the rest of the listing

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeRooms(
    &chat.DescribeRoomsRequest {
        NamespaceName: pointy.String("namespace1"),
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeRoomsRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeRooms(
        (new DescribeRoomsRequest())
            ->withNamespaceName(self::namespace1)
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeRoomsRequest;
import io.gs2.chat.result.DescribeRoomsResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DescribeRoomsResult result = client.describeRooms(
        new DescribeRoomsRequest()
            .withNamespaceName("namespace1")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Room> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DescribeRoomsRequest;
using Gs2.Gs2Chat.Result.DescribeRoomsResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DescribeRoomsResult> asyncResult = null;
yield return client.DescribeRooms(
    new Gs2.Gs2Chat.Request.DescribeRoomsRequest()
        .WithNamespaceName("namespace1")
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.describeRooms(
        new Gs2Chat.DescribeRoomsRequest()
            .withNamespaceName("namespace1")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.describe_rooms(
        chat.DescribeRoomsRequest()
            .with_namespace_name(self.hash1)
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.describe_rooms({
    namespaceName="namespace1",
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

createRoom

Create Room

You can create a room by specifying a room name, user ID, metadata, password, and user ID to be registered in the whitelist. The room name is optional, and if omitted, a UUID will be automatically assigned. It is used to create a new communication space.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
accessTokenstring~ 128 charsOwner User ID
namestringUUID~ 128 charsRoom Name
metadatastring~ 1024 charsmetadata
passwordstring~ 128 charsPassword required to access the room
whiteListUserIdsList<string>[]~ 1000 itemsList of user IDs with access to the room

Result

TypeDescription
itemRoomRoom created

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CreateRoom(
    &chat.CreateRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        AccessToken: pointy.String("accessToken-0001"),
        Name: pointy.String("room-0001"),
        Metadata: nil,
        Password: nil,
        WhiteListUserIds: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CreateRoomRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->createRoom(
        (new CreateRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withAccessToken(self::$accessToken0001)
            ->withName("room-0001")
            ->withMetadata(null)
            ->withPassword(null)
            ->withWhiteListUserIds(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CreateRoomRequest;
import io.gs2.chat.result.CreateRoomResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    CreateRoomResult result = client.createRoom(
        new CreateRoomRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withName("room-0001")
            .withMetadata(null)
            .withPassword(null)
            .withWhiteListUserIds(null)
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CreateRoomRequest;
using Gs2.Gs2Chat.Result.CreateRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CreateRoomResult> asyncResult = null;
yield return client.CreateRoom(
    new Gs2.Gs2Chat.Request.CreateRoomRequest()
        .WithNamespaceName("namespace1")
        .WithAccessToken("accessToken-0001")
        .WithName("room-0001")
        .WithMetadata(null)
        .WithPassword(null)
        .WithWhiteListUserIds(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.createRoom(
        new Gs2Chat.CreateRoomRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withName("room-0001")
            .withMetadata(null)
            .withPassword(null)
            .withWhiteListUserIds(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.create_room(
        chat.CreateRoomRequest()
            .with_namespace_name(self.hash1)
            .with_access_token(self.access_token_0001)
            .with_name('room-0001')
            .with_metadata(None)
            .with_password(None)
            .with_white_list_user_ids(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.create_room({
    namespaceName="namespace1",
    accessToken="accessToken-0001",
    name="room-0001",
    metadata=nil,
    password=nil,
    whiteListUserIds=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

createRoomFromBackend

Create Room from Backend

This API is not called by game players, but is used when creating rooms related to the system.

You can create a room by specifying a room name, user ID, metadata, password, and user ID to be registered in the whitelist. The room name is optional, and if omitted, a UUID will be automatically assigned. It is used to create a new communication space.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
namestringUUID~ 128 charsRoom Name
userIdstring~ 128 charsOwner User ID
metadatastring~ 1024 charsmetadata
passwordstring~ 128 charsPassword required to access the room
whiteListUserIdsList<string>[]~ 1000 itemsList of user IDs with access to the room
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemRoomRoom created

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CreateRoomFromBackend(
    &chat.CreateRoomFromBackendRequest {
        NamespaceName: pointy.String("namespace1"),
        Name: pointy.String("room-0001"),
        UserId: nil,
        Metadata: nil,
        Password: nil,
        WhiteListUserIds: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CreateRoomFromBackendRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->createRoomFromBackend(
        (new CreateRoomFromBackendRequest())
            ->withNamespaceName(self::namespace1)
            ->withName("room-0001")
            ->withUserId(null)
            ->withMetadata(null)
            ->withPassword(null)
            ->withWhiteListUserIds(null)
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CreateRoomFromBackendRequest;
import io.gs2.chat.result.CreateRoomFromBackendResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    CreateRoomFromBackendResult result = client.createRoomFromBackend(
        new CreateRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withName("room-0001")
            .withUserId(null)
            .withMetadata(null)
            .withPassword(null)
            .withWhiteListUserIds(null)
            .withTimeOffsetToken(null)
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CreateRoomFromBackendRequest;
using Gs2.Gs2Chat.Result.CreateRoomFromBackendResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CreateRoomFromBackendResult> asyncResult = null;
yield return client.CreateRoomFromBackend(
    new Gs2.Gs2Chat.Request.CreateRoomFromBackendRequest()
        .WithNamespaceName("namespace1")
        .WithName("room-0001")
        .WithUserId(null)
        .WithMetadata(null)
        .WithPassword(null)
        .WithWhiteListUserIds(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.createRoomFromBackend(
        new Gs2Chat.CreateRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withName("room-0001")
            .withUserId(null)
            .withMetadata(null)
            .withPassword(null)
            .withWhiteListUserIds(null)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.create_room_from_backend(
        chat.CreateRoomFromBackendRequest()
            .with_namespace_name(self.hash1)
            .with_name('room-0001')
            .with_user_id(None)
            .with_metadata(None)
            .with_password(None)
            .with_white_list_user_ids(None)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.create_room_from_backend({
    namespaceName="namespace1",
    name="room-0001",
    userId=nil,
    metadata=nil,
    password=nil,
    whiteListUserIds=nil,
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

getRoom

Get room information

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestringUUID~ 128 charsRoom Name

Result

TypeDescription
itemRoomRoom

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetRoom(
    &chat.GetRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetRoomRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getRoom(
        (new GetRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName("room-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetRoomRequest;
import io.gs2.chat.result.GetRoomResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    GetRoomResult result = client.getRoom(
        new GetRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetRoomRequest;
using Gs2.Gs2Chat.Result.GetRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetRoomResult> asyncResult = null;
yield return client.GetRoom(
    new Gs2.Gs2Chat.Request.GetRoomRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.getRoom(
        new Gs2Chat.GetRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.get_room(
        chat.GetRoomRequest()
            .with_namespace_name(self.hash1)
            .with_room_name('room-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_room({
    namespaceName="namespace1",
    roomName="room-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

updateRoom

Update Room

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestringUUID~ 128 charsRoom Name
metadatastring~ 1024 charsmetadata
passwordstring~ 128 charsPassword required to access the room
whiteListUserIdsList<string>[]~ 1000 itemsList of user IDs with access to the room
accessTokenstring~ 128 charsOwner User ID

Result

TypeDescription
itemRoomUpdated Rooms

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.UpdateRoom(
    &chat.UpdateRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        Metadata: nil,
        Password: pointy.String("password-0002"),
        WhiteListUserIds: []*string{
            pointy.String("user-0001"),
            pointy.String("user-0002"),
            pointy.String("user-0003"),
        },
        AccessToken: pointy.String("accessToken-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UpdateRoomRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateRoom(
        (new UpdateRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withMetadata(null)
            ->withPassword("password-0002")
            ->withWhiteListUserIds([
                "user-0001",
                "user-0002",
                "user-0003",
            ])
            ->withAccessToken(self::$accessToken0001)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UpdateRoomRequest;
import io.gs2.chat.result.UpdateRoomResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    UpdateRoomResult result = client.updateRoom(
        new UpdateRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMetadata(null)
            .withPassword("password-0002")
            .withWhiteListUserIds(Arrays.asList(
                "user-0001",
                "user-0002",
                "user-0003"
            ))
            .withAccessToken("accessToken-0001")
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UpdateRoomRequest;
using Gs2.Gs2Chat.Result.UpdateRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UpdateRoomResult> asyncResult = null;
yield return client.UpdateRoom(
    new Gs2.Gs2Chat.Request.UpdateRoomRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithMetadata(null)
        .WithPassword("password-0002")
        .WithWhiteListUserIds(new string[] {
            "user-0001",
            "user-0002",
            "user-0003",
        })
        .WithAccessToken("accessToken-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.updateRoom(
        new Gs2Chat.UpdateRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMetadata(null)
            .withPassword("password-0002")
            .withWhiteListUserIds([
                "user-0001",
                "user-0002",
                "user-0003",
            ])
            .withAccessToken("accessToken-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.update_room(
        chat.UpdateRoomRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_metadata(None)
            .with_password('password-0002')
            .with_white_list_user_ids([
                'user-0001',
                'user-0002',
                'user-0003',
            ])
            .with_access_token(self.access_token_0001)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.update_room({
    namespaceName="namespace1",
    roomName="room-0001",
    metadata=nil,
    password="password-0002",
    whiteListUserIds={
        "user-0001",
        "user-0002",
        "user-0003"
    },
    accessToken="accessToken-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

updateRoomFromBackend

Update Room from Backend

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestringUUID~ 128 charsRoom Name
metadatastring~ 1024 charsmetadata
passwordstring~ 128 charsPassword required to access the room
whiteListUserIdsList<string>[]~ 1000 itemsList of user IDs with access to the room
userIdstring~ 128 charsOwner User ID
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemRoomUpdated Rooms

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.UpdateRoomFromBackend(
    &chat.UpdateRoomFromBackendRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        Metadata: pointy.String("ROOM_0001"),
        Password: pointy.String("password-0003"),
        WhiteListUserIds: []*string{
            pointy.String("user-0001"),
            pointy.String("user-0002"),
            pointy.String("user-0003"),
        },
        UserId: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UpdateRoomFromBackendRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateRoomFromBackend(
        (new UpdateRoomFromBackendRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName("room-0001")
            ->withMetadata("ROOM_0001")
            ->withPassword("password-0003")
            ->withWhiteListUserIds([
                "user-0001",
                "user-0002",
                "user-0003",
            ])
            ->withUserId(null)
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UpdateRoomFromBackendRequest;
import io.gs2.chat.result.UpdateRoomFromBackendResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    UpdateRoomFromBackendResult result = client.updateRoomFromBackend(
        new UpdateRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMetadata("ROOM_0001")
            .withPassword("password-0003")
            .withWhiteListUserIds(Arrays.asList(
                "user-0001",
                "user-0002",
                "user-0003"
            ))
            .withUserId(null)
            .withTimeOffsetToken(null)
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UpdateRoomFromBackendRequest;
using Gs2.Gs2Chat.Result.UpdateRoomFromBackendResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UpdateRoomFromBackendResult> asyncResult = null;
yield return client.UpdateRoomFromBackend(
    new Gs2.Gs2Chat.Request.UpdateRoomFromBackendRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithMetadata("ROOM_0001")
        .WithPassword("password-0003")
        .WithWhiteListUserIds(new string[] {
            "user-0001",
            "user-0002",
            "user-0003",
        })
        .WithUserId(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.updateRoomFromBackend(
        new Gs2Chat.UpdateRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMetadata("ROOM_0001")
            .withPassword("password-0003")
            .withWhiteListUserIds([
                "user-0001",
                "user-0002",
                "user-0003",
            ])
            .withUserId(null)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.update_room_from_backend(
        chat.UpdateRoomFromBackendRequest()
            .with_namespace_name(self.hash1)
            .with_room_name('room-0001')
            .with_metadata('ROOM_0001')
            .with_password('password-0003')
            .with_white_list_user_ids([
                'user-0001',
                'user-0002',
                'user-0003',
            ])
            .with_user_id(None)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.update_room_from_backend({
    namespaceName="namespace1",
    roomName="room-0001",
    metadata="ROOM_0001",
    password="password-0003",
    whiteListUserIds={
        "user-0001",
        "user-0002",
        "user-0003"
    },
    userId=nil,
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

deleteRoom

Delete Room

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestringUUID~ 128 charsRoom Name
accessTokenstring~ 128 charsOwner User ID

Result

TypeDescription
itemRoomDeleted Rooms

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DeleteRoom(
    &chat.DeleteRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        AccessToken: pointy.String("accessToken-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DeleteRoomRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteRoom(
        (new DeleteRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withAccessToken(self::$accessToken0001)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DeleteRoomRequest;
import io.gs2.chat.result.DeleteRoomResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DeleteRoomResult result = client.deleteRoom(
        new DeleteRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DeleteRoomRequest;
using Gs2.Gs2Chat.Result.DeleteRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DeleteRoomResult> asyncResult = null;
yield return client.DeleteRoom(
    new Gs2.Gs2Chat.Request.DeleteRoomRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithAccessToken("accessToken-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.deleteRoom(
        new Gs2Chat.DeleteRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.delete_room(
        chat.DeleteRoomRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.delete_room({
    namespaceName="namespace1",
    roomName="room-0001",
    accessToken="accessToken-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

deleteRoomFromBackend

Delete Room from Backend

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestringUUID~ 128 charsRoom Name
userIdstring~ 128 charsOwner User ID
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemRoomDeleted Rooms

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DeleteRoomFromBackend(
    &chat.DeleteRoomFromBackendRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        UserId: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DeleteRoomFromBackendRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteRoomFromBackend(
        (new DeleteRoomFromBackendRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName("room-0001")
            ->withUserId(null)
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DeleteRoomFromBackendRequest;
import io.gs2.chat.result.DeleteRoomFromBackendResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DeleteRoomFromBackendResult result = client.deleteRoomFromBackend(
        new DeleteRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId(null)
            .withTimeOffsetToken(null)
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DeleteRoomFromBackendRequest;
using Gs2.Gs2Chat.Result.DeleteRoomFromBackendResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DeleteRoomFromBackendResult> asyncResult = null;
yield return client.DeleteRoomFromBackend(
    new Gs2.Gs2Chat.Request.DeleteRoomFromBackendRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithUserId(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.deleteRoomFromBackend(
        new Gs2Chat.DeleteRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId(null)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.delete_room_from_backend(
        chat.DeleteRoomFromBackendRequest()
            .with_namespace_name(self.hash1)
            .with_room_name('room-0001')
            .with_user_id(None)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.delete_room_from_backend({
    namespaceName="namespace1",
    roomName="room-0001",
    userId=nil,
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

describeMessages

Get list of messages

You can specify the room name, the start time of acquisition, and the limit on the number of acquisitions to get the messages in the room. If a password is set for the room, you will need to enter the password.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom Name
passwordstring~ 128 charsPassword required to receive messages
accessTokenstring~ 128 charsUser Id
startAtlongDifference from current time(-1 hours)Time to start retrieving messages
limitint301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<Message>List of Message

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeMessages(
    &chat.DescribeMessagesRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        Password: nil,
        AccessToken: pointy.String("accessToken-0001"),
        StartAt: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeMessagesRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeMessages(
        (new DescribeMessagesRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withPassword(null)
            ->withAccessToken(self::$accessToken0001)
            ->withStartAt(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeMessagesRequest;
import io.gs2.chat.result.DescribeMessagesResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DescribeMessagesResult result = client.describeMessages(
        new DescribeMessagesRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withPassword(null)
            .withAccessToken("accessToken-0001")
            .withStartAt(null)
            .withLimit(null)
    );
    List<Message> items = result.getItems();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DescribeMessagesRequest;
using Gs2.Gs2Chat.Result.DescribeMessagesResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DescribeMessagesResult> asyncResult = null;
yield return client.DescribeMessages(
    new Gs2.Gs2Chat.Request.DescribeMessagesRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithPassword(null)
        .WithAccessToken("accessToken-0001")
        .WithStartAt(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.describeMessages(
        new Gs2Chat.DescribeMessagesRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withPassword(null)
            .withAccessToken("accessToken-0001")
            .withStartAt(null)
            .withLimit(null)
    );
    const items = result.getItems();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.describe_messages(
        chat.DescribeMessagesRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_password(None)
            .with_access_token(self.access_token_0001)
            .with_start_at(None)
            .with_limit(None)
    )
    items = result.items
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.describe_messages({
    namespaceName="namespace1",
    roomName="room-0001",
    password=nil,
    accessToken="accessToken-0001",
    startAt=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;

describeMessagesByUserId

Get list of messages specifying user ID

You can specify the room name, the start time of acquisition, and the limit on the number of acquisitions to get the messages in the room. If a password is set for the room, you will need to enter the password.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom Name
passwordstring~ 128 charsPassword required to receive messages
userIdstring~ 128 charsUser Id
startAtlongDifference from current time(-1 hours)Time to start retrieving messages
limitint301 ~ 1000Number of data acquired
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemsList<Message>List of Message

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeMessagesByUserId(
    &chat.DescribeMessagesByUserIdRequest {
        NamespaceName: pointy.String("$namespace1.name"),
        RoomName: pointy.String("room-0001"),
        Password: nil,
        UserId: pointy.String("user-0002"),
        StartAt: nil,
        Limit: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeMessagesByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeMessagesByUserId(
        (new DescribeMessagesByUserIdRequest())
            ->withNamespaceName(self::$namespace1.name)
            ->withRoomName(self::room-0001)
            ->withPassword(null)
            ->withUserId("user-0002")
            ->withStartAt(null)
            ->withLimit(null)
            ->withTimeOffsetToken(null)
    );
    $items = $result->getItems();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeMessagesByUserIdRequest;
import io.gs2.chat.result.DescribeMessagesByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DescribeMessagesByUserIdResult result = client.describeMessagesByUserId(
        new DescribeMessagesByUserIdRequest()
            .withNamespaceName("$namespace1.name")
            .withRoomName("room-0001")
            .withPassword(null)
            .withUserId("user-0002")
            .withStartAt(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    List<Message> items = result.getItems();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DescribeMessagesByUserIdRequest;
using Gs2.Gs2Chat.Result.DescribeMessagesByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DescribeMessagesByUserIdResult> asyncResult = null;
yield return client.DescribeMessagesByUserId(
    new Gs2.Gs2Chat.Request.DescribeMessagesByUserIdRequest()
        .WithNamespaceName("$namespace1.name")
        .WithRoomName("room-0001")
        .WithPassword(null)
        .WithUserId("user-0002")
        .WithStartAt(null)
        .WithLimit(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.describeMessagesByUserId(
        new Gs2Chat.DescribeMessagesByUserIdRequest()
            .withNamespaceName("$namespace1.name")
            .withRoomName("room-0001")
            .withPassword(null)
            .withUserId("user-0002")
            .withStartAt(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    const items = result.getItems();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.describe_messages_by_user_id(
        chat.DescribeMessagesByUserIdRequest()
            .with_namespace_name(self.namespace1.name)
            .with_room_name(self.room1.name)
            .with_password(None)
            .with_user_id('user-0002')
            .with_start_at(None)
            .with_limit(None)
            .with_time_offset_token(None)
    )
    items = result.items
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.describe_messages_by_user_id({
    namespaceName="$namespace1.name",
    roomName="room-0001",
    password=nil,
    userId="user-0002",
    startAt=nil,
    limit=nil,
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;

post

Post a message

You can post a message by specifying the room name, category, metadata, and password (if set for the room).

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom Name
accessTokenstring~ 128 charsUser Id
categoryint0~ 2147483645Type number when you want to classify message types.
metadatastring~ 1024 charsmetadata
passwordstring~ 128 charsPassword

Result

TypeDescription
itemMessagePosted message

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.Post(
    &chat.PostRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        Category: nil,
        Metadata: pointy.String("MESSAGE_0001"),
        Password: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\PostRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->post(
        (new PostRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withAccessToken(self::$accessToken0001)
            ->withCategory(null)
            ->withMetadata("MESSAGE_0001")
            ->withPassword(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.PostRequest;
import io.gs2.chat.result.PostResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    PostResult result = client.post(
        new PostRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
            .withCategory(null)
            .withMetadata("MESSAGE_0001")
            .withPassword(null)
    );
    Message item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.PostRequest;
using Gs2.Gs2Chat.Result.PostResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.PostResult> asyncResult = null;
yield return client.Post(
    new Gs2.Gs2Chat.Request.PostRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithAccessToken("accessToken-0001")
        .WithCategory(null)
        .WithMetadata("MESSAGE_0001")
        .WithPassword(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.post(
        new Gs2Chat.PostRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
            .withCategory(null)
            .withMetadata("MESSAGE_0001")
            .withPassword(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.post(
        chat.PostRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
            .with_category(None)
            .with_metadata('MESSAGE_0001')
            .with_password(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.post({
    namespaceName="namespace1",
    roomName="room-0001",
    accessToken="accessToken-0001",
    category=nil,
    metadata="MESSAGE_0001",
    password=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

postByUserId

Post a message specifying user ID

You can post a message by specifying the room name, category, metadata, and password (if set for the room).

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom Name
userIdstring~ 128 charsUser Id
categoryint0~ 2147483645Type number when you want to classify message types.
metadatastring~ 1024 charsmetadata
passwordstring~ 128 charsPassword
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemMessagePosted message

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.PostByUserId(
    &chat.PostByUserIdRequest {
        NamespaceName: pointy.String("$namespace1.name"),
        RoomName: pointy.String("$room2.name"),
        UserId: pointy.String("user-0002"),
        Category: nil,
        Metadata: pointy.String("MESSAGE_0003"),
        Password: pointy.String("password-0002"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\PostByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->postByUserId(
        (new PostByUserIdRequest())
            ->withNamespaceName(self::$namespace1.name)
            ->withRoomName(self::$room2.name)
            ->withUserId("user-0002")
            ->withCategory(null)
            ->withMetadata("MESSAGE_0003")
            ->withPassword("password-0002")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.PostByUserIdRequest;
import io.gs2.chat.result.PostByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    PostByUserIdResult result = client.postByUserId(
        new PostByUserIdRequest()
            .withNamespaceName("$namespace1.name")
            .withRoomName("$room2.name")
            .withUserId("user-0002")
            .withCategory(null)
            .withMetadata("MESSAGE_0003")
            .withPassword("password-0002")
            .withTimeOffsetToken(null)
    );
    Message item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.PostByUserIdRequest;
using Gs2.Gs2Chat.Result.PostByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.PostByUserIdResult> asyncResult = null;
yield return client.PostByUserId(
    new Gs2.Gs2Chat.Request.PostByUserIdRequest()
        .WithNamespaceName("$namespace1.name")
        .WithRoomName("$room2.name")
        .WithUserId("user-0002")
        .WithCategory(null)
        .WithMetadata("MESSAGE_0003")
        .WithPassword("password-0002")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.postByUserId(
        new Gs2Chat.PostByUserIdRequest()
            .withNamespaceName("$namespace1.name")
            .withRoomName("$room2.name")
            .withUserId("user-0002")
            .withCategory(null)
            .withMetadata("MESSAGE_0003")
            .withPassword("password-0002")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.post_by_user_id(
        chat.PostByUserIdRequest()
            .with_namespace_name(self.namespace1.name)
            .with_room_name(self.room2.name)
            .with_user_id('user-0002')
            .with_category(None)
            .with_metadata('MESSAGE_0003')
            .with_password('password-0002')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.post_by_user_id({
    namespaceName="$namespace1.name",
    roomName="$room2.name",
    userId="user-0002",
    category=nil,
    metadata="MESSAGE_0003",
    password="password-0002",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

getMessage

Get Message

You can specify the room name, message name, and password if necessary to get detailed information about a specific message.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom Name
messageNamestringUUID~ 36 charsMessage name
passwordstring~ 128 charsPassword
accessTokenstring~ 128 charsUser Id

Result

TypeDescription
itemMessageMessage

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetMessage(
    &chat.GetMessageRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        MessageName: pointy.String("message-0001"),
        Password: nil,
        AccessToken: pointy.String("accessToken-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetMessageRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getMessage(
        (new GetMessageRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withMessageName(self::message-0001)
            ->withPassword(null)
            ->withAccessToken(self::$accessToken0001)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetMessageRequest;
import io.gs2.chat.result.GetMessageResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    GetMessageResult result = client.getMessage(
        new GetMessageRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMessageName("message-0001")
            .withPassword(null)
            .withAccessToken("accessToken-0001")
    );
    Message item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetMessageRequest;
using Gs2.Gs2Chat.Result.GetMessageResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetMessageResult> asyncResult = null;
yield return client.GetMessage(
    new Gs2.Gs2Chat.Request.GetMessageRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithMessageName("message-0001")
        .WithPassword(null)
        .WithAccessToken("accessToken-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.getMessage(
        new Gs2Chat.GetMessageRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMessageName("message-0001")
            .withPassword(null)
            .withAccessToken("accessToken-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.get_message(
        chat.GetMessageRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_message_name(self.message1.name)
            .with_password(None)
            .with_access_token(self.access_token_0001)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_message({
    namespaceName="namespace1",
    roomName="room-0001",
    messageName="message-0001",
    password=nil,
    accessToken="accessToken-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

getMessageByUserId

Get Message specifying user ID

You can specify the room name, message name, and password if necessary to get detailed information about a specific message.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom Name
messageNamestringUUID~ 36 charsMessage name
passwordstring~ 128 charsPassword
userIdstring~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemMessageMessage

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetMessageByUserId(
    &chat.GetMessageByUserIdRequest {
        NamespaceName: pointy.String("$namespace1.name"),
        RoomName: pointy.String("room-0001"),
        MessageName: pointy.String("message-0001"),
        Password: nil,
        UserId: pointy.String("user-0002"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetMessageByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getMessageByUserId(
        (new GetMessageByUserIdRequest())
            ->withNamespaceName(self::$namespace1.name)
            ->withRoomName(self::room-0001)
            ->withMessageName(self::message-0001)
            ->withPassword(null)
            ->withUserId("user-0002")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetMessageByUserIdRequest;
import io.gs2.chat.result.GetMessageByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    GetMessageByUserIdResult result = client.getMessageByUserId(
        new GetMessageByUserIdRequest()
            .withNamespaceName("$namespace1.name")
            .withRoomName("room-0001")
            .withMessageName("message-0001")
            .withPassword(null)
            .withUserId("user-0002")
            .withTimeOffsetToken(null)
    );
    Message item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetMessageByUserIdRequest;
using Gs2.Gs2Chat.Result.GetMessageByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetMessageByUserIdResult> asyncResult = null;
yield return client.GetMessageByUserId(
    new Gs2.Gs2Chat.Request.GetMessageByUserIdRequest()
        .WithNamespaceName("$namespace1.name")
        .WithRoomName("room-0001")
        .WithMessageName("message-0001")
        .WithPassword(null)
        .WithUserId("user-0002")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.getMessageByUserId(
        new Gs2Chat.GetMessageByUserIdRequest()
            .withNamespaceName("$namespace1.name")
            .withRoomName("room-0001")
            .withMessageName("message-0001")
            .withPassword(null)
            .withUserId("user-0002")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.get_message_by_user_id(
        chat.GetMessageByUserIdRequest()
            .with_namespace_name(self.namespace1.name)
            .with_room_name(self.room1.name)
            .with_message_name(self.message1.name)
            .with_password(None)
            .with_user_id('user-0002')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_message_by_user_id({
    namespaceName="$namespace1.name",
    roomName="room-0001",
    messageName="message-0001",
    password=nil,
    userId="user-0002",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

deleteMessage

Delete message

You can delete a specific message from the system.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom Name
userIdstring~ 128 charsUser Id
messageNamestringUUID~ 36 charsMessage name
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemMessageDeleted messages

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DeleteMessage(
    &chat.DeleteMessageRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        UserId: pointy.String("user-0001"),
        MessageName: pointy.String("message-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DeleteMessageRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteMessage(
        (new DeleteMessageRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withUserId("user-0001")
            ->withMessageName(self::message-0001)
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DeleteMessageRequest;
import io.gs2.chat.result.DeleteMessageResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DeleteMessageResult result = client.deleteMessage(
        new DeleteMessageRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withMessageName("message-0001")
            .withTimeOffsetToken(null)
    );
    Message item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DeleteMessageRequest;
using Gs2.Gs2Chat.Result.DeleteMessageResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DeleteMessageResult> asyncResult = null;
yield return client.DeleteMessage(
    new Gs2.Gs2Chat.Request.DeleteMessageRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithUserId("user-0001")
        .WithMessageName("message-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.deleteMessage(
        new Gs2Chat.DeleteMessageRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withMessageName("message-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.delete_message(
        chat.DeleteMessageRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_user_id('user-0001')
            .with_message_name(self.message1.name)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.delete_message({
    namespaceName="namespace1",
    roomName="room-0001",
    userId="user-0001",
    messageName="message-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

describeSubscribes

Obtaining list of subscribed rooms

You can get a list of subscriptions by specifying a page token and a limit on the number of acquisitions. This allows you to check an overview of the rooms that the user is subscribed to.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
accessTokenstring~ 128 charsUser Id
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<Subscribe>List of Subscribe
nextPageTokenstringPage token to retrieve the rest of the listing

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeSubscribes(
    &chat.DescribeSubscribesRequest {
        NamespaceName: pointy.String("namespace1"),
        AccessToken: pointy.String("accessToken-0001"),
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeSubscribesRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeSubscribes(
        (new DescribeSubscribesRequest())
            ->withNamespaceName(self::namespace1)
            ->withAccessToken(self::$accessToken0001)
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeSubscribesRequest;
import io.gs2.chat.result.DescribeSubscribesResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DescribeSubscribesResult result = client.describeSubscribes(
        new DescribeSubscribesRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Subscribe> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DescribeSubscribesRequest;
using Gs2.Gs2Chat.Result.DescribeSubscribesResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DescribeSubscribesResult> asyncResult = null;
yield return client.DescribeSubscribes(
    new Gs2.Gs2Chat.Request.DescribeSubscribesRequest()
        .WithNamespaceName("namespace1")
        .WithAccessToken("accessToken-0001")
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.describeSubscribes(
        new Gs2Chat.DescribeSubscribesRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.describe_subscribes(
        chat.DescribeSubscribesRequest()
            .with_namespace_name(self.hash1)
            .with_access_token(self.access_token_0001)
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.describe_subscribes({
    namespaceName="namespace1",
    accessToken="accessToken-0001",
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

describeSubscribesByUserId

Obtaining list of subscribed rooms by specifying user ID

You can get a list of subscriptions by specifying a page token and a limit on the number of acquisitions. This allows you to check an overview of the rooms that the user is subscribed to.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
userIdstring~ 128 charsUser Id
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint301 ~ 1000Number of data acquired
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemsList<Subscribe>List of Subscribe
nextPageTokenstringPage token to retrieve the rest of the listing

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeSubscribesByUserId(
    &chat.DescribeSubscribesByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        UserId: pointy.String("user-0001"),
        PageToken: nil,
        Limit: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeSubscribesByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeSubscribesByUserId(
        (new DescribeSubscribesByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withUserId("user-0001")
            ->withPageToken(null)
            ->withLimit(null)
            ->withTimeOffsetToken(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeSubscribesByUserIdRequest;
import io.gs2.chat.result.DescribeSubscribesByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DescribeSubscribesByUserIdResult result = client.describeSubscribesByUserId(
        new DescribeSubscribesByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    List<Subscribe> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DescribeSubscribesByUserIdRequest;
using Gs2.Gs2Chat.Result.DescribeSubscribesByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DescribeSubscribesByUserIdResult> asyncResult = null;
yield return client.DescribeSubscribesByUserId(
    new Gs2.Gs2Chat.Request.DescribeSubscribesByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithUserId("user-0001")
        .WithPageToken(null)
        .WithLimit(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.describeSubscribesByUserId(
        new Gs2Chat.DescribeSubscribesByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.describe_subscribes_by_user_id(
        chat.DescribeSubscribesByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
            .with_page_token(None)
            .with_limit(None)
            .with_time_offset_token(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.describe_subscribes_by_user_id({
    namespaceName="namespace1",
    userId="user-0001",
    pageToken=nil,
    limit=nil,
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

describeSubscribesByRoomName

Get a list of users subscribed to a room by specifying a room name

You can get a list of users subscribed to a room by specifying a page token and a limit on the number of acquisitions.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom name to subscribe to
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<Subscribe>List of Subscribe
nextPageTokenstringPage token to retrieve the rest of the listing

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeSubscribesByRoomName(
    &chat.DescribeSubscribesByRoomNameRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeSubscribesByRoomNameRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeSubscribesByRoomName(
        (new DescribeSubscribesByRoomNameRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeSubscribesByRoomNameRequest;
import io.gs2.chat.result.DescribeSubscribesByRoomNameResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    DescribeSubscribesByRoomNameResult result = client.describeSubscribesByRoomName(
        new DescribeSubscribesByRoomNameRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Subscribe> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DescribeSubscribesByRoomNameRequest;
using Gs2.Gs2Chat.Result.DescribeSubscribesByRoomNameResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DescribeSubscribesByRoomNameResult> asyncResult = null;
yield return client.DescribeSubscribesByRoomName(
    new Gs2.Gs2Chat.Request.DescribeSubscribesByRoomNameRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.describeSubscribesByRoomName(
        new Gs2Chat.DescribeSubscribesByRoomNameRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.describe_subscribes_by_room_name(
        chat.DescribeSubscribesByRoomNameRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.describe_subscribes_by_room_name({
    namespaceName="namespace1",
    roomName="room-0001",
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

subscribe

Subscribe to a room

This is used for users to receive message posting notifications to a specific room.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom name to subscribe to
accessTokenstring~ 128 charsUser Id
notificationTypesList<NotificationType>[]~ 100 itemsCategory list to receive notifications of new messages

Result

TypeDescription
itemSubscribeSubscribed Subscriptions

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.Subscribe(
    &chat.SubscribeRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        NotificationTypes: []chat.NotificationType{
            chat.NotificationType{
            },
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\SubscribeRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->subscribe(
        (new SubscribeRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withAccessToken(self::$accessToken0001)
            ->withNotificationTypes([
                (new \Gs2\Chat\Model\NotificationType()),
            ])
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.SubscribeRequest;
import io.gs2.chat.result.SubscribeResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    SubscribeResult result = client.subscribe(
        new SubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
            .withNotificationTypes(Arrays.asList(
                new io.gs2.chat.model.NotificationType()
            ))
    );
    Subscribe item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.SubscribeRequest;
using Gs2.Gs2Chat.Result.SubscribeResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.SubscribeResult> asyncResult = null;
yield return client.Subscribe(
    new Gs2.Gs2Chat.Request.SubscribeRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithAccessToken("accessToken-0001")
        .WithNotificationTypes(new Gs2.Gs2Chat.Model.NotificationType[] {
            new Gs2.Gs2Chat.Model.NotificationType(),
        }),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.subscribe(
        new Gs2Chat.SubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
            .withNotificationTypes([
                new Gs2Chat.model.NotificationType(),
            ])
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.subscribe(
        chat.SubscribeRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
            .with_notification_types([
                chat.NotificationType(),
            ])
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.subscribe({
    namespaceName="namespace1",
    roomName="room-0001",
    accessToken="accessToken-0001",
    notificationTypes={
        {
        }
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

subscribeByUserId

Subscribe to a room by specifying a user ID

This is used for users to receive message posting notifications to a specific room.

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom name to subscribe to
userIdstring~ 128 charsUser Id
notificationTypesList<NotificationType>[]~ 100 itemsCategory list to receive notifications of new messages
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemSubscribeSubscribed Subscriptions

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.SubscribeByUserId(
    &chat.SubscribeByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        UserId: pointy.String("user-0001"),
        NotificationTypes: []chat.NotificationType{
            *.NotificationType(),
        },
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\SubscribeByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->subscribeByUserId(
        (new SubscribeByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withUserId("user-0001")
            ->withNotificationTypes([
                NotificationType(),
            ])
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.SubscribeByUserIdRequest;
import io.gs2.chat.result.SubscribeByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    SubscribeByUserIdResult result = client.subscribeByUserId(
        new SubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withNotificationTypes(Arrays.asList(
                new NotificationType()
            ))
            .withTimeOffsetToken(null)
    );
    Subscribe item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.SubscribeByUserIdRequest;
using Gs2.Gs2Chat.Result.SubscribeByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.SubscribeByUserIdResult> asyncResult = null;
yield return client.SubscribeByUserId(
    new Gs2.Gs2Chat.Request.SubscribeByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithUserId("user-0001")
        .WithNotificationTypes(new Gs2.Gs2Chat.Model.NotificationType[] {
            new Gs2.Gs2Chat.Model.NotificationType(),
        })
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.subscribeByUserId(
        new Gs2Chat.SubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withNotificationTypes([
                new NotificationType(),
            ])
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.subscribe_by_user_id(
        chat.SubscribeByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_user_id('user-0001')
            .with_notification_types([
                NotificationType(),
            ])
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.subscribe_by_user_id({
    namespaceName="namespace1",
    roomName="room-0001",
    userId="user-0001",
    notificationTypes={
        {}
    },
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

getSubscribe

Get Subscription

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom name to subscribe to
accessTokenstring~ 128 charsUser Id

Result

TypeDescription
itemSubscribeSubscription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetSubscribe(
    &chat.GetSubscribeRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        AccessToken: pointy.String("accessToken-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetSubscribeRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getSubscribe(
        (new GetSubscribeRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withAccessToken(self::$accessToken0001)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetSubscribeRequest;
import io.gs2.chat.result.GetSubscribeResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    GetSubscribeResult result = client.getSubscribe(
        new GetSubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
    );
    Subscribe item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetSubscribeRequest;
using Gs2.Gs2Chat.Result.GetSubscribeResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetSubscribeResult> asyncResult = null;
yield return client.GetSubscribe(
    new Gs2.Gs2Chat.Request.GetSubscribeRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithAccessToken("accessToken-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.getSubscribe(
        new Gs2Chat.GetSubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.get_subscribe(
        chat.GetSubscribeRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_subscribe({
    namespaceName="namespace1",
    roomName="room-0001",
    accessToken="accessToken-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

getSubscribeByUserId

Get subscription by specifying user ID

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom name to subscribe to
userIdstring~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemSubscribeSubscription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetSubscribeByUserId(
    &chat.GetSubscribeByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetSubscribeByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getSubscribeByUserId(
        (new GetSubscribeByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetSubscribeByUserIdRequest;
import io.gs2.chat.result.GetSubscribeByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    GetSubscribeByUserIdResult result = client.getSubscribeByUserId(
        new GetSubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    Subscribe item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetSubscribeByUserIdRequest;
using Gs2.Gs2Chat.Result.GetSubscribeByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetSubscribeByUserIdResult> asyncResult = null;
yield return client.GetSubscribeByUserId(
    new Gs2.Gs2Chat.Request.GetSubscribeByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.getSubscribeByUserId(
        new Gs2Chat.GetSubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.get_subscribe_by_user_id(
        chat.GetSubscribeByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_subscribe_by_user_id({
    namespaceName="namespace1",
    roomName="room-0001",
    userId="user-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

updateNotificationType

Update notification methods

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom name to subscribe to
accessTokenstring~ 128 charsUser Id
notificationTypesList<NotificationType>[]~ 100 itemsCategory list to receive notifications of new messages

Result

TypeDescription
itemSubscribeRenewed Subscriptions

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.UpdateNotificationType(
    &chat.UpdateNotificationTypeRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        NotificationTypes: []chat.NotificationType{
            *.NotificationType(),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UpdateNotificationTypeRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateNotificationType(
        (new UpdateNotificationTypeRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withAccessToken(self::$accessToken0001)
            ->withNotificationTypes([
                NotificationType(),
            ])
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UpdateNotificationTypeRequest;
import io.gs2.chat.result.UpdateNotificationTypeResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    UpdateNotificationTypeResult result = client.updateNotificationType(
        new UpdateNotificationTypeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
            .withNotificationTypes(Arrays.asList(
                new NotificationType()
            ))
    );
    Subscribe item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UpdateNotificationTypeRequest;
using Gs2.Gs2Chat.Result.UpdateNotificationTypeResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UpdateNotificationTypeResult> asyncResult = null;
yield return client.UpdateNotificationType(
    new Gs2.Gs2Chat.Request.UpdateNotificationTypeRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithAccessToken("accessToken-0001")
        .WithNotificationTypes(new Gs2.Gs2Chat.Model.NotificationType[] {
            new Gs2.Gs2Chat.Model.NotificationType(),
        }),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.updateNotificationType(
        new Gs2Chat.UpdateNotificationTypeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
            .withNotificationTypes([
                new NotificationType(),
            ])
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.update_notification_type(
        chat.UpdateNotificationTypeRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
            .with_notification_types([
                NotificationType(),
            ])
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.update_notification_type({
    namespaceName="namespace1",
    roomName="room-0001",
    accessToken="accessToken-0001",
    notificationTypes={
        {}
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

updateNotificationTypeByUserId

Update notification method by specifying user ID

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom name to subscribe to
userIdstring~ 128 charsUser Id
notificationTypesList<NotificationType>[]~ 100 itemsCategory list to receive notifications of new messages
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemSubscribeRenewed Subscriptions

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.UpdateNotificationTypeByUserId(
    &chat.UpdateNotificationTypeByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        UserId: pointy.String("user-0001"),
        NotificationTypes: []chat.NotificationType{
            *.NotificationType(),
        },
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UpdateNotificationTypeByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateNotificationTypeByUserId(
        (new UpdateNotificationTypeByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withUserId("user-0001")
            ->withNotificationTypes([
                NotificationType(),
            ])
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UpdateNotificationTypeByUserIdRequest;
import io.gs2.chat.result.UpdateNotificationTypeByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    UpdateNotificationTypeByUserIdResult result = client.updateNotificationTypeByUserId(
        new UpdateNotificationTypeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withNotificationTypes(Arrays.asList(
                new NotificationType()
            ))
            .withTimeOffsetToken(null)
    );
    Subscribe item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UpdateNotificationTypeByUserIdRequest;
using Gs2.Gs2Chat.Result.UpdateNotificationTypeByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UpdateNotificationTypeByUserIdResult> asyncResult = null;
yield return client.UpdateNotificationTypeByUserId(
    new Gs2.Gs2Chat.Request.UpdateNotificationTypeByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithUserId("user-0001")
        .WithNotificationTypes(new Gs2.Gs2Chat.Model.NotificationType[] {
            new Gs2.Gs2Chat.Model.NotificationType(),
        })
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.updateNotificationTypeByUserId(
        new Gs2Chat.UpdateNotificationTypeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withNotificationTypes([
                new NotificationType(),
            ])
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.update_notification_type_by_user_id(
        chat.UpdateNotificationTypeByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_user_id('user-0001')
            .with_notification_types([
                NotificationType(),
            ])
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.update_notification_type_by_user_id({
    namespaceName="namespace1",
    roomName="room-0001",
    userId="user-0001",
    notificationTypes={
        {}
    },
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

unsubscribe

Unsubscribe Subscription

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom name to subscribe to
accessTokenstring~ 128 charsUser Id

Result

TypeDescription
itemSubscribeUnsubscribed subscriptions

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.Unsubscribe(
    &chat.UnsubscribeRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        AccessToken: pointy.String("accessToken-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UnsubscribeRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->unsubscribe(
        (new UnsubscribeRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withAccessToken(self::$accessToken0001)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UnsubscribeRequest;
import io.gs2.chat.result.UnsubscribeResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    UnsubscribeResult result = client.unsubscribe(
        new UnsubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
    );
    Subscribe item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UnsubscribeRequest;
using Gs2.Gs2Chat.Result.UnsubscribeResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UnsubscribeResult> asyncResult = null;
yield return client.Unsubscribe(
    new Gs2.Gs2Chat.Request.UnsubscribeRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithAccessToken("accessToken-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.unsubscribe(
        new Gs2Chat.UnsubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.unsubscribe(
        chat.UnsubscribeRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.unsubscribe({
    namespaceName="namespace1",
    roomName="room-0001",
    accessToken="accessToken-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

unsubscribeByUserId

Unsubscribe from a subscription by user ID

Request

TypeConditionRequireDefaultLimitationDescription
namespaceNamestring~ 32 charsNamespace name
roomNamestring~ 128 charsRoom name to subscribe to
userIdstring~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemSubscribeUnsubscribed subscriptions

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.UnsubscribeByUserId(
    &chat.UnsubscribeByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UnsubscribeByUserIdRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->unsubscribeByUserId(
        (new UnsubscribeByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UnsubscribeByUserIdRequest;
import io.gs2.chat.result.UnsubscribeByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(session);

try {
    UnsubscribeByUserIdResult result = client.unsubscribeByUserId(
        new UnsubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    Subscribe item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UnsubscribeByUserIdRequest;
using Gs2.Gs2Chat.Result.UnsubscribeByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UnsubscribeByUserIdResult> asyncResult = null;
yield return client.UnsubscribeByUserId(
    new Gs2.Gs2Chat.Request.UnsubscribeByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Chat from '@/gs2/chat';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Chat.Gs2ChatRestClient(session);

try {
    const result = await client.unsubscribeByUserId(
        new Gs2Chat.UnsubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = chat.Gs2ChatRestClient(session)

try:
    result = client.unsubscribe_by_user_id(
        chat.UnsubscribeByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.unsubscribe_by_user_id({
    namespaceName="namespace1",
    roomName="room-0001",
    userId="user-0001",
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;