Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}