Skip to content

Commit

Permalink
chore: Update to version 4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wijayaadhisurya committed Aug 19, 2021
1 parent 6cfb4ce commit d6ddd7f
Show file tree
Hide file tree
Showing 19 changed files with 941 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [4.0.1](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/branches/compare/4.0.1%0D4.0.0) (2021-08-16)

## [4.0.0](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/branches/compare/4.0.0%0D3.2.0) (2021-08-02)


Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,25 @@ This documentation assumes that you are already familiar with modern C++, Unreal

## Dependencies

AccelByte SDK is compatible with these AccelByte Services version 3.2.0
AccelByte SDK v4.0.1 is compatible with these AccelByte Services version 3.3.1:

| Service | Version |
|-----------------------------------------------------|----------------|
| justice-iam-service | 4.3.0 |
| justice-legal-service | 1.12.1 |
| justice-basic-service | 1.21.1 |
| justice-platform-service | 3.32.0 |
| justice-social-service | 1.17.1 |
| justice-leaderboard-service | 2.8.0 |
| justice-achievement-service | 2.5.4 |
| justice-cloudsave-service | 1.6.4 |
| justice-ugc-service | 1.4.0 |
| justice-lobby-server | 1.34.0 |
| justice-group-service | 2.7.3 |
| Justice QoS Manager Service | 1.7.6 |
| justice-dedicated-server-manager-controller-service | 2.4.1 |
| amalgam_game_telemetry | 1.1.2-392420e1 |


## Features

Expand Down
2 changes: 2 additions & 0 deletions Source/AccelByteUe4Sdk/Private/AccelByteUe4SdkModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ bool FAccelByteUe4SdkModule::LoadSettingsFromConfigUobject()
FRegistry::Settings.AchievementServerUrl = GetDefaultAPIUrl(GetDefault<UAccelByteSettings>()->AchievementServerUrl, TEXT("achievement"));
FRegistry::Settings.SessionBrowserServerUrl = GetDefaultAPIUrl(GetDefault<UAccelByteSettings>()->SessionBrowserServerUrl, TEXT("sessionbrowser"));
FRegistry::Settings.UGCServerUrl = GetDefaultAPIUrl(GetDefault<UAccelByteSettings>()->UGCServerUrl, TEXT("ugc"));
FRegistry::Settings.SeasonPassServerUrl = GetDefaultAPIUrl(GetDefault<UAccelByteSettings>()->UGCServerUrl, TEXT("seasonpass"));
FRegistry::Settings.AppId = GetDefault<UAccelByteSettings>()->AppId;
FRegistry::Credentials.SetClientCredentials(FRegistry::Settings.ClientId, FRegistry::Settings.ClientSecret);

Expand Down Expand Up @@ -180,6 +181,7 @@ bool FAccelByteUe4SdkModule::LoadServerSettingsFromConfigUobject()
FRegistry::ServerSettings.MatchmakingServerUrl = GetDefaultServerAPIUrl(GetDefault<UAccelByteServerSettings>()->MatchmakingServerUrl, TEXT("matchmaking"));
FRegistry::ServerSettings.LobbyServerUrl = GetDefaultServerAPIUrl(GetDefault<UAccelByteServerSettings>()->LobbyServerUrl, TEXT("lobby"));
FRegistry::ServerSettings.CloudSaveServerUrl = GetDefaultServerAPIUrl(GetDefault<UAccelByteServerSettings>()->CloudSaveServerUrl, TEXT("cloudsave"));
FRegistry::ServerSettings.SeasonPassServerUrl = GetDefaultServerAPIUrl(GetDefault<UAccelByteServerSettings>()->SeasonPassServerUrl, TEXT("seasonpass"));
FRegistry::ServerCredentials.SetClientCredentials(FRegistry::ServerSettings.ClientId, FRegistry::ServerSettings.ClientSecret);

#endif
Expand Down
289 changes: 289 additions & 0 deletions Source/AccelByteUe4Sdk/Private/Api/AccelByteSeasonPassApi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
// Copyright (c) 2021 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.


#include "Api/AccelByteSeasonPassApi.h"

#include "Core/AccelByteHttpRetryScheduler.h"
#include "Core/AccelByteRegistry.h"
#include "Core/AccelByteReport.h"

