Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/main/java/jp/ne/paypay/api/ApiNameConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public class ApiNameConstants {
public static final String GET_CASHBACK_DETAILS = "v2_getCashbackDetails";
public static final String CREATE_REVERSE_CASHBACK_REQUEST = "v2_createReverseCashBackRequest";
public static final String GET_REVERSED_CASHBACK_DETAILS = "v2_getReversedCashBackDetails";
public static final String GET_BALANCE = "v6_getWalletBalance";
}
66 changes: 53 additions & 13 deletions src/main/java/jp/ne/paypay/api/WalletApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import jp.ne.paypay.Pair;
import jp.ne.paypay.model.ProductType;
import jp.ne.paypay.model.WalletBalance;
import jp.ne.paypay.model.GetWalletBalance;

import jakarta.validation.constraints.NotNull;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -48,11 +49,9 @@ public void setApiClient(ApiClient apiClient) {
* @throws ApiException If fail to serialize the request body object
Comment thread
curtisfennerpaypay marked this conversation as resolved.

*/
private Call checkWalletBalanceCall(String userAuthorizationId, Integer amount, String currency,
private Call walletBalanceCall(String endpoint, String userAuthorizationId, Integer amount, String currency,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method walletBalanceCall has 5 arguments (exceeds 4 allowed). Consider refactoring.

ProductType productType) throws ApiException {

String localVarPath = "/v2/wallet/check_balance";

List<Pair> localVarQueryParams = new ArrayList<>();
List<Pair> localVarCollectionQueryParams = new ArrayList<>();
if (userAuthorizationId != null)
Expand Down Expand Up @@ -82,12 +81,11 @@ private Call checkWalletBalanceCall(String userAuthorizationId, Integer amount,

String[] localVarAuthNames = new String[] { "HmacAuth" };
apiClient.setReadTimeout(15);
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams,
return apiClient.buildCall(endpoint, "GET", localVarQueryParams, localVarCollectionQueryParams,
null, localVarHeaderParams, localVarFormParams, localVarAuthNames);
}

private Call checkWalletBalanceValidateBeforeCall(String userAuthorizationId, Integer amount, String currency, ProductType productType) throws ApiException {

private Call validateCheckWalletBalanceParamsBeforeCall(String userAuthorizationId, Integer amount, String currency, ProductType productType) throws ApiException {

// verify the required parameter 'userAuthorizationId' is set
if (userAuthorizationId == null) {
Expand All @@ -104,20 +102,33 @@ private Call checkWalletBalanceValidateBeforeCall(String userAuthorizationId, In
throw new ApiException("Missing the required parameter 'currency' when calling checkWalletBalance(Async)");
}

return walletBalanceCall("/v2/wallet/check_balance", userAuthorizationId, amount, currency, productType);
}

private Call validateGetWalletBalanceParamsBeforeCall(String userAuthorizationId, String currency, ProductType productType) throws ApiException {

// verify the required parameter 'userAuthorizationId' is set
if (userAuthorizationId == null) {
throw new ApiException("Missing the required parameter 'userAuthorizationId' when calling checkWalletBalance(Async)");
}

return checkWalletBalanceCall(userAuthorizationId, amount, currency, productType);
// verify the required parameter 'currency' is set
if (currency == null) {
throw new ApiException("Missing the required parameter 'currency' when calling checkWalletBalance(Async)");
}

return walletBalanceCall("/v6/wallet/balance", userAuthorizationId, null, currency, productType);
}

/**
* Check user wallet balance
* Check if user has enough balance to make a payment **Timeout: 15s**
* 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 WalletBalance
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body

*/
public WalletBalance checkWalletBalance( String userAuthorizationId, Integer amount, String currency, @NotNull ProductType productType) throws ApiException {
ApiResponse<WalletBalance> resp = checkWalletBalanceWithHttpInfo(userAuthorizationId, amount, currency, productType);
Expand All @@ -126,19 +137,48 @@ public WalletBalance checkWalletBalance( String userAuthorizationId, Integer amo

/**
* Check user wallet balance
* Check if user has enough balance to make a payment **Timeout: 15s**
* 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);
Call call = validateCheckWalletBalanceParamsBeforeCall(userAuthorizationId, amount, currency, productType);
Type localVarReturnType = new TypeToken<WalletBalance>(){}.getType();
return apiClient.execute(call, localVarReturnType, ApiNameConstants.CHECK_BALANCE);
}
}

/**
* Get user wallet balance
* Get the user's total balance and preference **Timeout: 15s**
* @param userAuthorizationId (required)
* @param currency (required)
* @param productType (optional)
* @return GetWalletBalance
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public GetWalletBalance getWalletBalance(String userAuthorizationId, String currency, @NotNull ProductType productType) throws ApiException {
ApiResponse<GetWalletBalance> resp = getWalletBalanceWithHttpInfo(userAuthorizationId, currency, productType);
return resp.getData();
}

/**
* Get user wallet balance
* Get the user's total balance and preference **Timeout: 15s**
* @param userAuthorizationId (required)
* @param currency (required)
* @param productType (optional)
* @return ApiResponse&lt;GetWalletBalance&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
protected ApiResponse<GetWalletBalance> getWalletBalanceWithHttpInfo(String userAuthorizationId,
String currency, ProductType productType) throws ApiException {
Call call = validateGetWalletBalanceParamsBeforeCall(userAuthorizationId, currency, productType);
Type localVarReturnType = new TypeToken<GetWalletBalance>(){}.getType();
return apiClient.execute(call, localVarReturnType, ApiNameConstants.GET_BALANCE);
}
}
81 changes: 81 additions & 0 deletions src/main/java/jp/ne/paypay/model/GetBalanceData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package jp.ne.paypay.model;

import com.google.gson.annotations.SerializedName;

import io.swagger.annotations.ApiModelProperty;

/**
* BalanceData
*/
public class GetBalanceData {

@SerializedName("userAuthorizationId")
private String userAuthorizationId = null;

@SerializedName("totalBalance")
private MoneyAmount totalBalance = null;

@SerializedName("preference")
private Preference preference = null;

/**
* User's userAuthorizationId
* @return userAuthorizationId
**/
@ApiModelProperty(value = "User's userAuthorizationId")
public String getUserAuthorizationId() {
return userAuthorizationId;
}

public GetBalanceData setUserAuthorizationId(String userAuthorizationId) {
this.userAuthorizationId = userAuthorizationId;
return this;
}

/**
* User's total balance
* @return totalAmount
**/

public MoneyAmount getTotalBalance() {
return totalBalance;
}
public void setTotalBalance(MoneyAmount totalBalance) {
this.totalBalance = totalBalance;
}

/**
* User's Preference
* @return preference
**/

public Preference getPreference() {
return preference;
}
public void setPreference(Preference preference) {
this.preference = preference;
}

@Override
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class GetBalanceData {\n");

sb.append(" userAuthorizationId: ").append(toIndentedString(userAuthorizationId)).append("\n");
sb.append(" totalBalance: ").append(toIndentedString(totalBalance)).append("\n");
sb.append(" preference: ").append(toIndentedString(preference)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
99 changes: 99 additions & 0 deletions src/main/java/jp/ne/paypay/model/GetWalletBalance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package jp.ne.paypay.model;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 10 locations. Consider refactoring.


import com.google.gson.annotations.SerializedName;

import java.util.Objects;

import io.swagger.annotations.ApiModelProperty;

/**
* GetWalletBalance
*/

public class GetWalletBalance {

@SerializedName("resultInfo")
private ResultInfo resultInfo = null;

@SerializedName("data")
private GetBalanceData data = null;

public GetWalletBalance resultInfo(ResultInfo resultInfo) {
this.resultInfo = resultInfo;
return this;
}


/**
* Get resultInfo
* @return resultInfo
**/
@ApiModelProperty(value = "")
public ResultInfo getResultInfo() {
return resultInfo;
}
public void setResultInfo(ResultInfo resultInfo) {
this.resultInfo = resultInfo;
}

public GetWalletBalance data(GetBalanceData data) {
this.data = data;
return this;
}


/**
* Get data
* @return data
**/
@ApiModelProperty(value = "")
public GetBalanceData getData() {
return data;
}
public void setData(GetBalanceData data) {
this.data = data;
}

@Override
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method equals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GetWalletBalance walletBalance = (GetWalletBalance) o;
return Objects.equals(this.resultInfo, walletBalance.resultInfo) &&
Objects.equals(this.data, walletBalance.data);
}

@Override
public int hashCode() {
return Objects.hash(resultInfo, data);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class GetWalletBalance {\n");

sb.append(" resultInfo: ").append(toIndentedString(resultInfo)).append("\n");
sb.append(" data: ").append(toIndentedString(data)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}



Loading