Skip to content

use long data type for model id #159

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

Merged
merged 7 commits into from
Jul 31, 2025
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
4 changes: 2 additions & 2 deletions src/main/java/com/bunq/sdk/context/SessionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class SessionContext implements java.io.Serializable {

@Expose
@SerializedName("user_id")
private final Integer userId;
private final Long userId;

@Expose
@SerializedName("user_person")
Expand Down Expand Up @@ -129,7 +129,7 @@ Date getExpiryTime() {
return expiryTime;
}

public Integer getUserId() {
public Long getUserId() {
return userId;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/bunq/sdk/context/UserContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void refreshContext() {
this.initMainMonetaryAccount(helper);
}

public Integer getUserId() {
public Long getUserId() {
return this.apiContext.getSessionContext().getUserId();
}

Expand All @@ -72,7 +72,7 @@ public boolean areAllUserSet() {
return this.userPerson != null && this.userCompany != null && this.userApiKey != null;
}

public Integer getMainMonetaryAccountId() {
public Long getMainMonetaryAccountId() {
if (this.primaryMonetaryAccountBank == null) {
throw new BunqException(ERROR_PRIMARY_MONETARY_ACCOUNT_IS_NOT_SET);
} else {
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/com/bunq/sdk/http/Pagination.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class Pagination {
public static final String PARAM_FUTURE_ID = "future_id";
public static final String PARAM_COUNT = "count";

private Integer olderId;
private Integer newerId;
private Integer futureId;
private Integer count;
private Long olderId;
private Long newerId;
private Long futureId;
private Long count;

/**
* Get the URL params required to request the next page of the listing.
Expand All @@ -35,7 +35,7 @@ public Map<String, String> getUrlParamsNextPage() {
assertHasNextPage();

Map<String, String> params = new HashMap<>();
params.put(PARAM_NEWER_ID, Integer.toString(getNextId()));
params.put(PARAM_NEWER_ID, Long.toString(getNextId()));
addCountToParamsIfNeeded(params);

return params;
Expand All @@ -47,7 +47,7 @@ private void assertHasNextPage() {
}
}

private Integer getNextId() {
private Long getNextId() {
if (hasNextPageAssured()) {
return newerId;
} else {
Expand All @@ -61,7 +61,7 @@ public boolean hasNextPageAssured() {

private void addCountToParamsIfNeeded(Map<String, String> params) {
if (count != null) {
params.put(PARAM_COUNT, Integer.toString(count));
params.put(PARAM_COUNT, Long.toString(count));
}
}

Expand All @@ -72,7 +72,7 @@ public Map<String, String> getUrlParamsPreviousPage() {
assertHasPreviousPage();

Map<String, String> params = new HashMap<>();
params.put(PARAM_OLDER_ID, Integer.toString(olderId));
params.put(PARAM_OLDER_ID, Long.toString(olderId));
addCountToParamsIfNeeded(params);

return params;
Expand All @@ -98,35 +98,35 @@ public Map<String, String> getUrlParamsCountOnly() {
return params;
}

public Integer getOlderId() {
public Long getOlderId() {
return olderId;
}

public void setOlderId(Integer olderId) {
public void setOlderId(Long olderId) {
this.olderId = olderId;
}

public Integer getNewerId() {
public Long getNewerId() {
return newerId;
}

public void setNewerId(Integer newerId) {
public void setNewerId(Long newerId) {
this.newerId = newerId;
}

public Integer getFutureId() {
public Long getFutureId() {
return futureId;
}

public void setFutureId(Integer futureId) {
public void setFutureId(Long futureId) {
this.futureId = futureId;
}

public Integer getCount() {
public Long getCount() {
return count;
}

public void setCount(Integer count) {
public void setCount(Long count) {
this.count = count;
}
}
14 changes: 7 additions & 7 deletions src/main/java/com/bunq/sdk/json/PaginationAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public Pagination deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
try {
JsonObject responseJson = json.getAsJsonObject();
Map<String, Integer> paginationBody = parsePaginationBody(responseJson);
Map<String, Long> paginationBody = parsePaginationBody(responseJson);

return createPagination(paginationBody);
} catch (URISyntaxException exception) {
throw new JsonParseException(exception);
}
}

private Map<String, Integer> parsePaginationBody(JsonObject responseJson)
private Map<String, Long> parsePaginationBody(JsonObject responseJson)
throws URISyntaxException {
Map<String, Integer> paginationBody = new HashMap<>();
Map<String, Long> paginationBody = new HashMap<>();
updatePaginationBodyFromResponseField(
paginationBody,
Pagination.PARAM_OLDER_ID,
Expand All @@ -65,7 +65,7 @@ private Map<String, Integer> parsePaginationBody(JsonObject responseJson)
return paginationBody;
}

private Pagination createPagination(Map<String, Integer> paginationBody) {
private Pagination createPagination(Map<String, Long> paginationBody) {
Pagination pagination = new Pagination();
pagination.setOlderId(paginationBody.get(Pagination.PARAM_OLDER_ID));
pagination.setNewerId(paginationBody.get(Pagination.PARAM_NEWER_ID));
Expand All @@ -76,7 +76,7 @@ private Pagination createPagination(Map<String, Integer> paginationBody) {
}

private void updatePaginationBodyFromResponseField(
Map<String, Integer> paginationBody,
Map<String, Long> paginationBody,
String idField,
JsonObject responseJson,
String responseField,
Expand All @@ -89,10 +89,10 @@ private void updatePaginationBodyFromResponseField(

for (String parameterName : Objects.requireNonNull(url).queryParameterNames()) {
if (responseParam.equals(parameterName)) {
paginationBody.put(idField, Integer.parseInt(Objects.requireNonNull(url.queryParameter(parameterName))));
paginationBody.put(idField, Long.parseLong(Objects.requireNonNull(url.queryParameter(parameterName))));
} else if (Pagination.PARAM_COUNT.equals(parameterName) &&
paginationBody.get(Pagination.PARAM_COUNT) == null) {
paginationBody.put(Pagination.PARAM_COUNT, Integer.parseInt(Objects.requireNonNull(url.queryParameter(parameterName))));
paginationBody.put(Pagination.PARAM_COUNT, Long.parseLong(Objects.requireNonNull(url.queryParameter(parameterName))));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/bunq/sdk/model/core/BunqModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ static <T> BunqResponse<T> fromJsonArrayNested(Class<T> classOfObject,
/**
* De-serializes an ID object and returns its integer value.
*/
protected static BunqResponse<Integer> processForId(BunqResponseRaw responseRaw) {
protected static BunqResponse<Long> processForId(BunqResponseRaw responseRaw) {
JsonObject responseItemObject = getResponseItemObject(responseRaw);
JsonObject responseItemObjectUnwrapped = getWrappedContent(responseItemObject, FIELD_ID);
Integer responseValue = gson.fromJson(responseItemObjectUnwrapped, Id.class).getId();
Long responseValue = gson.fromJson(responseItemObjectUnwrapped, Id.class).getId();

return new BunqResponse<>(responseValue, responseRaw.getHeaders());
}
Expand Down Expand Up @@ -195,11 +195,11 @@ protected static ApiContext getApiContext() {
return BunqContext.getApiContext();
}

protected static Integer determineUserId() {
protected static Long determineUserId() {
return BunqContext.getUserContext().getUserId();
}

protected static Integer determineMonetaryAccountId(Integer id) {
protected static Long determineMonetaryAccountId(Long id) {
if (id == null) {
return BunqContext.getUserContext().getPrimaryMonetaryAccountBank().getId();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.List;

public class DeviceServerInternal extends DeviceServerApiObject {
public static BunqResponse<Integer> create(
public static BunqResponse<Long> create(
ApiContext apiContext,
String description,
String secret,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/bunq/sdk/model/core/Id.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

public class Id {

private Integer id;
private Long id;

public Id() {
}

public Integer getId() {
public Long getId() {
return id;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/bunq/sdk/model/core/Installation.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private static byte[] generateRequestBodyBytes(String publicKeyClientString) {
return gson.toJson(installationRequestBody).getBytes();
}

public Integer getId() {
public Long getId() {
return id.getId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static BunqResponse<List<NotificationFilterUrlObject>> createWithListResp
* Create notification filters with list response type.
*/
public static BunqResponse<List<NotificationFilterUrlObject>> createWithListResponse(
Integer monetaryAccountId,
Long monetaryAccountId,
List<NotificationFilterUrlObject> allNotificationFilter
) {
return createWithListResponse(monetaryAccountId, allNotificationFilter, null);
Expand All @@ -38,7 +38,7 @@ public static BunqResponse<List<NotificationFilterUrlObject>> createWithListResp
* Create notification filters with list response type.
*/
public static BunqResponse<List<NotificationFilterUrlObject>> createWithListResponse(
Integer monetaryAccountId,
Long monetaryAccountId,
List<NotificationFilterUrlObject> allNotificationFilter,
Map<String, String> customHeaders
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public UserApiObject getFirstUser() {
return response.getValue().get(INDEX_FIRST);
}

public MonetaryAccountBankApiObject getFirstActiveMonetaryAccountBankByUserId(Integer userId) {
public MonetaryAccountBankApiObject getFirstActiveMonetaryAccountBankByUserId(Long userId) {
BunqResponseRaw responseRaw = getRawResponse(
String.format(ENDPOINT_MONETARY_ACCOUNT_BANK, userId)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class AdditionalTransactionInformationCategoryApiObject extends BunqModel
*/
@Expose
@SerializedName("order")
private Integer order;
private Long order;

/**
* The description of the category.
Expand Down Expand Up @@ -140,11 +140,11 @@ public void setStatus(String status) {
/**
* The sort order of the category.
*/
public Integer getOrder() {
public Long getOrder() {
return this.order;
}

public void setOrder(Integer order) {
public void setOrder(Long order) {
this.order = order;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public AdditionalTransactionInformationCategoryUserDefinedApiObject(String statu
* @param color The color of the category.
* @param icon The icon of the category.
*/
public static BunqResponse<Integer> create(String status, String category, String description, String color, String icon, Map<String, String> customHeaders) {
public static BunqResponse<Long> create(String status, String category, String description, String color, String icon, Map<String, String> customHeaders) {
ApiClient apiClient = new ApiClient(getApiContext());

if (customHeaders == null) {
Expand All @@ -123,27 +123,27 @@ public static BunqResponse<Integer> create(String status, String category, Strin
return processForId(responseRaw);
}

public static BunqResponse<Integer> create() {
public static BunqResponse<Long> create() {
return create(null, null, null, null, null, null);
}

public static BunqResponse<Integer> create(String status) {
public static BunqResponse<Long> create(String status) {
return create(status, null, null, null, null, null);
}

public static BunqResponse<Integer> create(String status, String category) {
public static BunqResponse<Long> create(String status, String category) {
return create(status, category, null, null, null, null);
}

public static BunqResponse<Integer> create(String status, String category, String description) {
public static BunqResponse<Long> create(String status, String category, String description) {
return create(status, category, description, null, null, null);
}

public static BunqResponse<Integer> create(String status, String category, String description, String color) {
public static BunqResponse<Long> create(String status, String category, String description, String color) {
return create(status, category, description, color, null, null);
}

public static BunqResponse<Integer> create(String status, String category, String description, String color, String icon) {
public static BunqResponse<Long> create(String status, String category, String description, String color, String icon) {
return create(status, category, description, color, icon, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class AttachmentConversationContentApiObject extends BunqModel {
/**
* Get the raw content of a specific attachment.
*/
public static BunqResponse<byte[]> list(Integer chatConversationId, Integer attachmentId, Map<String, String> params, Map<String, String> customHeaders) {
public static BunqResponse<byte[]> list(Long chatConversationId, Long attachmentId, Map<String, String> params, Map<String, String> customHeaders) {
ApiClient apiClient = new ApiClient(getApiContext());
BunqResponseRaw responseRaw = apiClient.get(String.format(ENDPOINT_URL_LISTING, determineUserId(), chatConversationId, attachmentId), params, customHeaders);

Expand All @@ -45,13 +45,13 @@ public static BunqResponse<byte[]> list(Integer chatConversationId, Integer atta
public static BunqResponse<byte[]> list() {
return list(null, null, null, null);
}
public static BunqResponse<byte[]> list(Integer chatConversationId) {
public static BunqResponse<byte[]> list(Long chatConversationId) {
return list(chatConversationId, null, null, null);
}
public static BunqResponse<byte[]> list(Integer chatConversationId, Integer attachmentId) {
public static BunqResponse<byte[]> list(Long chatConversationId, Long attachmentId) {
return list(chatConversationId, attachmentId, null, null);
}
public static BunqResponse<byte[]> list(Integer chatConversationId, Integer attachmentId, Map<String, String> params) {
public static BunqResponse<byte[]> list(Long chatConversationId, Long attachmentId, Map<String, String> params) {
return list(chatConversationId, attachmentId, params, null);
}

Expand Down
Loading