namespace AccelByte
{
namespace Api
{
SeasonPass::SeasonPass(const AccelByte::Credentials& Credentials, const AccelByte::Settings& Setting) : Credentials(Credentials), Settings(Setting)
{
}

SeasonPass::~SeasonPass()
{
}

void SeasonPass::GetCurrentSeason(const FString& Language, const THandler<FAccelByteModelsSeasonInfo>& OnSuccess, const FErrorHandler& OnError)
{
FReport::Log(FString(__FUNCTION__));

FString Authorization = FString::Printf(TEXT("Bearer %s"), *Credentials.GetAccessToken());
FString Url = FString::Printf( TEXT("%s/public/namespaces/%s/seasons/current?language=%s"), *Settings.SeasonPassServerUrl, *Credentials.GetNamespace(), *Language);
FString Verb = TEXT("GET");
FString ContentType = TEXT("application/json");
FString Accept = TEXT("application/json");
FString Content = TEXT("");

FHttpRequestPtr Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetHeader(TEXT("Authorization"), Authorization);
Request->SetVerb(Verb);
Request->SetHeader(TEXT("Content-Type"), ContentType);
Request->SetHeader(TEXT("Accept"), Accept);
Request->SetContentAsString(Content);

FRegistry::HttpRetryScheduler.ProcessRequest(
Request,
CreateHttpResultHandler(THandler<FAccelByteModelsSeasonTierRewardAsJsonObject>::CreateLambda(
[OnSuccess, this](const FAccelByteModelsSeasonTierRewardAsJsonObject& SeasonResult)
{
// Convert the Tier JsonObject to TMap<FString, TArray<FString>>
TArray<FAccelByteModelsSeasonPassTier> Tiers;
for (const FString& PassCode : SeasonResult.PassCodes)
{
for (const FAccelByteModelsSeasonPassTierJsonObject& Tier : SeasonResult.Tiers)
{
FAccelByteModelsSeasonPassTier TierRes;
TierRes.Id = Tier.Id;
TierRes.RequiredExp = Tier.RequiredExp;
TierRes.Rewards = FJsonObjectToPassRewards(Tier.Rewards.JsonObject);
Tiers.Add(TierRes);
}
}
FAccelByteModelsSeasonInfo EndResult{
SeasonResult.Title, SeasonResult.Description, SeasonResult.Id,
SeasonResult.Namespace, SeasonResult.Name, SeasonResult.Start,
SeasonResult.End, SeasonResult.TierItemId, SeasonResult.AutoClaim,
SeasonResult.Images, SeasonResult.PassCodes,
SeasonResult.Status, SeasonResult.PublishedAt,
SeasonResult.Language, SeasonResult.CreatedAt,
SeasonResult.UpdatedAt, SeasonResult.Passes, SeasonResult.Rewards,
Tiers
};
OnSuccess.ExecuteIfBound(EndResult);
}), OnError),
FPlatformTime::Seconds());
}

void SeasonPass::GetUserSeason(const FString& SeasonId, const THandler<FAccelByteModelsUserSeasonInfo>& OnSuccess, const FErrorHandler& OnError)
{
FReport::Log(FString(__FUNCTION__));

FString Authorization = FString::Printf(TEXT("Bearer %s"), *Credentials.GetAccessToken());
FString Url = FString::Printf(TEXT("%s/public/namespaces/%s/users/%s/seasons/%s/data"), *Settings.SeasonPassServerUrl, *Credentials.GetNamespace(), *Credentials.GetUserId(), *SeasonId);
FString Verb = TEXT("GET");
FString ContentType = TEXT("application/json");
FString Accept = TEXT("application/json");
FString Content = TEXT("");

FHttpRequestPtr Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetHeader(TEXT("Authorization"), Authorization);
Request->SetVerb(Verb);
Request->SetHeader(TEXT("Content-Type"), ContentType);
Request->SetHeader(TEXT("Accept"), Accept);
Request->SetContentAsString(Content);

FRegistry::HttpRetryScheduler.ProcessRequest(
Request,
CreateHttpResultHandler(THandler<FAccelByteModelsUserSeasonInfoClaimRewardAsJsonObject>::CreateLambda(
[OnSuccess, this](const FAccelByteModelsUserSeasonInfoClaimRewardAsJsonObject& Response)
{
TMap<int32, TMap<FString, TArray<FString>>> ToClaimRewards;
for (const TTuple<int, FJsonObjectWrapper>& ClaimReward : Response.ToClaimRewards)
{
ToClaimRewards.Add(ClaimReward.Key, FJsonObjectToPassRewards(ClaimReward.Value.JsonObject));
}

TMap<int32, TMap<FString, TArray<FString>>> ClaimingRewards;
for (const TTuple<int, FJsonObjectWrapper>& ClaimReward : Response.ClaimingRewards)
{
ClaimingRewards.Add(ClaimReward.Key, FJsonObjectToPassRewards(ClaimReward.Value.JsonObject));
}
FAccelByteModelsUserSeasonInfo EndResult{
Response.Id, Response.Namespace, Response.UserId,
Response.SeasonId, Response.EnrolledAt,
Response.EnrolledPasses,
Response.CurrentTierIndex, Response.LastTierIndex,
Response.RequiredExp, Response.CurrentExp,
Response.Cleared, Response.Season,
ToClaimRewards, ClaimingRewards, Response.CreatedAt,
Response.UpdatedAt
};
OnSuccess.ExecuteIfBound(EndResult);
}), OnError),
FPlatformTime::Seconds());
}

void SeasonPass::GetCurrentUserSeason(const THandler<FAccelByteModelsUserSeasonInfo>& OnSuccess, const FErrorHandler& OnError)
{
FReport::Log(FString(__FUNCTION__));

FString Authorization = FString::Printf(TEXT("Bearer %s"), *Credentials.GetAccessToken());
FString Url = FString::Printf(TEXT("%s/public/namespaces/%s/users/%s/seasons/current/data"), *Settings.SeasonPassServerUrl, *Credentials.GetNamespace(), *Credentials.GetUserId());
FString Verb = TEXT("GET");
FString ContentType = TEXT("application/json");
FString Accept = TEXT("application/json");
FString Content = TEXT("");

FHttpRequestPtr Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetHeader(TEXT("Authorization"), Authorization);
Request->SetVerb(Verb);
Request->SetHeader(TEXT("Content-Type"), ContentType);
Request->SetHeader(TEXT("Accept"), Accept);
Request->SetContentAsString(Content);

FRegistry::HttpRetryScheduler.ProcessRequest(
Request,
CreateHttpResultHandler(THandler<FAccelByteModelsUserSeasonInfoClaimRewardAsJsonObject>::CreateLambda(
[OnSuccess, this](const FAccelByteModelsUserSeasonInfoClaimRewardAsJsonObject& Response)
{
TMap<int32, TMap<FString, TArray<FString>>> ToClaimRewards;
for (const TTuple<int, FJsonObjectWrapper>& ClaimReward : Response.ToClaimRewards)
{
ToClaimRewards.Add(ClaimReward.Key, FJsonObjectToPassRewards(ClaimReward.Value.JsonObject));
}

TMap<int32, TMap<FString, TArray<FString>>> ClaimingRewards;
for (const TTuple<int, FJsonObjectWrapper>& ClaimReward : Response.ClaimingRewards)
{
ClaimingRewards.Add(ClaimReward.Key, FJsonObjectToPassRewards(ClaimReward.Value.JsonObject));
}
FAccelByteModelsUserSeasonInfo EndResult{
Response.Id, Response.Namespace, Response.UserId,
Response.SeasonId, Response.EnrolledAt,
Response.EnrolledPasses,
Response.CurrentTierIndex, Response.LastTierIndex,
Response.RequiredExp, Response.CurrentExp,
Response.Cleared, Response.Season,
ToClaimRewards, ClaimingRewards, Response.CreatedAt,
Response.UpdatedAt
};
OnSuccess.ExecuteIfBound(EndResult);
}), OnError),
FPlatformTime::Seconds());
}

void SeasonPass::ClaimRewards(const FAccelByteModelsSeasonClaimRewardRequest& RewardRequest, const THandler<FAccelByteModelsSeasonClaimRewardResponse>& OnSuccess, const FErrorHandler& OnError)
{
FReport::Log(FString(__FUNCTION__));

FString Authorization = FString::Printf(TEXT("Bearer %s"), *Credentials.GetAccessToken());
FString Url = FString::Printf(
TEXT("%s/public/namespaces/%s/users/%s/seasons/current/rewards"), *Settings.SeasonPassServerUrl,
*Credentials.GetNamespace(), *Credentials.GetUserId());
FString Verb = TEXT("POST");
FString ContentType = TEXT("application/json");
FString Accept = TEXT("application/json");
FString Content = TEXT("");

FJsonObjectConverter::UStructToJsonObjectString(RewardRequest, Content);

FHttpRequestPtr Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetHeader(TEXT("Authorization"), Authorization);
Request->SetVerb(Verb);
Request->SetHeader(TEXT("Content-Type"), ContentType);
Request->SetHeader(TEXT("Accept"), Accept);
Request->SetContentAsString(Content);

FRegistry::HttpRetryScheduler.ProcessRequest(
Request,
CreateHttpResultHandler(THandler<FAccelByteModelsSeasonClaimRewardResponseJsonWrapper>::CreateLambda(
[OnSuccess, this](
const FAccelByteModelsSeasonClaimRewardResponseJsonWrapper& Response)
{
TMap<int32, TMap<FString, TArray<FString>>> ToClaimRewards;
for (const TTuple<int, FJsonObjectWrapper>& ClaimReward : Response.ToClaimRewards)
{
ToClaimRewards.Add(ClaimReward.Key, FJsonObjectToPassRewards( ClaimReward.Value.JsonObject));
}

TMap<int32, TMap<FString, TArray<FString>>> ClaimingRewards;
for (const TTuple<int, FJsonObjectWrapper>& ClaimReward : Response.ClaimingRewards)
{
ClaimingRewards.Add( ClaimReward.Key, FJsonObjectToPassRewards(ClaimReward.Value.JsonObject));
}

FAccelByteModelsSeasonClaimRewardResponse EndResult{
ToClaimRewards, ClaimingRewards
};
OnSuccess.ExecuteIfBound(EndResult);
}), OnError),
FPlatformTime::Seconds());
}

void SeasonPass::BulkClaimRewards(const THandler<FAccelByteModelsSeasonClaimRewardResponse>& OnSuccess, const FErrorHandler& OnError)
{
FReport::Log(FString(__FUNCTION__));

FString Authorization = FString::Printf(TEXT("Bearer %s"), *Credentials.GetAccessToken());
FString Url = FString::Printf(
TEXT("%s/public/namespaces/%s/users/%s/seasons/current/rewards/bulk"), *Settings.SeasonPassServerUrl,
*Credentials.GetNamespace(), *Credentials.GetUserId());
FString Verb = TEXT("POST");
FString ContentType = TEXT("application/json");
FString Accept = TEXT("application/json");
FString Content = TEXT("");

FHttpRequestPtr Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetHeader(TEXT("Authorization"), Authorization);
Request->SetVerb(Verb);
Request->SetHeader(TEXT("Content-Type"), ContentType);
Request->SetHeader(TEXT("Accept"), Accept);
Request->SetContentAsString(Content);

FRegistry::HttpRetryScheduler.ProcessRequest(
Request,
CreateHttpResultHandler(THandler<FAccelByteModelsSeasonClaimRewardResponseJsonWrapper>::CreateLambda(
[OnSuccess, this](
const FAccelByteModelsSeasonClaimRewardResponseJsonWrapper& Response)
{
TMap<int32, TMap<FString, TArray<FString>>> ToClaimRewards;
for (const TTuple<int, FJsonObjectWrapper>& ClaimReward : Response.ToClaimRewards)
{
ToClaimRewards.Add(ClaimReward.Key, FJsonObjectToPassRewards( ClaimReward.Value.JsonObject));
}

TMap<int32, TMap<FString, TArray<FString>>> ClaimingRewards;
for (const TTuple<int, FJsonObjectWrapper>& ClaimReward : Response.ClaimingRewards)
{
ClaimingRewards.Add( ClaimReward.Key, FJsonObjectToPassRewards(ClaimReward.Value.JsonObject));
}

FAccelByteModelsSeasonClaimRewardResponse EndResult{
ToClaimRewards, ClaimingRewards
};
OnSuccess.ExecuteIfBound(EndResult);
}), OnError),
FPlatformTime::Seconds());
}

TMap<FString, TArray<FString>> SeasonPass::FJsonObjectToPassRewards(TSharedPtr<FJsonObject> JsonObject)
{
// Convert the Tier JsonObject to TMap<FString, TArray<FString>>
TMap<FString, TArray<FString>> PassAndRewardCode;
for (const TTuple<FString, TSharedPtr<FJsonValue, ESPMode::Fast>>& PassReward : JsonObject->Values)
{
TArray<FString> ClaimRewardCode;
for (const TSharedPtr<FJsonValue>& RewardCode : PassReward.Value->AsArray())
{
ClaimRewardCode.Add(RewardCode->AsString());
}
PassAndRewardCode.Add(PassReward.Key, ClaimRewardCode);
}

return PassAndRewardCode;
}
}
}
2 changes: 2 additions & 0 deletions Source/AccelByteUe4Sdk/Private/Api/AccelByteUserApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ static FString GetPlatformString(EAccelBytePlatformType PlatformType)
return "epicgames";
case EAccelBytePlatformType::Stadia:
return "stadia";
case EAccelBytePlatformType::AwsCognito:
return "awscognito";
default:
return "unknown";
}
Expand Down
6 changes: 5 additions & 1 deletion Source/AccelByteUe4Sdk/Private/Core/AccelByteRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "Api/AccelByteAchievementApi.h"
#include "Api/AccelByteSessionBrowserApi.h"
#include "Api/AccelByteUGCApi.h"
#include "Api/AccelByteSeasonPassApi.h"
#include "GameServerApi/AccelByteServerOauth2Api.h"
#include "GameServerApi/AccelByteServerDSMApi.h"
#include "GameServerApi/AccelByteServerStatisticApi.h"
Expand All @@ -36,6 +37,7 @@
#include "GameServerApi/AccelByteServerMatchmakingApi.h"
#include "GameServerApi/AccelByteServerLobby.h"
#include "GameServerApi/AccelByteServerCloudSaveApi.h"
#include "GameServerApi/AccelByteServerSeasonPassApi.h"

