diff --git a/src/main/java/jp/ne/paypay/api/ApiNameConstants.java b/src/main/java/jp/ne/paypay/api/ApiNameConstants.java index a36bd81..631fcd9 100644 --- a/src/main/java/jp/ne/paypay/api/ApiNameConstants.java +++ b/src/main/java/jp/ne/paypay/api/ApiNameConstants.java @@ -26,4 +26,7 @@ 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_USER_CASHBACK_SETTING_STATUS = "v1_userCashbackSettingStatus"; + public static final String UPDATE_USER_CASHBACK_USE_STATUS = "v1_updateUserCashbackUseStatus"; + public static final String UPDATE_USER_CASHBACK_AUTO_INVESTMENT = "v1_updateUserCashbackAutoInvestment"; } diff --git a/src/main/java/jp/ne/paypay/api/UserApi.java b/src/main/java/jp/ne/paypay/api/UserApi.java index f19315f..0bf80e0 100644 --- a/src/main/java/jp/ne/paypay/api/UserApi.java +++ b/src/main/java/jp/ne/paypay/api/UserApi.java @@ -7,9 +7,13 @@ import jp.ne.paypay.ApiResponse; import jp.ne.paypay.Configuration; import jp.ne.paypay.Pair; +import jp.ne.paypay.Validator; import jp.ne.paypay.model.MaskedUserProfileResponse; import jp.ne.paypay.model.NotDataResponse; import jp.ne.paypay.model.UserAuthorizationStatus; +import jp.ne.paypay.model.UserCashbackAutoInvestment; +import jp.ne.paypay.model.UserCashbackSettingStatus; +import jp.ne.paypay.model.UserCashbackUseStatus; import java.lang.reflect.Type; @@ -18,6 +22,8 @@ public class UserApi { private ApiClient apiClient; + private final Validator validator = Validator.getInstance(); + public UserApi() { this(new Configuration().getDefaultApiClient()); } @@ -131,4 +137,109 @@ protected ApiResponse unlinkUserWithHttpInfo(String userAuthori Type localVarReturnType = new TypeToken(){}.getType(); return apiClient.execute(call, localVarReturnType, ApiNameConstants.UNLINK_USER); } + + /** + * Get user cashback setting status + * Get cashback setting state of specified user **Timeout: 15s** + * @param userAuthorizationId (required) + * @return UserCashbackSettingStatus + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + + */ + public UserCashbackSettingStatus getUserCashbackSettingStatus(String userAuthorizationId) throws ApiException { + ApiResponse resp = getUserCashbackSettingStatusWithHttpInfo(userAuthorizationId); + return resp.getData(); + } + + /** + * Get user cashback setting status + * Get cashback setting state of specified user **Timeout: 15s** + * @param userAuthorizationId (required) + * @return ApiResponse<UserCashbackSettingStatus> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + + */ + protected ApiResponse getUserCashbackSettingStatusWithHttpInfo(String userAuthorizationId) throws ApiException { + Call call = getUserCashbackSettingStatusValidateBeforeCall(userAuthorizationId); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType, ApiNameConstants.GET_USER_CASHBACK_SETTING_STATUS); + } + + private Call getUserCashbackSettingStatusValidateBeforeCall(String userAuthorizationId) throws ApiException { + return ApiUtil.getCallObject(apiClient, "/v1/user/cashback_setting_state/{userAuthorizationId}", new Pair(ApiConstants.USER_AUTHORIZATION_ID, + userAuthorizationId), "GET"); + } + + /** + * Set useCashback flag + * Set the useCashback flag of specified user. **Timeout: 15s** + * + * @param body UserCashbackUseStatus + * @return NotDataResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public NotDataResponse updateUserCashbackUseStatus(UserCashbackUseStatus body) throws ApiException { + String message = validator.validate(body); + if (message != null) { + throw new IllegalArgumentException(message); + } + ApiResponse resp = updateUserCashbackUseStatusWithHttpInfo(body); + return resp.getData(); + } + + /** + * Set useCashback flag + * Set the useCashback flag of specified user. **Timeout: 15s** + * + * @param body UserCashbackUseStatus + * @return ApiResponse<NotDataResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + protected ApiResponse updateUserCashbackUseStatusWithHttpInfo(Object body) throws ApiException { + Call call = updateUserCashbackUseStatusBeforeCall(body); + Type localVarReturnType = new TypeToken() { + }.getType(); + return apiClient.execute(call, localVarReturnType, ApiNameConstants.UPDATE_USER_CASHBACK_USE_STATUS); + } + + private Call updateUserCashbackUseStatusBeforeCall(Object body) throws ApiException { + return ApiUtil.postCallObject(apiClient, "/v1/user/use_cashback", body, null); + } + + /** + * Set cashbackAutoInvestment flag + * Set cashbackAutoInvestment flag of specified user. **Timeout: 15s** + * + * @param body UserCashbackAutoInvestment + * @return NotDataResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public NotDataResponse updateUserCashbackAutoInvestment(UserCashbackAutoInvestment body) throws ApiException { + String message = validator.validate(body); + if (message != null) { + throw new IllegalArgumentException(message); + } + ApiResponse resp = updateUserCashbackAutoInvestmentWithHttpInfo(body); + return resp.getData(); + } + + /** + * Set cashbackAutoInvestment flag + * Set cashbackAutoInvestment flag of specified user. **Timeout: 15s** + * + * @param body UserCashbackAutoInvestment + * @return ApiResponse<NotDataResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + protected ApiResponse updateUserCashbackAutoInvestmentWithHttpInfo(Object body) throws ApiException { + Call call = updateUserCashbackAutoInvestmentBeforeCall(body); + Type localVarReturnType = new TypeToken() { + }.getType(); + return apiClient.execute(call, localVarReturnType, ApiNameConstants.UPDATE_USER_CASHBACK_AUTO_INVESTMENT); + } + + private Call updateUserCashbackAutoInvestmentBeforeCall(Object body) throws ApiException { + return ApiUtil.postCallObject(apiClient, "/v1/user/cashback_auto_investment", body, null); + } + } diff --git a/src/main/java/jp/ne/paypay/model/UserCashbackAutoInvestment.java b/src/main/java/jp/ne/paypay/model/UserCashbackAutoInvestment.java new file mode 100644 index 0000000..22bc15d --- /dev/null +++ b/src/main/java/jp/ne/paypay/model/UserCashbackAutoInvestment.java @@ -0,0 +1,113 @@ +package jp.ne.paypay.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import java.time.Instant; +import java.util.Objects; + +/** + * UserCashbackAutoInvestment + */ + +public class UserCashbackAutoInvestment { + + @SerializedName("userAuthorizationId") + @NotEmpty(message = "userAuthorizationId is required") + @Size(max = 64, message = "maximum 64 characters are allowed for userAuthorizationId") + private String userAuthorizationId = null; + + @SerializedName("cashbackAutoInvestment") + @NotNull(message = "cashbackAutoInvestment is required") + private Boolean cashbackAutoInvestment = null; + + @SerializedName("updatedAt") + private Long updatedAt = Instant.now().getEpochSecond(); + + /** + * Get userAuthorizationId + * @return userAuthorizationId + **/ + @ApiModelProperty(value = "") + public String getUserAuthorizationId() { + return userAuthorizationId; + } + + public void setUserAuthorizationId(String userAuthorizationId) { + this.userAuthorizationId = userAuthorizationId; + } + + /** + * Get cashbackAutoInvestment + * @return cashbackAutoInvestment + **/ + @ApiModelProperty(value = "") + public Boolean getCashbackAutoInvestment() { + return cashbackAutoInvestment; + } + + public void setCashbackAutoInvestment(Boolean cashbackAutoInvestment) { + this.cashbackAutoInvestment = cashbackAutoInvestment; + } + + /** + * Get updatedAt + * @return updatedAt + **/ + @ApiModelProperty(value = "") + public Long getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Long updatedAt) { + this.updatedAt = updatedAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserCashbackAutoInvestment userCashbackAutoInvestment = (UserCashbackAutoInvestment) o; + return Objects.equals(this.userAuthorizationId, userCashbackAutoInvestment.userAuthorizationId) && + Objects.equals(this.cashbackAutoInvestment, userCashbackAutoInvestment.cashbackAutoInvestment) && + Objects.equals(this.updatedAt, userCashbackAutoInvestment.updatedAt); + } + + @Override + public int hashCode() { + return Objects.hash(userAuthorizationId, cashbackAutoInvestment, updatedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UserCashbackAutoInvestment {\n"); + sb.append(" userAuthorizationId: ").append(toIndentedString(userAuthorizationId)).append("\n"); + sb.append(" useCashback: ").append(toIndentedString(cashbackAutoInvestment)).append("\n"); + sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).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 "); + } + +} + + + diff --git a/src/main/java/jp/ne/paypay/model/UserCashbackSettingStatus.java b/src/main/java/jp/ne/paypay/model/UserCashbackSettingStatus.java new file mode 100644 index 0000000..0f2acf8 --- /dev/null +++ b/src/main/java/jp/ne/paypay/model/UserCashbackSettingStatus.java @@ -0,0 +1,98 @@ +package jp.ne.paypay.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * UserCashbackSettingStatus + */ + +public class UserCashbackSettingStatus { + + @SerializedName("resultInfo") + private ResultInfo resultInfo = null; + + @SerializedName("data") + private UserCashbackStatus data = null; + + public UserCashbackSettingStatus 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 UserCashbackSettingStatus data(UserCashbackStatus data) { + this.data = data; + return this; + } + + + /** + * Get data + * @return data + **/ + @ApiModelProperty(value = "") + public UserCashbackStatus getData() { + return data; + } + public void setData(UserCashbackStatus data) { + this.data = data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserCashbackSettingStatus userCashbackSettingStatus = (UserCashbackSettingStatus) o; + return Objects.equals(this.resultInfo, userCashbackSettingStatus.resultInfo) && + Objects.equals(this.data, userCashbackSettingStatus.data); + } + + @Override + public int hashCode() { + return Objects.hash(resultInfo, data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UserCashbackSettingStatus {\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 "); + } + +} + + + diff --git a/src/main/java/jp/ne/paypay/model/UserCashbackStatus.java b/src/main/java/jp/ne/paypay/model/UserCashbackStatus.java new file mode 100644 index 0000000..560a072 --- /dev/null +++ b/src/main/java/jp/ne/paypay/model/UserCashbackStatus.java @@ -0,0 +1,87 @@ +package jp.ne.paypay.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * UserCashbackStatus + */ + +public class UserCashbackStatus { + + @SerializedName("useCashback") + private Boolean useCashback = null; + + @SerializedName("cashbackAutoInvestment") + private Boolean cashbackAutoInvestment = null; + + /** + * The flag whether user use cashback for payment + * @return useCashback + **/ + @ApiModelProperty(value = "The flag whether user use cashback for payment") + public Boolean getUseCashback() { + return useCashback; + } + + public void setUseCashback(Boolean useCashback) { + this.useCashback = useCashback; + } + + /** + * The flag whether user auto-invests points for Point Investment + * @return cashbackAutoInvestment + **/ + @ApiModelProperty(value = "The flag whether user auto-invests points for Point Investment") + public Boolean getCashbackAutoInvestment() { + return cashbackAutoInvestment; + } + + public void setCashbackAutoInvestment(Boolean cashbackAutoInvestment) { + this.cashbackAutoInvestment = cashbackAutoInvestment; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserCashbackStatus userCashbackStatus = (UserCashbackStatus) o; + return Objects.equals(this.useCashback, userCashbackStatus.useCashback) && + Objects.equals(this.cashbackAutoInvestment, userCashbackStatus.cashbackAutoInvestment); + } + + @Override + public int hashCode() { + return Objects.hash(useCashback, cashbackAutoInvestment); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UserCashbackStatus {\n"); + sb.append(" useCashback: ").append(toIndentedString(useCashback)).append("\n"); + sb.append(" cashbackAutoInvestment: ").append(toIndentedString(cashbackAutoInvestment)).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 "); + } +} + + + diff --git a/src/main/java/jp/ne/paypay/model/UserCashbackUseStatus.java b/src/main/java/jp/ne/paypay/model/UserCashbackUseStatus.java new file mode 100644 index 0000000..baca601 --- /dev/null +++ b/src/main/java/jp/ne/paypay/model/UserCashbackUseStatus.java @@ -0,0 +1,94 @@ +package jp.ne.paypay.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import java.util.Objects; + +/** + * UserCashbackUseStatus + */ + +public class UserCashbackUseStatus { + + @SerializedName("userAuthorizationId") + @NotEmpty(message = "userAuthorizationId is required") + @Size(max = 64, message = "maximum 64 characters are allowed for userAuthorizationId") + private String userAuthorizationId = null; + + @SerializedName("useCashback") + @NotNull(message = "useCashback is required") + private Boolean useCashback = null; + + /** + * Get userAuthorizationId + * @return userAuthorizationId + **/ + @ApiModelProperty(value = "") + public String getUserAuthorizationId() { + return userAuthorizationId; + } + + public void setUserAuthorizationId(String userAuthorizationId) { + this.userAuthorizationId = userAuthorizationId; + } + + /** + * Get useCashback + * @return useCashback + **/ + @ApiModelProperty(value = "") + public Boolean getUseCashback() { + return useCashback; + } + + public void setUseCashback(Boolean useCashback) { + this.useCashback = useCashback; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserCashbackUseStatus userCashbackUseStatus = (UserCashbackUseStatus) o; + return Objects.equals(this.userAuthorizationId, userCashbackUseStatus.userAuthorizationId) && + Objects.equals(this.useCashback, userCashbackUseStatus.useCashback); + } + + @Override + public int hashCode() { + return Objects.hash(userAuthorizationId, useCashback); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UserCashbackUseStatus {\n"); + sb.append(" userAuthorizationId: ").append(toIndentedString(userAuthorizationId)).append("\n"); + sb.append(" useCashback: ").append(toIndentedString(useCashback)).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 "); + } + +} + + + diff --git a/src/test/java/jp/ne/paypay/api/UserApiTest.java b/src/test/java/jp/ne/paypay/api/UserApiTest.java index d6f0498..718a7c8 100644 --- a/src/test/java/jp/ne/paypay/api/UserApiTest.java +++ b/src/test/java/jp/ne/paypay/api/UserApiTest.java @@ -7,6 +7,9 @@ import jp.ne.paypay.model.NotDataResponse; import jp.ne.paypay.model.ResultInfo; import jp.ne.paypay.model.UserAuthorizationStatus; +import jp.ne.paypay.model.UserCashbackAutoInvestment; +import jp.ne.paypay.model.UserCashbackSettingStatus; +import jp.ne.paypay.model.UserCashbackUseStatus; import org.junit.Assert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -95,5 +98,74 @@ public void unlinkUserTest() throws ApiException { Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS"); } - + + /** + * Get user cashback setting status + * + * Get cashback setting state of specified user + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getUserCashbackSettingStatusTest() throws ApiException { + + String userAuthorizationId = "userAuthorizationId"; + UserCashbackSettingStatus userCashbackSettingStatus = new UserCashbackSettingStatus(); + userCashbackSettingStatus.setResultInfo(resultInfo); + ApiResponse userCashbackSettingStatusApiResponse = new ApiResponse<>(00001, null, userCashbackSettingStatus); + Mockito.when(apiClient.escapeString(userAuthorizationId)).thenReturn(userAuthorizationId); + Mockito.when(api.getUserCashbackSettingStatusWithHttpInfo(userAuthorizationId)).thenReturn(userCashbackSettingStatusApiResponse); + + UserCashbackSettingStatus response = api.getUserCashbackSettingStatus(userAuthorizationId); + + Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS"); + } + + /** + * Set useCashback flag + * + * Set useCashback flag of specified user + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updateUserCashbackUseStatusTest() throws ApiException { + + UserCashbackUseStatus userCashbackUseStatus = new UserCashbackUseStatus(); + userCashbackUseStatus.setUserAuthorizationId("userAuthorizationId"); + userCashbackUseStatus.setUseCashback(true); + + NotDataResponse notDataResponse = new NotDataResponse(); + notDataResponse.setResultInfo(resultInfo); + ApiResponse userCashbackUseStatusApiResponse = new ApiResponse<>(00001, null, notDataResponse); + Mockito.when(api.updateUserCashbackUseStatusWithHttpInfo(userCashbackUseStatus)).thenReturn(userCashbackUseStatusApiResponse); + NotDataResponse response = api.updateUserCashbackUseStatus(userCashbackUseStatus); + Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS"); + } + + /** + * Set cashbackAutoInvestment flag + * + * Set cashbackAutoInvestment flag of specified user + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updateUserCashbackAutoInvestmentTest() throws ApiException { + + UserCashbackAutoInvestment userCashbackAutoInvestment = new UserCashbackAutoInvestment(); + userCashbackAutoInvestment.setUserAuthorizationId("userAuthorizationId"); + userCashbackAutoInvestment.setCashbackAutoInvestment(true); + + NotDataResponse notDataResponse = new NotDataResponse(); + notDataResponse.setResultInfo(resultInfo); + ApiResponse userCashbackUseStatusApiResponse = new ApiResponse<>(00001, null, notDataResponse); + Mockito.when(api.updateUserCashbackAutoInvestmentWithHttpInfo(userCashbackAutoInvestment)).thenReturn(userCashbackUseStatusApiResponse); + NotDataResponse response = api.updateUserCashbackAutoInvestment(userCashbackAutoInvestment); + Assert.assertEquals(response.getResultInfo().getMessage(), "SUCCESS"); + } + }