Search in sources :

Example 1 with ProductType

use of jp.ne.paypay.model.ProductType in project paypayopa-sdk-java by paypay.

the class WalletApiTest method checkWalletBalanceTest.

/**
 * Check user wallet balance
 *
 * Check if user has enough balance to make a payment  **Timeout: 15s**
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void checkWalletBalanceTest() throws ApiException {
    String userAuthorizationId = "user-authorization-id";
    Integer amount = 10;
    String currency = "JPY";
    ProductType productType = null;
    WalletBalance walletBalance = new WalletBalance();
    Assert.assertNotNull(api.getApiClient());
    walletBalance.setResultInfo(resultInfo);
    BalanceData balanceData = new BalanceData();
    balanceData.setHasEnoughBalance(true);
    walletBalance.setData(balanceData);
    ApiResponse<WalletBalance> walletBalanceApiResponse = new ApiResponse<>(00001, null, walletBalance);
    Mockito.when(api.checkWalletBalanceWithHttpInfo(userAuthorizationId, amount, currency, productType)).thenReturn(walletBalanceApiResponse);
    WalletBalance response = api.checkWalletBalance(userAuthorizationId, amount, currency, productType);
    Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS");
}
Also used : BalanceData(jp.ne.paypay.model.BalanceData) WalletBalance(jp.ne.paypay.model.WalletBalance) ProductType(jp.ne.paypay.model.ProductType) ApiResponse(jp.ne.paypay.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 2 with ProductType

use of jp.ne.paypay.model.ProductType in project paypayopa-sdk-java by paypay.

the class WalletApiTest method checkWalletBalanceInvalidParamsTest.

@Test
@DisplayName("Wallet Balance API for invalid params test")
public void checkWalletBalanceInvalidParamsTest() throws ApiException {
    String userAuthorizationId = "user-authorization-id";
    Integer amount = 10;
    String currency = "JPY";
    ProductType productType = null;
    WalletBalance walletBalance = new WalletBalance();
    Assert.assertNotNull(api.getApiClient());
    walletBalance.setResultInfo(resultInfo);
    Assert.assertThrows(ApiException.class, () -> api.checkWalletBalance(null, amount, currency, productType));
    Assert.assertThrows(ApiException.class, () -> api.checkWalletBalance(userAuthorizationId, null, currency, productType));
    Assert.assertThrows(ApiException.class, () -> api.checkWalletBalance(userAuthorizationId, amount, null, productType));
}
Also used : WalletBalance(jp.ne.paypay.model.WalletBalance) ProductType(jp.ne.paypay.model.ProductType) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with ProductType

use of jp.ne.paypay.model.ProductType in project paypayopa-sdk-java by paypay.

the class WalletApi method checkWalletBalanceWithHttpInfo.

/**
 * Check user wallet balance
 * Check if user has enough balance to make a payment  **Timeout: 15s**
 * @param userAuthorizationId  (required)
 * @param amount  (required)
 * @param currency  (required)
 * @param productType  (optional)
 * @return ApiResponse&lt;WalletBalance&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
protected ApiResponse<WalletBalance> checkWalletBalanceWithHttpInfo(String userAuthorizationId, Integer amount, String currency, ProductType productType) throws ApiException {
    Call call = checkWalletBalanceValidateBeforeCall(userAuthorizationId, amount, currency, productType);
    Type localVarReturnType = new TypeToken<WalletBalance>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType, ApiNameConstants.CHECK_BALANCE);
}
Also used : Call(com.squareup.okhttp.Call) ProductType(jp.ne.paypay.model.ProductType) Type(java.lang.reflect.Type) WalletBalance(jp.ne.paypay.model.WalletBalance)

Aggregations

ProductType (jp.ne.paypay.model.ProductType)3 WalletBalance (jp.ne.paypay.model.WalletBalance)3 Test (org.junit.jupiter.api.Test)2 Call (com.squareup.okhttp.Call)1 Type (java.lang.reflect.Type)1 ApiResponse (jp.ne.paypay.ApiResponse)1 BalanceData (jp.ne.paypay.model.BalanceData)1 DisplayName (org.junit.jupiter.api.DisplayName)1