GS2-SerialKey
GS2-SDK for Game Engine Reference
SDK for Game Engine
Models
EzCampaignModel
Campaign Model
Type | Description | |
---|---|---|
name | string | Campaign name |
metadata | string | metadata |
enableCampaignCode | bool | Allow redemption with campaign code |
EzSerialKey
Serial Code
The serial code issued can be used only once.
Serial codes are issued in the format "RPCLP-FP7N-NCDMJ-FLVA-IRI4" and the data length cannot be changed.
Information on the type of campaign is also included within the serial code. When using the serial code, simply specify the namespace in which the serial code is to be used.
Type | Description | |
---|---|---|
campaignModelName | string | Campaign name |
metadata | string | metadata |
code | string | Serial Code |
status | enum ['ACTIVE', 'USED', 'INACTIVE'] | Status |
Methods
getCampaignModel
getCampaignModel
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.SerialKey.Namespace(
namespaceName: "namespace-0001"
).CampaignModel(
campaignModelName: "campaign-0001"
);
var item = await domain.ModelAsync();
}
///////////////////////////////////////////////////////////////
// New Experience
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
var future = profile.Initialize();
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.SerialKey.Namespace(
namespaceName: "namespace-0001"
).CampaignModel(
campaignModelName: "campaign-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzGetCampaignModelResult> asyncResult = null;
var current = gs2.SerialKey.GetCampaignModel(
callback: r => { asyncResult = r; },
namespaceName: "namespace-0001",
campaignModelName: "campaign-0001"
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
}
const auto Profile = MakeShared<Gs2::UE5::Util::FProfile>(
"your client id",
"your client secret",
Gs2::Core::Model::ERegion::ApNorthEast1,
MakeShareable<Gs2::UE5::Util::IReOpener>(new Gs2::UE5::Util::FGs2BasicReOpener())
);
Gs2::UE5::Core::Domain::FGs2DomainPtr Gs2;
{
const auto Future = Profile->Initialize();
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;
Gs2 = Future->GetTask().Result();
Future->EnsureCompletion();
}
// Up to this line is the initialization process.
{
const auto Domain = Gs2->SerialKey->Namespace(
"namespace-0001" // namespaceName
)->CampaignModel(
"campaign-0001" // campaignModelName
);
const auto item = Domain.Model();
}
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->serialKey.getCampaignModel(
[](gs2::ez::account::AsyncEzGetCampaignModelResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "serialKey.getCampaignModel failed.");
}
else
{
Item = r.getResult()->getItem();
}
},
TCHAR_TO_ANSI("namespace-0001"), // namespaceName
TCHAR_TO_ANSI("campaign-0001") // campaignModelName
);
Get campaign model
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
campaignModelName | string | ✓ | ~ 128 chars | Campaign name |
Result
Type | Description | |
---|---|---|
item | EzCampaignModel | Campaign Model |
get
get
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.SerialKey.Namespace(
namespaceName: "namespace-0001"
).User(
userId: null
).SerialKey(
code: "code-0001"
);
var item = await domain.ModelAsync();
}
///////////////////////////////////////////////////////////////
// New Experience
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
var future = profile.Initialize();
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
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;
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzGetResult> asyncResult = null;
var current = gs2.SerialKey.Get(
callback: r => { asyncResult = r; },
namespaceName: "namespace-0001",
code: "code-0001"
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
var campaignModel = result.CampaignModel;
}
const auto Profile = MakeShared<Gs2::UE5::Util::FProfile>(
"your client id",
"your client secret",
Gs2::Core::Model::ERegion::ApNorthEast1,
MakeShareable<Gs2::UE5::Util::IReOpener>(new Gs2::UE5::Util::FGs2BasicReOpener())
);
Gs2::UE5::Core::Domain::FGs2DomainPtr Gs2;
{
const auto Future = Profile->Initialize();
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;
Gs2 = Future->GetTask().Result();
Future->EnsureCompletion();
}
// Up to this line is the initialization process.
{
const auto Domain = Gs2->SerialKey->Namespace(
"namespace-0001" // namespaceName
)->User(
nullptr // userId
)->SerialKey(
"code-0001" // code
);
const auto item = Domain.Model();
}
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->serialKey.getSerialKey(
[](gs2::ez::account::AsyncEzGetSerialKeyResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "serialKey.getSerialKey failed.");
}
else
{
Item = r.getResult()->getItem();
CampaignModel = r.getResult()->getCampaignModel();
}
},
TCHAR_TO_ANSI("namespace-0001"), // namespaceName
TCHAR_TO_ANSI("code-0001") // code
);
Get Serial Code
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
code | string | ✓ | ~ 48 chars | Serial Code |
Result
Type | Description | |
---|---|---|
item | EzSerialKey | Serial Key |
campaignModel | EzCampaignModel | Campaign Model |
useSerialCode
useSerialCode
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
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();
}
///////////////////////////////////////////////////////////////
// New Experience
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
var future = profile.Initialize();
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
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)
{
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;
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzUseSerialCodeResult> asyncResult = null;
var current = gs2.SerialKey.UseSerialCode(
callback: r => { asyncResult = r; },
session: session,
namespaceName: "namespace-0001",
code: "code-0001"
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
var campaignModel = result.CampaignModel;
}
const auto Profile = MakeShared<Gs2::UE5::Util::FProfile>(
"your client id",
"your client secret",
Gs2::Core::Model::ERegion::ApNorthEast1,
MakeShareable<Gs2::UE5::Util::IReOpener>(new Gs2::UE5::Util::FGs2BasicReOpener())
);
Gs2::UE5::Core::Domain::FGs2DomainPtr Gs2;
{
const auto Future = Profile->Initialize();
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;
Gs2 = Future->GetTask().Result();
Future->EnsureCompletion();
}
// Up to this line is the initialization process.
{
const auto Domain = Gs2->SerialKey->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->SerialKey(
"code-0001" // code
);
const auto Future = Domain->UseSerialCode(
);
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) 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();
}
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->serialKey.use(
[](gs2::ez::account::AsyncEzUseResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "serialKey.use failed.");
}
else
{
Item = r.getResult()->getItem();
CampaignModel = r.getResult()->getCampaignModel();
}
},
ProfilePtr->getGs2Session(),
TCHAR_TO_ANSI("namespace-0001"), // namespaceName
TCHAR_TO_ANSI("code-0001") // code
);
Consume Serial Code
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
code | string | ✓ | ~ 48 chars | Serial Code |
Result
Type | Description | |
---|---|---|
item | EzSerialKey | Serial Key |
campaignModel | EzCampaignModel | Campaign Model |