Integrate Store Display and Section
Last updated on October 24, 2024
Overview
This article walks you through how to retrieve Store Display and Section information through the Game SDK.
Prerequisite
You have created stores in the AccelByte Gaming Services Admin Portal. For more information, see Set up, configure, and prepare a store.
Retrieve Store Display information
Use the following function to get the Store Display information of a store:
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
string storeId = "YourStoreIdFromAdminPortal";
string storeLanguage = "US";
ViewInfo[] views;
StoreDisplay storeDisplay = AccelByteSDK.GetClientRegistry().GetApi().GetStoreDisplayService();
storeDisplay.GetAllViews(storeId, storeLanguage, result =>
{
if (result.IsError)
{
// Your logic to handle errors in GetAllViews
// ...
Debug.Log($"Error GetAllViews, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
views = result.Value;
// Your logic to run after GetAllViews is successful
});
viewService := &platform.ViewService{
Client: factory.NewPlatformClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
userId := "myuserid"
language := "US"
storeId := "mystoreid"
input := &view.PublicListViewsParams{
Namespace: namespace,
UserID: userId,
Language: &language,
StoreID: &storeId,
}
result, err := viewService.PublicListViewsShort(input)
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_list_views(
user_id="********************************",
language="en-US",
store_id="YourStoreIdFromAdminPortal",
)
if error:
exit(error)
final View viewWrapper = new View(sdk);
String storeId = "<your-store-id>";
String userId = "<user-id>";
List<ViewInfo> response;
try {
response = viewWrapper.publicListViews(PublicListViews.builder()
.namespace("<namespace>")
.userId(userId)
.storeId(storeId)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something when successful
}
string storeId = "<your-store-id>";
string userId = "<user-id>";
var response = sdk.Platform.View.PublicListViewsOp
.SetStoreId(storeId)
.SetLanguage("<your-store-language>")
.Execute(sdk.Namespace, userId);
if (response != null)
{
//do something after store's views are retrieved
}
Retrieve Store Section information
After retrieving the Store Display information, you can get the ID of the Store display and use that to get the active section that contains available items.
Use the following function to get the active section of a store:
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
string storeId = "YourStoreIdFromAdminPortal";
string viewId = "YourViewId";
string storeLanguage = "en-US";
string storeRegion = "US";
SectionInfo[] viewSections;
StoreDisplay storeDisplay = AccelByteSDK.GetClientRegistry().GetApi().GetStoreDisplayService();
storeDisplay.ListActiveSectionContents(storeId, viewId, storeRegion, storeLanguage, result =>
{
if (result.IsError)
{
// Your logic to handle errors in ListActiveSectionContents
// ...
Debug.Log($"Error ListActiveSectionContents, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
viewSections = result.Value;
// Your logic to run after ListActiveSectionContents is successful
});
sectionService := &platform.SectionService{
Client: factory.NewPlatformClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
userId := "myuserid"
autoCalcEstimatedPrice := false
language := "en-US"
region := "US"
storeId := "mystoreid"
viewId := "myviewid"
input := §ion.PublicListActiveSectionsParams{
Namespace: namespace,
UserID: userId,
AutoCalcEstimatedPrice: &autoCalcEstimatedPrice,
Language: &language,
Region: ®ion,
StoreID: &storeId,
ViewID: &viewId,
}
result, err := sectionService.PublicListActiveSectionsShort(input)
import accelbyte_py_sdk.api.platform as platform_service
result, error = platform_service.public_list_active_sections(
user_id="********************************",
language="en-US",
region="US",
store_id="YourStoreIdFromAdminPortal",
view_id="YourViewId",
)
if error:
exit(error)
final Section sectionWrapper = new Section(sdk);
String storeId = "<your-store-id>";
String userId = "<user-id>";
String viewId = "<your-store-view-id>"; //can be retrieved using PublicListViews
List<SectionInfo> response;
try {
response = sectionWrapper.publicListActiveSections(PublicListActiveSections.builder()
.namespace("<namespace>")
.userId(userId)
.storeId(storeId)
.region("<your-store-region")
.language("<your-store-language>")
.viewId(viewId)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something when successful
}
string storeId = "<your-store-id>";
string userId = "<user-id>";
string viewId = "<your-store-view-id>"; //can be retrieved using PublicListViews
var response = sdk.Platform.Section.PublicListActiveSectionsOp
.SetStoreId(storeId)
.SetRegion("<your-store-region")
.SetLanguage("<your-store-language>")
.SetViewId(viewId)
.Execute(sdk.Namespace, userId);
if (response != null)
{
//do something after store's sections are retrieved
}