From 894e495071a6b2933d13ba610084ba2942b9f9da Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Wed, 14 Oct 2026 13:01:00 -0400 Subject: [PATCH] BCLOUD-15137 --- .../braincloud/client/ServiceOperation.java | 2 + .../braincloud/services/AppStoreService.java | 40 +++++++++++++++++++ .../services/AppStoreServiceTest.java | 32 +++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/src/main/java/com/bitheads/braincloud/client/ServiceOperation.java b/src/main/java/com/bitheads/braincloud/client/ServiceOperation.java index 58d0ac6..67c0f31 100644 --- a/src/main/java/com/bitheads/braincloud/client/ServiceOperation.java +++ b/src/main/java/com/bitheads/braincloud/client/ServiceOperation.java @@ -325,6 +325,8 @@ public enum ServiceOperation { FINALIZE_PURCHASE, REFRESH_PROMOTIONS, CACHE_PURCHASE_PAYLOAD_CONTEXT, + GET_STORE_INFO, + GET_USER_TOKEN, GET_UPDATED_FILES, GET_FILE_LIST, diff --git a/src/main/java/com/bitheads/braincloud/services/AppStoreService.java b/src/main/java/com/bitheads/braincloud/services/AppStoreService.java index 87a8a0b..10c2de7 100644 --- a/src/main/java/com/bitheads/braincloud/services/AppStoreService.java +++ b/src/main/java/com/bitheads/braincloud/services/AppStoreService.java @@ -247,4 +247,44 @@ public void refreshPromotions(IServerCallback callback) { ServerCall sc = new ServerCall(ServiceName.appStore, ServiceOperation.REFRESH_PROMOTIONS, data, callback); _client.sendRequest(sc); } + + /** + * Returns the store's client-side configuration for the given store. + * + * Service Name - appStore + * Service Operation - GET_STORE_INFO + * + * @param storeId The store platform. Valid stores are: + * - xsolla + * @param callback The method to be invoked when the server response is received + */ + public void getStoreInfo(String storeId, IServerCallback callback) { + sendStoreRequest(ServiceOperation.GET_STORE_INFO, storeId, callback); + } + + /** + * Returns a store user token (JWT) for the current user, generated server-side. + * + * Service Name - appStore + * Service Operation - GET_USER_TOKEN + * + * @param storeId The store platform. Valid stores are: + * - xsolla + * @param callback The method to be invoked when the server response is received + */ + public void getUserToken(String storeId, IServerCallback callback) { + sendStoreRequest(ServiceOperation.GET_USER_TOKEN, storeId, callback); + } + + private void sendStoreRequest(ServiceOperation operation, String storeId, IServerCallback callback) { + try { + JSONObject data = new JSONObject(); + data.put(Parameter.storeId.name(), storeId); + + ServerCall sc = new ServerCall(ServiceName.appStore, operation, data, callback); + _client.sendRequest(sc); + } catch (JSONException je) { + je.printStackTrace(); + } + } } diff --git a/src/test/java/com/bitheads/braincloud/services/AppStoreServiceTest.java b/src/test/java/com/bitheads/braincloud/services/AppStoreServiceTest.java index 5ba9ef3..3e3ef0c 100644 --- a/src/test/java/com/bitheads/braincloud/services/AppStoreServiceTest.java +++ b/src/test/java/com/bitheads/braincloud/services/AppStoreServiceTest.java @@ -73,4 +73,36 @@ public void testCachePurchasePayloadContext() throws Exception { _wrapper.getAppStoreService().cachePurchasePayloadContext("_invalid_store_id_", "_invalid_transaction_id_", "{}", tr); tr.RunExpectFail(StatusCodes.BAD_REQUEST, ReasonCodes.INVALID_STORE_ID); } + + @Test + public void testGetStoreInfo() throws Exception { + TestResult tr = new TestResult(_wrapper); + + _wrapper.getAppStoreService().getStoreInfo("xsolla", tr); + tr.Run(); + } + + @Test + public void testGetStoreInfoFail() throws Exception { + TestResult tr = new TestResult(_wrapper); + + _wrapper.getAppStoreService().getStoreInfo("_invalid_store_id_", tr); + tr.RunExpectFail(StatusCodes.BAD_REQUEST, ReasonCodes.INVALID_STORE_ID); + } + + @Test + public void testGetUserToken() throws Exception { + TestResult tr = new TestResult(_wrapper); + + _wrapper.getAppStoreService().getUserToken("xsolla", tr); + tr.Run(); + } + + @Test + public void testGetUserTokenFail() throws Exception { + TestResult tr = new TestResult(_wrapper); + + _wrapper.getAppStoreService().getUserToken("_invalid_store_id_", tr); + tr.RunExpectFail(StatusCodes.BAD_REQUEST, ReasonCodes.INVALID_STORE_ID); + } }