using namespace AccelByte;
using namespace AccelByte::Api;
Expand Down Expand Up @@ -66,6 +68,7 @@ Api::Agreement FRegistry::Agreement(FRegistry::Credentials, FRegistry::Settings)
Api::Achievement FRegistry::Achievement(FRegistry::Credentials, FRegistry::Settings);
Api::SessionBrowser FRegistry::SessionBrowser(FRegistry::Credentials, FRegistry::Settings);
Api::UGC FRegistry::UGC(FRegistry::Credentials, FRegistry::Settings);
Api::SeasonPass FRegistry::SeasonPass(FRegistry::Credentials, FRegistry::Settings);
GameServerApi::ServerOauth2 FRegistry::ServerOauth2(FRegistry::ServerCredentials, FRegistry::ServerSettings);
GameServerApi::ServerDSM FRegistry::ServerDSM(FRegistry::ServerCredentials, FRegistry::ServerSettings);
GameServerApi::ServerStatistic FRegistry::ServerStatistic(FRegistry::ServerCredentials, FRegistry::ServerSettings);
Expand All @@ -75,4 +78,5 @@ GameServerApi::ServerGameTelemetry FRegistry::ServerGameTelemetry(FRegistry::Ser
GameServerApi::ServerAchievement FRegistry::ServerAchievement(FRegistry::ServerCredentials, FRegistry::ServerSettings);
GameServerApi::ServerMatchmaking FRegistry::ServerMatchmaking(FRegistry::ServerCredentials, FRegistry::ServerSettings);
GameServerApi::ServerLobby FRegistry::ServerLobby(FRegistry::ServerCredentials, FRegistry::ServerSettings);
GameServerApi::ServerCloudSave FRegistry::ServerCloudSave(FRegistry::ServerCredentials, FRegistry::ServerSettings);
GameServerApi::ServerCloudSave FRegistry::ServerCloudSave(FRegistry::ServerCredentials, FRegistry::ServerSettings);
GameServerApi::ServerSeasonPass FRegistry::ServerSeasonPass(FRegistry::ServerCredentials, FRegistry::ServerSettings);
Loading

0 comments on commit d6ddd7f

Please sign in to comment.