GS2-SerialKey SDK for Game Engine API リファレンス
モデル
EzCampaignModel
キャンペーンモデル
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
name | string | ✓ | | ~ 128文字 | キャンペーン名 |
metadata | string | | | ~ 2048文字 | メタデータ |
enableCampaignCode | bool | ✓ | false | | キャンペーンコードでの引き換えを許可するか |
EzSerialKey
シリアルコード
発行されたシリアルコードは1度のみ使用可能です。
シリアルコードは「RPCLP-FP7N-NCDMJ-FLVA-IRI4」のような形式で発行され、データ長を変更することはできません。
シリアルコード内にはキャンペーンの種類の情報も含まれており、シリアルコードを使用する際にはネームスペースを指定するだけで使用できます。
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
campaignModelName | string | ✓ | | ~ 128文字 | キャンペーン名 |
metadata | string | | | ~ 2048文字 | メタデータ |
code | string | ✓ | | ~ 48文字 | シリアルコード |
status | enum [‘ACTIVE’, ‘USED’, ‘INACTIVE’] | ✓ | “ACTIVE” | ~ 128文字 | ステータス |
メソッド
getCampaignModel
キャンペーンモデルを取得
Request
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
campaignModelName | string | ✓ | | ~ 128文字 | キャンペーン名 |
Result
実装例
var domain = gs2.SerialKey.Namespace(
namespaceName: "namespace-0001"
).CampaignModel(
campaignModelName: "campaign-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.SerialKey.Namespace(
namespaceName: "namespace-0001"
).CampaignModel(
campaignModelName: "campaign-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->SerialKey->Namespace(
"namespace-0001" // namespaceName
)->CampaignModel(
"campaign-0001" // campaignModelName
);
const auto item = Domain.Model();
get
シリアルコードを取得
Request
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
code | string | ✓ | | ~ 48文字 | シリアルコード |
Result
実装例
var domain = gs2.SerialKey.Namespace(
namespaceName: "namespace-0001"
).User(
userId: null
).SerialKey(
code: "code-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.SerialKey.Namespace(
namespaceName: "namespace-0001"
).User(
userId: null
).SerialKey(
code: "code-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->SerialKey->Namespace(
"namespace-0001" // namespaceName
)->User(
nullptr // userId
)->SerialKey(
"code-0001" // code
);
const auto item = Domain.Model();
useSerialCode
シリアルコードを消費
Request
| 型 | 必須 | デフォルト | 値の制限 | 説明 |
---|
namespaceName | string | ✓ | | ~ 32文字 | ネームスペース名 |
accessToken | string | ✓ | | ~ 128文字 | ユーザーID |
code | string | ✓ | | ~ 48文字 | シリアルコード |
Result
Error
このAPIには特別な例外が定義されています。
GS2-SDK for GameEngine ではゲーム内でハンドリングが必要そうなエラーは一般的な例外から派生した特殊化した例外を用意することでハンドリングしやすくしています。
一般的なエラーの種類や、ハンドリング方法は こちら のドキュメントを参考にしてください。
型 | 基底クラス | 説明 |
---|
AlreadyUsedException | BadRequestException | 指定されたシリアルコードはすでに使用されています |
CodeNotFoundException | NotFoundException | 指定されたシリアルコードは存在しません |
実装例
try {
var domain = gs2.SerialKey.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SerialKey(
code: "code-0001"
);
var result = await domain.UseSerialCodeAsync(
);
var item = await result.ModelAsync();
} catch(Gs2.Gs2SerialKey.Exception.AlreadyUsed e) {
// The specified serial code has already been used.
} catch(Gs2.Gs2SerialKey.Exception.CodeNotFound e) {
// The specified serial code does not exist.
}
var domain = gs2.SerialKey.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SerialKey(
code: "code-0001"
);
var future = domain.UseSerialCode(
);
yield return future;
if (future.Error != null)
{
if (future.Error is Gs2.Gs2SerialKey.Exception.AlreadyUsedException)
{
// The specified serial code has already been used.
}
if (future.Error is Gs2.Gs2SerialKey.Exception.CodeNotFoundException)
{
// The specified serial code does not exist.
}
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->SerialKey->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->SerialKey(
"code-0001" // code
);
const auto Future = Domain->UseSerialCode(
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
if (Gs2::SerialKey::Error::FAlreadyUsedError::TypeString == Task->GetTask().Error()->Type())
{
// The specified serial code has already been used.
}
if (Gs2::SerialKey::Error::FCodeNotFoundError::TypeString == Task->GetTask().Error()->Type())
{
// The specified serial code does not exist.
}
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
const auto Result = Future2->GetTask().Result();