Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve deprecations and recommendations #172

Merged
merged 23 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ buildscript {
}
}

task javadocJar(type: Jar) {
tasks.register('javadocJar', Jar) {
archiveClassifier = 'javadoc'
from javadoc
}

task sourcesJar(type: Jar) {
tasks.register('sourcesJar', Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/co/omise/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class Client {

private final OkHttpClient httpClient;
private Requester requester;
private final Requester requester;

/**
* Creates a Client that sends the specified API version string in the header to access an earlier version
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/co/omise/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void reverseCharge() throws IOException, OmiseException, ClientException {
new Charge.ReverseRequestBuilder("chrg_test_4xso2s8ivdej29pqnhz").build();
Charge charge = client().sendRequest(reverseChargeRequest);

System.out.printf("charge reversal: %s", Boolean.toString(charge.isReversed()));
System.out.printf("charge reversal: %s", charge.isReversed());
}

void updateCharge() throws IOException, OmiseException, ClientException {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/co/omise/Serializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ private Serializer() {

.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true)
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); // TODO: Deprecate in vNext
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}

/**
Expand Down Expand Up @@ -197,7 +196,7 @@ public <T extends OmiseObject> Map<String, Object> serializeToMap(T model) {
* @return The string value for using as query parameters.
*/
public <T extends Enum<T>> String serializeToQueryParams(T value) {
return (String) objectMapper.convertValue(value, String.class);
return objectMapper.convertValue(value, String.class);
}

/**
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/co/omise/models/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ public void setZeroInterestInstallments(boolean zeroInterestInstallments) {

public static class GetRequestBuilder extends RequestBuilder<Account> {

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
return buildUrl(Endpoint.API, "account");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/co/omise/models/AuthorizationType.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public enum AuthorizationType {
@JsonProperty("pre_auth")
PreAuth,
@JsonProperty("final_auth")
FinalAuth;
FinalAuth
}
9 changes: 0 additions & 9 deletions src/main/java/co/omise/models/Balance.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import co.omise.Endpoint;
import co.omise.requests.RequestBuilder;
import co.omise.requests.ResponseType;
import com.fasterxml.jackson.annotation.JsonProperty;
import okhttp3.HttpUrl;
import okhttp3.RequestBody;

import java.io.IOException;

/**
* Balance object
Expand Down Expand Up @@ -63,11 +59,6 @@ public void setTransferable(long transferable) {

public static class GetRequestBuilder extends RequestBuilder<Balance> {

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
return buildUrl(Endpoint.API, "balance");
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/co/omise/models/Capability.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import co.omise.requests.ResponseType;
import com.fasterxml.jackson.annotation.JsonProperty;
import okhttp3.HttpUrl;
import okhttp3.RequestBody;

import java.io.IOException;
import java.util.List;

/**
Expand Down Expand Up @@ -66,11 +64,6 @@ public void setZeroInterestInstallments(boolean zeroInterestInstallments) {

public static class GetRequestBuilder extends RequestBuilder<Capability> {

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
return buildUrl(Endpoint.API, "capability");
Expand Down
24 changes: 7 additions & 17 deletions src/main/java/co/omise/models/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ public Create expiration(int month, int year) {
}

public static class DeleteRequestBuilder extends RequestBuilder<Card> {
private String customerId;
private String cardId;
private final String customerId;
private final String cardId;
public DeleteRequestBuilder(String customerId, String cardId) {
this.customerId = customerId;
this.cardId = cardId;
Expand All @@ -326,18 +326,13 @@ protected ResponseType<Card> type() {
}

public static class GetRequestBuilder extends RequestBuilder<Card> {
private String customerId;
private String cardId;
private final String customerId;
private final String cardId;
public GetRequestBuilder(String customerId, String cardId) {
this.customerId = customerId;
this.cardId = cardId;
}

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
return buildUrl(Endpoint.API, "customers", customerId, "cards", cardId);
Expand All @@ -350,8 +345,8 @@ protected ResponseType<Card> type() {
}

public static class UpdateRequestBuilder extends RequestBuilder<Card> {
private String customerId;
private String cardId;
private final String customerId;
private final String cardId;

@JsonProperty
private String city;
Expand Down Expand Up @@ -425,17 +420,12 @@ protected RequestBody payload() throws IOException {
}

public static class ListRequestBuilder extends RequestBuilder<ScopedList<Card>> {
private String customerId;
private final String customerId;
private ScopedList.Options options;
public ListRequestBuilder(String customerId) {
this.customerId = customerId;
}

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
if (options == null) {
Expand Down
19 changes: 3 additions & 16 deletions src/main/java/co/omise/models/Chain.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import co.omise.Endpoint;
import co.omise.requests.RequestBuilder;
import co.omise.requests.ResponseType;
import com.fasterxml.jackson.annotation.JsonProperty;

import com.fasterxml.jackson.core.type.TypeReference;
import okhttp3.HttpUrl;
import okhttp3.RequestBody;

import java.io.IOException;

/**
* Chain object
Expand Down Expand Up @@ -56,11 +53,6 @@ public void setRevoked(boolean revoked) {
public static class ListRequestBuilder extends RequestBuilder<ScopedList<Chain>> {
private ScopedList.Options options;

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
if (options == null) {
Expand All @@ -84,16 +76,11 @@ public ListRequestBuilder options(ScopedList.Options options) {
}

public static class GetRequestBuilder extends RequestBuilder<Chain> {
private String chainId;
private final String chainId;
public GetRequestBuilder(String chainId) {
this.chainId = chainId;
}

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
return buildUrl(Endpoint.API, "chains", chainId);
Expand All @@ -106,7 +93,7 @@ protected ResponseType<Chain> type() {
}

public static class RevokeRequestBuilder extends RequestBuilder<Chain> {
private String chainId;
private final String chainId;
public RevokeRequestBuilder(String chainId) {
this.chainId = chainId;
}
Expand Down
36 changes: 8 additions & 28 deletions src/main/java/co/omise/models/Charge.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,6 @@ public void setMerchantAdvice(String merchantAdvice) {
public static class ListRequestBuilder extends RequestBuilder<ScopedList<Charge>> {
private ScopedList.Options options;

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
if (options == null) {
Expand Down Expand Up @@ -689,17 +684,12 @@ public CreateRequestBuilder metadata(String key, Object value) {
}

public static class ListEventsRequestBuilder extends RequestBuilder<ScopedList<Event>> {
private String chargeId;
private final String chargeId;
private ScopedList.Options options;
public ListEventsRequestBuilder(String chargeId) {
this.chargeId = chargeId;
}

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
if (options == null) {
Expand All @@ -725,11 +715,6 @@ public ListEventsRequestBuilder options(ScopedList.Options options) {
public static class ListSchedulesRequestBuilder extends RequestBuilder<ScopedList<Schedule>> {
private ScopedList.Options options;

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
if (options == null) {
Expand All @@ -753,16 +738,11 @@ public ListSchedulesRequestBuilder options(ScopedList.Options options) {
}

public static class GetRequestBuilder extends RequestBuilder<Charge> {
private String chargeId;
private final String chargeId;
public GetRequestBuilder(String chargeId) {
this.chargeId = chargeId;
}

@Override
protected String method() {
return GET;
}

@Override
protected HttpUrl path() {
return buildUrl(Endpoint.API, "charges", chargeId);
Expand All @@ -775,7 +755,7 @@ protected ResponseType<Charge> type() {
}

public static class UpdateRequestBuilder extends RequestBuilder<Charge> {
private String chargeId;
private final String chargeId;

@JsonProperty
private String description;
Expand Down Expand Up @@ -828,7 +808,7 @@ public UpdateRequestBuilder metadata(String key, Object value) {
}

public static class CaptureRequestBuilder extends RequestBuilder<Charge> {
private String chargeId;
private final String chargeId;

@JsonProperty("capture_amount")
private long captureAmount;
Expand Down Expand Up @@ -864,7 +844,7 @@ protected RequestBody payload() throws IOException {
}

public static class ExpireRequestBuilder extends RequestBuilder<Charge> {
private String chargeId;
private final String chargeId;
public ExpireRequestBuilder(String chargeId) {
this.chargeId = chargeId;
}
Expand All @@ -886,7 +866,7 @@ protected ResponseType<Charge> type() {
}

public static class MarkAsFailedRequestBuilder extends RequestBuilder<Charge> {
private String chargeId;
private final String chargeId;
public MarkAsFailedRequestBuilder(String chargeId) {
this.chargeId = chargeId;
}
Expand All @@ -908,7 +888,7 @@ protected ResponseType<Charge> type() {
}

public static class MarkAsPaidRequestBuilder extends RequestBuilder<Charge> {
private String chargeId;
private final String chargeId;
public MarkAsPaidRequestBuilder(String chargeId) {
this.chargeId = chargeId;
}
Expand All @@ -930,7 +910,7 @@ protected ResponseType<Charge> type() {
}

public static class ReverseRequestBuilder extends RequestBuilder<Charge> {
private String chargeId;
private final String chargeId;
public ReverseRequestBuilder(String chargeId) {
this.chargeId = chargeId;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/co/omise/models/ChargeStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public enum ChargeStatus {
@JsonProperty("successful")
Successful,
@JsonProperty("unknown")
Unknown;
Unknown
}
Loading
Loading