Skip to content
Closed
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### v4.2.0 (2026-02-16)
* * *

### New Features:
* Added subdomain routing support for API requests.
* Added JSON request body support for applicable APIs.

### v4.1.1 (2026-02-10)
* * *
### Bug Fixes:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.1
4.2.0
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "com.chargebee"
version = "4.1.1"
version = "4.2.0"
description = "Java client library for ChargeBee"

// Project metadata
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/chargebee/v4/client/ChargebeeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public String getBaseUrl() {
}
return String.format("%s://%s.%s/api/v2", protocol, siteName, domainSuffix);
}

/**
* Send a GET request to the specified path.
*
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/com/chargebee/v4/internal/SubDomain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is auto-generated by Chargebee.
* Copyright 2026 Chargebee Inc.
*/

package com.chargebee.v4.internal;

/** Subdomain identifiers for routing API operations to the correct service endpoint. */
public enum SubDomain {
INGEST("ingest"),

FILE_INGEST("file-ingest"),

GROW("grow");

private final String value;

SubDomain(String value) {
this.value = value;
}

/**
* Get the string value of this subdomain.
*
* @return the subdomain string value
*/
public String getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.chargebee.v4.models.offerEvent.params;

import com.chargebee.v4.internal.Recommended;
import com.chargebee.v4.internal.JsonUtil;

import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -49,6 +50,11 @@ public Map<String, Object> toFormData() {
return formData;
}

/** Get the JSON string representation for this request. */
public String toJsonString() {
return JsonUtil.toJson(toFormData());
}

/** Create a new builder for OfferEventsParams. */
@Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness")
public static OfferEventsBuilder builder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.chargebee.v4.models.offerFulfillment.params;

import com.chargebee.v4.internal.Recommended;
import com.chargebee.v4.internal.JsonUtil;

import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -49,6 +50,11 @@ public Map<String, Object> toFormData() {
return formData;
}

/** Get the JSON string representation for this request. */
public String toJsonString() {
return JsonUtil.toJson(toFormData());
}

/** Create a new builder for OfferFulfillmentsParams. */
@Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness")
public static OfferFulfillmentsBuilder builder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.chargebee.v4.models.offerFulfillment.params;

import com.chargebee.v4.internal.Recommended;
import com.chargebee.v4.internal.JsonUtil;

import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -62,6 +63,11 @@ public Map<String, Object> toFormData() {
return formData;
}

/** Get the JSON string representation for this request. */
public String toJsonString() {
return JsonUtil.toJson(toFormData());
}

/** Create a new builder for OfferFulfillmentsUpdateParams. */
@Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness")
public static OfferFulfillmentsUpdateBuilder builder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ public Map<String, Object> toFormData() {
return formData;
}

/** Get the JSON string representation for this request. */
public String toJsonString() {
return JsonUtil.toJson(toFormData());
}

/** Create a new builder for PersonalizedOffersParams. */
@Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness")
public static PersonalizedOffersBuilder builder() {
Expand Down Expand Up @@ -302,6 +307,11 @@ public Map<String, Object> toFormData() {
return formData;
}

/** Get the JSON string representation for this request. */
public String toJsonString() {
return JsonUtil.toJson(toFormData());
}

/** Create a new builder for RequestContextParams. */
@Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness")
public static RequestContextBuilder builder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public Map<String, Object> toFormData() {
return formData;
}

/** Get the JSON string representation for this request. */
public String toJsonString() {
return JsonUtil.toJson(toFormData());
}

/** Create a new builder for UsageEventBatchIngestParams. */
@Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness")
public static UsageEventBatchIngestBuilder builder() {
Expand Down Expand Up @@ -135,6 +140,11 @@ public Map<String, Object> toFormData() {
return formData;
}

/** Get the JSON string representation for this request. */
public String toJsonString() {
return JsonUtil.toJson(toFormData());
}

/** Create a new builder for EventsParams. */
@Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness")
public static EventsBuilder builder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public Map<String, Object> toFormData() {
return formData;
}

/** Get the JSON string representation for this request. */
public String toJsonString() {
return JsonUtil.toJson(toFormData());
}

/** Create a new builder for UsageEventCreateParams. */
@Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness")
public static UsageEventCreateBuilder builder() {
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/com/chargebee/v4/services/BaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ protected Response post(String path, Map<String, Object> formData) throws Charge
return client.executeWithInterceptor(builder.build());
}

/**
* Helper: POST with subdomain routing.
*/
protected Response postWithSubDomain(String path, String subDomain, Map<String, Object> formData) throws ChargebeeException {
String fullUrl = UrlBuilder.buildUrl(baseUrlWithSubDomain(subDomain), path, null);
Request.Builder builder = Request.builder()
.method("POST")
.url(fullUrl)
.formBody(formData);
applyMergedHeaders(builder);
return client.executeWithInterceptor(builder.build());
}

/**
* Helper: POST JSON with optional headers.
*/
Expand All @@ -121,6 +134,19 @@ protected Response postJson(String path, String jsonData) throws ChargebeeExcept
return client.executeWithInterceptor(builder.build());
}

/**
* Helper: POST JSON with subdomain routing.
*/
protected Response postJsonWithSubDomain(String path, String subDomain, String jsonData) throws ChargebeeException {
String fullUrl = UrlBuilder.buildUrl(baseUrlWithSubDomain(subDomain), path, null);
Request.Builder builder = Request.builder()
.method("POST")
.url(fullUrl)
.jsonBody(jsonData);
applyMergedHeaders(builder);
return client.executeWithInterceptor(builder.build());
}

/**
* Helper: POST async with optional headers.
*/
Expand Down Expand Up @@ -183,6 +209,31 @@ protected Response get(String path, Map<String, Object> queryParams) throws Char
return client.executeWithInterceptor(builder.build());
}

/**
* GET with subdomain routing.
*/
protected Response getWithSubDomain(String path, String subDomain, Map<String, Object> queryParams) throws ChargebeeException {
String fullUrl = UrlBuilder.buildUrl(baseUrlWithSubDomain(subDomain), path, queryParams);
Request.Builder builder = Request.builder()
.method("GET")
.url(fullUrl);
applyMergedHeaders(builder);
return client.executeWithInterceptor(builder.build());
}

/**
* Build base URL with subdomain prefix for routing.
* Constructs {@code protocol://siteName.subDomain.domainSuffix/api/v2}.
*/
private String baseUrlWithSubDomain(String subDomain) {
String endpoint = client.getEndpoint();
if (endpoint != null && !endpoint.trim().isEmpty()) {
return endpoint;
}
return String.format("%s://%s.%s.%s/api/v2",
client.getProtocol(), client.getSiteName(), subDomain, client.getDomainSuffix());
}

/**
* GET async with Object query parameters.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import com.chargebee.v4.models.offerEvent.responses.OfferEventsResponse;

import com.chargebee.v4.internal.SubDomain;

public final class OfferEventService extends BaseService<OfferEventService> {

private final ServiceConfig config;
Expand Down Expand Up @@ -55,15 +57,16 @@ public OfferEventService withOptions(RequestOptions options) {
*/
Response offerEventsRaw(OfferEventsParams params) throws ChargebeeException {

return post("/offer_events", params != null ? params.toFormData() : null);
return postJsonWithSubDomain(
"/offer_events", SubDomain.GROW.getValue(), params != null ? params.toJsonString() : null);
}

/**
* offerEvents a offerEvent using raw JSON payload (executes immediately) - returns raw Response.
*/
Response offerEventsRaw(String jsonPayload) throws ChargebeeException {

return postJson("/offer_events", jsonPayload);
return postJsonWithSubDomain("/offer_events", SubDomain.GROW.getValue(), jsonPayload);
}

public OfferEventsResponse offerEvents(OfferEventsParams params) throws ChargebeeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import com.chargebee.v4.models.offerFulfillment.responses.OfferFulfillmentsUpdateResponse;

import com.chargebee.v4.internal.SubDomain;

public final class OfferFulfillmentService extends BaseService<OfferFulfillmentService> {

private final ServiceConfig config;
Expand Down Expand Up @@ -63,7 +65,10 @@ public OfferFulfillmentService withOptions(RequestOptions options) {
*/
Response offerFulfillmentsRaw(OfferFulfillmentsParams params) throws ChargebeeException {

return post("/offer_fulfillments", params != null ? params.toFormData() : null);
return postJsonWithSubDomain(
"/offer_fulfillments",
SubDomain.GROW.getValue(),
params != null ? params.toJsonString() : null);
}

/**
Expand All @@ -72,7 +77,7 @@ Response offerFulfillmentsRaw(OfferFulfillmentsParams params) throws ChargebeeEx
*/
Response offerFulfillmentsRaw(String jsonPayload) throws ChargebeeException {

return postJson("/offer_fulfillments", jsonPayload);
return postJsonWithSubDomain("/offer_fulfillments", SubDomain.GROW.getValue(), jsonPayload);
}

public OfferFulfillmentsResponse offerFulfillments(OfferFulfillmentsParams params)
Expand All @@ -90,7 +95,7 @@ Response offerFulfillmentsGetRaw(String offerFulfillmentId) throws ChargebeeExce
"offer-fulfillment-id",
offerFulfillmentId);

return get(path, null);
return getWithSubDomain(path, SubDomain.GROW.getValue(), null);
}

public OfferFulfillmentsGetResponse offerFulfillmentsGet(String offerFulfillmentId)
Expand All @@ -107,7 +112,7 @@ Response offerFulfillmentsUpdateRaw(String offerFulfillmentId) throws ChargebeeE
"offer-fulfillment-id",
offerFulfillmentId);

return post(path, null);
return postWithSubDomain(path, SubDomain.GROW.getValue(), null);
}

/**
Expand All @@ -121,7 +126,8 @@ Response offerFulfillmentsUpdateRaw(
"/offer_fulfillments/{offer-fulfillment-id}",
"offer-fulfillment-id",
offerFulfillmentId);
return post(path, params.toFormData());
return postJsonWithSubDomain(
path, SubDomain.GROW.getValue(), params != null ? params.toJsonString() : null);
}

/**
Expand All @@ -135,7 +141,7 @@ Response offerFulfillmentsUpdateRaw(String offerFulfillmentId, String jsonPayloa
"/offer_fulfillments/{offer-fulfillment-id}",
"offer-fulfillment-id",
offerFulfillmentId);
return postJson(path, jsonPayload);
return postJsonWithSubDomain(path, SubDomain.GROW.getValue(), jsonPayload);
}

public OfferFulfillmentsUpdateResponse offerFulfillmentsUpdate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import com.chargebee.v4.models.personalizedOffer.responses.PersonalizedOffersResponse;

import com.chargebee.v4.internal.SubDomain;

public final class PersonalizedOfferService extends BaseService<PersonalizedOfferService> {

private final ServiceConfig config;
Expand Down Expand Up @@ -57,7 +59,10 @@ public PersonalizedOfferService withOptions(RequestOptions options) {
*/
Response personalizedOffersRaw(PersonalizedOffersParams params) throws ChargebeeException {

return post("/personalized_offers", params != null ? params.toFormData() : null);
return postJsonWithSubDomain(
"/personalized_offers",
SubDomain.GROW.getValue(),
params != null ? params.toJsonString() : null);
}

/**
Expand All @@ -66,7 +71,7 @@ Response personalizedOffersRaw(PersonalizedOffersParams params) throws Chargebee
*/
Response personalizedOffersRaw(String jsonPayload) throws ChargebeeException {

return postJson("/personalized_offers", jsonPayload);
return postJsonWithSubDomain("/personalized_offers", SubDomain.GROW.getValue(), jsonPayload);
}

public PersonalizedOffersResponse personalizedOffers(PersonalizedOffersParams params)
Expand Down
Loading