diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e398a71..185775a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### v4.0.3 (2026-02-05) +* * * + +### New Features: +* Add custom field support for sub-resources in HostedPage, PricingPageSession, Quote, Subscription, and Gift operations. + ### v4.0.2 (2026-01-30) * * * diff --git a/VERSION b/VERSION index 4d54dadd..c4e41f94 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.2 +4.0.3 diff --git a/build.gradle.kts b/build.gradle.kts index 7ded6db8..85664f20 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "com.chargebee" -version = "4.0.2" +version = "4.0.3" description = "Java client library for ChargeBee" // Project metadata diff --git a/dist/chargebee-java-4.0.1-javadoc.jar b/dist/chargebee-java-4.0.1-javadoc.jar deleted file mode 100644 index 3ba04acc..00000000 Binary files a/dist/chargebee-java-4.0.1-javadoc.jar and /dev/null differ diff --git a/dist/chargebee-java-4.0.1-sources.jar b/dist/chargebee-java-4.0.1-sources.jar deleted file mode 100644 index 891f5688..00000000 Binary files a/dist/chargebee-java-4.0.1-sources.jar and /dev/null differ diff --git a/dist/chargebee-java-4.0.1.jar b/dist/chargebee-java-4.0.1.jar deleted file mode 100644 index bd218b61..00000000 Binary files a/dist/chargebee-java-4.0.1.jar and /dev/null differ diff --git a/src/main/java/com/chargebee/v4/models/addon/params/AddonListParams.java b/src/main/java/com/chargebee/v4/models/addon/params/AddonListParams.java index 1121c762..76923f83 100644 --- a/src/main/java/com/chargebee/v4/models/addon/params/AddonListParams.java +++ b/src/main/java/com/chargebee/v4/models/addon/params/AddonListParams.java @@ -11,7 +11,6 @@ import com.chargebee.v4.filters.StringFilter; import com.chargebee.v4.filters.NumberFilter; import com.chargebee.v4.filters.TimestampFilter; - import com.chargebee.v4.filters.CustomFieldSelector; import java.util.Collections; diff --git a/src/main/java/com/chargebee/v4/models/coupon/params/CouponListParams.java b/src/main/java/com/chargebee/v4/models/coupon/params/CouponListParams.java index 447d6151..ffc9dadd 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/params/CouponListParams.java +++ b/src/main/java/com/chargebee/v4/models/coupon/params/CouponListParams.java @@ -10,7 +10,6 @@ import com.chargebee.v4.internal.Recommended; import com.chargebee.v4.filters.StringFilter; import com.chargebee.v4.filters.TimestampFilter; - import com.chargebee.v4.filters.CustomFieldSelector; import java.util.Collections; diff --git a/src/main/java/com/chargebee/v4/models/customer/params/CustomerListParams.java b/src/main/java/com/chargebee/v4/models/customer/params/CustomerListParams.java index a4d75587..adbdb360 100644 --- a/src/main/java/com/chargebee/v4/models/customer/params/CustomerListParams.java +++ b/src/main/java/com/chargebee/v4/models/customer/params/CustomerListParams.java @@ -10,7 +10,6 @@ import com.chargebee.v4.internal.Recommended; import com.chargebee.v4.filters.StringFilter; import com.chargebee.v4.filters.TimestampFilter; - import com.chargebee.v4.filters.CustomFieldSelector; import java.util.Collections; diff --git a/src/main/java/com/chargebee/v4/models/feature/params/FeatureListParams.java b/src/main/java/com/chargebee/v4/models/feature/params/FeatureListParams.java index 7e6db631..c723cf82 100644 --- a/src/main/java/com/chargebee/v4/models/feature/params/FeatureListParams.java +++ b/src/main/java/com/chargebee/v4/models/feature/params/FeatureListParams.java @@ -9,7 +9,6 @@ import com.chargebee.v4.internal.Recommended; import com.chargebee.v4.filters.StringFilter; - import com.chargebee.v4.filters.CustomFieldSelector; import java.util.Collections; diff --git a/src/main/java/com/chargebee/v4/models/gift/params/GiftCreateParams.java b/src/main/java/com/chargebee/v4/models/gift/params/GiftCreateParams.java index 427fc417..4cd3ce00 100644 --- a/src/main/java/com/chargebee/v4/models/gift/params/GiftCreateParams.java +++ b/src/main/java/com/chargebee/v4/models/gift/params/GiftCreateParams.java @@ -9,6 +9,7 @@ import com.chargebee.v4.internal.Recommended; import com.chargebee.v4.internal.JsonUtil; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -1107,6 +1108,8 @@ public static final class SubscriptionParams { private final String planQuantityInDecimal; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.planId = builder.planId; @@ -1114,6 +1117,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.planQuantity = builder.planQuantity; this.planQuantityInDecimal = builder.planQuantityInDecimal; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getPlanId() { @@ -1128,6 +1136,10 @@ public String getPlanQuantityInDecimal() { return planQuantityInDecimal; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -1147,6 +1159,8 @@ public Map toFormData() { formData.put("plan_quantity_in_decimal", this.planQuantityInDecimal); } + formData.putAll(customFields); + return formData; } @@ -1164,6 +1178,8 @@ public static final class SubscriptionBuilder { private String planQuantityInDecimal; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder planId(String value) { @@ -1181,6 +1197,42 @@ public SubscriptionBuilder planQuantityInDecimal(String value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutExistingForItemsParams.java b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutExistingForItemsParams.java index b23db35c..541ac2a9 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutExistingForItemsParams.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutExistingForItemsParams.java @@ -8,6 +8,7 @@ import com.chargebee.v4.internal.Recommended; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -752,6 +753,8 @@ public static final class SubscriptionParams { private final Integer contractTermBillingCycleOnRenewal; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.id = builder.id; @@ -771,6 +774,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.invoiceNotes = builder.invoiceNotes; this.contractTermBillingCycleOnRenewal = builder.contractTermBillingCycleOnRenewal; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -809,6 +817,10 @@ public Integer getContractTermBillingCycleOnRenewal() { return contractTermBillingCycleOnRenewal; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -859,6 +871,8 @@ public Map toFormData() { "contract_term_billing_cycle_on_renewal", this.contractTermBillingCycleOnRenewal); } + formData.putAll(customFields); + return formData; } @@ -888,6 +902,8 @@ public static final class SubscriptionBuilder { private Integer contractTermBillingCycleOnRenewal; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder id(String value) { @@ -937,6 +953,42 @@ public SubscriptionBuilder contractTermBillingCycleOnRenewal(Integer value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } @@ -1035,6 +1087,8 @@ public static final class CustomerParams { private final String entityIdentifierStandard; + private final Map customFields; + private CustomerParams(CustomerBuilder builder) { this.vatNumber = builder.vatNumber; @@ -1046,6 +1100,11 @@ private CustomerParams(CustomerBuilder builder) { this.entityIdentifierScheme = builder.entityIdentifierScheme; this.entityIdentifierStandard = builder.entityIdentifierStandard; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getVatNumber() { @@ -1068,6 +1127,10 @@ public String getEntityIdentifierStandard() { return entityIdentifierStandard; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -1097,6 +1160,8 @@ public Map toFormData() { formData.put("entity_identifier_standard", this.entityIdentifierStandard); } + formData.putAll(customFields); + return formData; } @@ -1118,6 +1183,8 @@ public static final class CustomerBuilder { private String entityIdentifierStandard; + private Map customFields = new LinkedHashMap<>(); + private CustomerBuilder() {} public CustomerBuilder vatNumber(String value) { @@ -1145,6 +1212,42 @@ public CustomerBuilder entityIdentifierStandard(String value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public CustomerBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public CustomerBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public CustomerParams build() { return new CustomerParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutExistingParams.java b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutExistingParams.java index 09a7b434..3e00cf7b 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutExistingParams.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutExistingParams.java @@ -8,6 +8,7 @@ import com.chargebee.v4.internal.Recommended; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -600,6 +601,8 @@ public static final class SubscriptionParams { private final Integer contractTermBillingCycleOnRenewal; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.id = builder.id; @@ -629,6 +632,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.invoiceNotes = builder.invoiceNotes; this.contractTermBillingCycleOnRenewal = builder.contractTermBillingCycleOnRenewal; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -687,6 +695,10 @@ public Integer getContractTermBillingCycleOnRenewal() { return contractTermBillingCycleOnRenewal; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -762,6 +774,8 @@ public Map toFormData() { "contract_term_billing_cycle_on_renewal", this.contractTermBillingCycleOnRenewal); } + formData.putAll(customFields); + return formData; } @@ -801,6 +815,8 @@ public static final class SubscriptionBuilder { private Integer contractTermBillingCycleOnRenewal; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder id(String value) { @@ -874,6 +890,42 @@ public SubscriptionBuilder contractTermBillingCycleOnRenewal(Integer value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } @@ -966,11 +1018,18 @@ public static final class CustomerParams { private final String vatNumberPrefix; + private final Map customFields; + private CustomerParams(CustomerBuilder builder) { this.vatNumber = builder.vatNumber; this.vatNumberPrefix = builder.vatNumberPrefix; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getVatNumber() { @@ -981,6 +1040,10 @@ public String getVatNumberPrefix() { return vatNumberPrefix; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -995,6 +1058,8 @@ public Map toFormData() { formData.put("vat_number_prefix", this.vatNumberPrefix); } + formData.putAll(customFields); + return formData; } @@ -1010,6 +1075,8 @@ public static final class CustomerBuilder { private String vatNumberPrefix; + private Map customFields = new LinkedHashMap<>(); + private CustomerBuilder() {} public CustomerBuilder vatNumber(String value) { @@ -1022,6 +1089,42 @@ public CustomerBuilder vatNumberPrefix(String value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public CustomerBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public CustomerBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public CustomerParams build() { return new CustomerParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutGiftParams.java b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutGiftParams.java index 3554a55a..a9c78b97 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutGiftParams.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutGiftParams.java @@ -8,6 +8,7 @@ import com.chargebee.v4.internal.Recommended; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -217,6 +218,8 @@ public static final class SubscriptionParams { private final String coupon; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.planId = builder.planId; @@ -226,6 +229,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.planQuantityInDecimal = builder.planQuantityInDecimal; this.coupon = builder.coupon; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getPlanId() { @@ -244,6 +252,10 @@ public String getCoupon() { return coupon; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -268,6 +280,8 @@ public Map toFormData() { formData.put("coupon", this.coupon); } + formData.putAll(customFields); + return formData; } @@ -287,6 +301,8 @@ public static final class SubscriptionBuilder { private String coupon; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder planId(String value) { @@ -310,6 +326,42 @@ public SubscriptionBuilder coupon(String value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutNewForItemsParams.java b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutNewForItemsParams.java index 9250eee1..7d2a19c9 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutNewForItemsParams.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutNewForItemsParams.java @@ -8,6 +8,7 @@ import com.chargebee.v4.internal.Recommended; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -612,6 +613,8 @@ public static final class SubscriptionParams { private final Integer contractTermBillingCycleOnRenewal; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.id = builder.id; @@ -633,6 +636,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.poNumber = builder.poNumber; this.contractTermBillingCycleOnRenewal = builder.contractTermBillingCycleOnRenewal; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -675,6 +683,10 @@ public Integer getContractTermBillingCycleOnRenewal() { return contractTermBillingCycleOnRenewal; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -730,6 +742,8 @@ public Map toFormData() { "contract_term_billing_cycle_on_renewal", this.contractTermBillingCycleOnRenewal); } + formData.putAll(customFields); + return formData; } @@ -761,6 +775,8 @@ public static final class SubscriptionBuilder { private Integer contractTermBillingCycleOnRenewal; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder id(String value) { @@ -814,6 +830,42 @@ public SubscriptionBuilder contractTermBillingCycleOnRenewal(Integer value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } @@ -930,6 +982,8 @@ public static final class CustomerParams { private final EinvoicingMethod einvoicingMethod; + private final Map customFields; + private CustomerParams(CustomerBuilder builder) { this.id = builder.id; @@ -959,6 +1013,11 @@ private CustomerParams(CustomerBuilder builder) { this.entityIdentifierStandard = builder.entityIdentifierStandard; this.einvoicingMethod = builder.einvoicingMethod; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -1017,6 +1076,10 @@ public EinvoicingMethod getEinvoicingMethod() { return einvoicingMethod; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -1091,6 +1154,8 @@ public Map toFormData() { formData.put("einvoicing_method", this.einvoicingMethod); } + formData.putAll(customFields); + return formData; } @@ -1130,6 +1195,8 @@ public static final class CustomerBuilder { private EinvoicingMethod einvoicingMethod; + private Map customFields = new LinkedHashMap<>(); + private CustomerBuilder() {} public CustomerBuilder id(String value) { @@ -1202,6 +1269,42 @@ public CustomerBuilder einvoicingMethod(EinvoicingMethod value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public CustomerBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public CustomerBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public CustomerParams build() { return new CustomerParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutNewParams.java b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutNewParams.java index 7ed14a0b..1ad3e831 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutNewParams.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutNewParams.java @@ -8,6 +8,7 @@ import com.chargebee.v4.internal.Recommended; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -532,6 +533,8 @@ public static final class SubscriptionParams { private final Integer contractTermBillingCycleOnRenewal; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.id = builder.id; @@ -563,6 +566,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.affiliateToken = builder.affiliateToken; this.contractTermBillingCycleOnRenewal = builder.contractTermBillingCycleOnRenewal; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -625,6 +633,10 @@ public Integer getContractTermBillingCycleOnRenewal() { return contractTermBillingCycleOnRenewal; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -705,6 +717,8 @@ public Map toFormData() { "contract_term_billing_cycle_on_renewal", this.contractTermBillingCycleOnRenewal); } + formData.putAll(customFields); + return formData; } @@ -746,6 +760,8 @@ public static final class SubscriptionBuilder { private Integer contractTermBillingCycleOnRenewal; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder id(String value) { @@ -824,6 +840,42 @@ public SubscriptionBuilder contractTermBillingCycleOnRenewal(Integer value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } @@ -934,6 +986,8 @@ public static final class CustomerParams { private final Boolean consolidatedInvoicing; + private final Map customFields; + private CustomerParams(CustomerBuilder builder) { this.id = builder.id; @@ -957,6 +1011,11 @@ private CustomerParams(CustomerBuilder builder) { this.vatNumberPrefix = builder.vatNumberPrefix; this.consolidatedInvoicing = builder.consolidatedInvoicing; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -1003,6 +1062,10 @@ public Boolean getConsolidatedInvoicing() { return consolidatedInvoicing; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -1062,6 +1125,8 @@ public Map toFormData() { formData.put("consolidated_invoicing", this.consolidatedInvoicing); } + formData.putAll(customFields); + return formData; } @@ -1095,6 +1160,8 @@ public static final class CustomerBuilder { private Boolean consolidatedInvoicing; + private Map customFields = new LinkedHashMap<>(); + private CustomerBuilder() {} public CustomerBuilder id(String value) { @@ -1152,6 +1219,42 @@ public CustomerBuilder consolidatedInvoicing(Boolean value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public CustomerBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public CustomerBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public CustomerParams build() { return new CustomerParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutOneTimeForItemsParams.java b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutOneTimeForItemsParams.java index fe08f184..2031155b 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutOneTimeForItemsParams.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutOneTimeForItemsParams.java @@ -8,6 +8,7 @@ import com.chargebee.v4.internal.Recommended; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -558,6 +559,8 @@ public static final class CustomerParams { private final Boolean consolidatedInvoicing; + private final Map customFields; + private CustomerParams(CustomerBuilder builder) { this.id = builder.id; @@ -589,6 +592,11 @@ private CustomerParams(CustomerBuilder builder) { this.entityIdentifierStandard = builder.entityIdentifierStandard; this.consolidatedInvoicing = builder.consolidatedInvoicing; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -651,6 +659,10 @@ public Boolean getConsolidatedInvoicing() { return consolidatedInvoicing; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -730,6 +742,8 @@ public Map toFormData() { formData.put("consolidated_invoicing", this.consolidatedInvoicing); } + formData.putAll(customFields); + return formData; } @@ -771,6 +785,8 @@ public static final class CustomerBuilder { private Boolean consolidatedInvoicing; + private Map customFields = new LinkedHashMap<>(); + private CustomerBuilder() {} public CustomerBuilder id(String value) { @@ -848,6 +864,42 @@ public CustomerBuilder consolidatedInvoicing(Boolean value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public CustomerBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public CustomerBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public CustomerParams build() { return new CustomerParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutOneTimeParams.java b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutOneTimeParams.java index a8493b2e..761ba08e 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutOneTimeParams.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/params/HostedPageCheckoutOneTimeParams.java @@ -8,6 +8,7 @@ import com.chargebee.v4.internal.Recommended; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -430,6 +431,8 @@ public static final class CustomerParams { private final Boolean consolidatedInvoicing; + private final Map customFields; + private CustomerParams(CustomerBuilder builder) { this.id = builder.id; @@ -453,6 +456,11 @@ private CustomerParams(CustomerBuilder builder) { this.vatNumberPrefix = builder.vatNumberPrefix; this.consolidatedInvoicing = builder.consolidatedInvoicing; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -499,6 +507,10 @@ public Boolean getConsolidatedInvoicing() { return consolidatedInvoicing; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -558,6 +570,8 @@ public Map toFormData() { formData.put("consolidated_invoicing", this.consolidatedInvoicing); } + formData.putAll(customFields); + return formData; } @@ -591,6 +605,8 @@ public static final class CustomerBuilder { private Boolean consolidatedInvoicing; + private Map customFields = new LinkedHashMap<>(); + private CustomerBuilder() {} public CustomerBuilder id(String value) { @@ -648,6 +664,42 @@ public CustomerBuilder consolidatedInvoicing(Boolean value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public CustomerBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public CustomerBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public CustomerParams build() { return new CustomerParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/itemFamily/params/ItemFamilyListParams.java b/src/main/java/com/chargebee/v4/models/itemFamily/params/ItemFamilyListParams.java index b6bf7124..d33c6dd4 100644 --- a/src/main/java/com/chargebee/v4/models/itemFamily/params/ItemFamilyListParams.java +++ b/src/main/java/com/chargebee/v4/models/itemFamily/params/ItemFamilyListParams.java @@ -10,7 +10,6 @@ import com.chargebee.v4.internal.Recommended; import com.chargebee.v4.filters.StringFilter; import com.chargebee.v4.filters.TimestampFilter; - import com.chargebee.v4.filters.CustomFieldSelector; import java.util.Collections; diff --git a/src/main/java/com/chargebee/v4/models/plan/params/PlanListParams.java b/src/main/java/com/chargebee/v4/models/plan/params/PlanListParams.java index f626fba8..1e7611f4 100644 --- a/src/main/java/com/chargebee/v4/models/plan/params/PlanListParams.java +++ b/src/main/java/com/chargebee/v4/models/plan/params/PlanListParams.java @@ -11,7 +11,6 @@ import com.chargebee.v4.filters.StringFilter; import com.chargebee.v4.filters.NumberFilter; import com.chargebee.v4.filters.TimestampFilter; - import com.chargebee.v4.filters.CustomFieldSelector; import java.util.Collections; diff --git a/src/main/java/com/chargebee/v4/models/pricingPageSession/params/PricingPageSessionCreateForExistingSubscriptionParams.java b/src/main/java/com/chargebee/v4/models/pricingPageSession/params/PricingPageSessionCreateForExistingSubscriptionParams.java index bc1577dd..ec754b0c 100644 --- a/src/main/java/com/chargebee/v4/models/pricingPageSession/params/PricingPageSessionCreateForExistingSubscriptionParams.java +++ b/src/main/java/com/chargebee/v4/models/pricingPageSession/params/PricingPageSessionCreateForExistingSubscriptionParams.java @@ -9,6 +9,7 @@ import com.chargebee.v4.internal.Recommended; import com.chargebee.v4.internal.JsonUtil; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -217,15 +218,26 @@ public static final class SubscriptionParams { private final String id; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.id = builder.id; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { return id; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -235,6 +247,8 @@ public Map toFormData() { formData.put("id", this.id); } + formData.putAll(customFields); + return formData; } @@ -248,6 +262,8 @@ public static final class SubscriptionBuilder { private String id; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder id(String value) { @@ -255,6 +271,42 @@ public SubscriptionBuilder id(String value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/pricingPageSession/params/PricingPageSessionCreateForNewSubscriptionParams.java b/src/main/java/com/chargebee/v4/models/pricingPageSession/params/PricingPageSessionCreateForNewSubscriptionParams.java index 53dbdef2..6dd3849b 100644 --- a/src/main/java/com/chargebee/v4/models/pricingPageSession/params/PricingPageSessionCreateForNewSubscriptionParams.java +++ b/src/main/java/com/chargebee/v4/models/pricingPageSession/params/PricingPageSessionCreateForNewSubscriptionParams.java @@ -9,6 +9,7 @@ import com.chargebee.v4.internal.Recommended; import com.chargebee.v4.internal.JsonUtil; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -334,15 +335,26 @@ public static final class SubscriptionParams { private final String id; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.id = builder.id; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { return id; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -352,6 +364,8 @@ public Map toFormData() { formData.put("id", this.id); } + formData.putAll(customFields); + return formData; } @@ -365,6 +379,8 @@ public static final class SubscriptionBuilder { private String id; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder id(String value) { @@ -372,6 +388,42 @@ public SubscriptionBuilder id(String value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } @@ -394,6 +446,8 @@ public static final class CustomerParams { private final String locale; + private final Map customFields; + private CustomerParams(CustomerBuilder builder) { this.id = builder.id; @@ -409,6 +463,11 @@ private CustomerParams(CustomerBuilder builder) { this.phone = builder.phone; this.locale = builder.locale; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -439,6 +498,10 @@ public String getLocale() { return locale; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -478,6 +541,8 @@ public Map toFormData() { formData.put("locale", this.locale); } + formData.putAll(customFields); + return formData; } @@ -503,6 +568,8 @@ public static final class CustomerBuilder { private String locale; + private Map customFields = new LinkedHashMap<>(); + private CustomerBuilder() {} public CustomerBuilder id(String value) { @@ -540,6 +607,42 @@ public CustomerBuilder locale(String value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public CustomerBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public CustomerBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public CustomerParams build() { return new CustomerParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/quote/params/CreateSubscriptionItemsForCustomerQuoteParams.java b/src/main/java/com/chargebee/v4/models/quote/params/CreateSubscriptionItemsForCustomerQuoteParams.java index 1a0aaf41..660c3739 100644 --- a/src/main/java/com/chargebee/v4/models/quote/params/CreateSubscriptionItemsForCustomerQuoteParams.java +++ b/src/main/java/com/chargebee/v4/models/quote/params/CreateSubscriptionItemsForCustomerQuoteParams.java @@ -595,6 +595,8 @@ public static final class SubscriptionParams { private final Integer contractTermBillingCycleOnRenewal; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.id = builder.id; @@ -610,6 +612,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.offlinePaymentMethod = builder.offlinePaymentMethod; this.contractTermBillingCycleOnRenewal = builder.contractTermBillingCycleOnRenewal; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -640,6 +647,10 @@ public Integer getContractTermBillingCycleOnRenewal() { return contractTermBillingCycleOnRenewal; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -680,6 +691,8 @@ public Map toFormData() { "contract_term_billing_cycle_on_renewal", this.contractTermBillingCycleOnRenewal); } + formData.putAll(customFields); + return formData; } @@ -705,6 +718,8 @@ public static final class SubscriptionBuilder { private Integer contractTermBillingCycleOnRenewal; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder id(String value) { @@ -743,6 +758,42 @@ public SubscriptionBuilder contractTermBillingCycleOnRenewal(Integer value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/quote/params/EditCreateSubscriptionCustomerQuoteForItemsParams.java b/src/main/java/com/chargebee/v4/models/quote/params/EditCreateSubscriptionCustomerQuoteForItemsParams.java index 6b7dacdb..e119b0fa 100644 --- a/src/main/java/com/chargebee/v4/models/quote/params/EditCreateSubscriptionCustomerQuoteForItemsParams.java +++ b/src/main/java/com/chargebee/v4/models/quote/params/EditCreateSubscriptionCustomerQuoteForItemsParams.java @@ -579,6 +579,8 @@ public static final class SubscriptionParams { private final Integer contractTermBillingCycleOnRenewal; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.id = builder.id; @@ -594,6 +596,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.offlinePaymentMethod = builder.offlinePaymentMethod; this.contractTermBillingCycleOnRenewal = builder.contractTermBillingCycleOnRenewal; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -624,6 +631,10 @@ public Integer getContractTermBillingCycleOnRenewal() { return contractTermBillingCycleOnRenewal; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -664,6 +675,8 @@ public Map toFormData() { "contract_term_billing_cycle_on_renewal", this.contractTermBillingCycleOnRenewal); } + formData.putAll(customFields); + return formData; } @@ -689,6 +702,8 @@ public static final class SubscriptionBuilder { private Integer contractTermBillingCycleOnRenewal; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder id(String value) { @@ -727,6 +742,42 @@ public SubscriptionBuilder contractTermBillingCycleOnRenewal(Integer value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/quote/params/EditUpdateSubscriptionQuoteForItemsParams.java b/src/main/java/com/chargebee/v4/models/quote/params/EditUpdateSubscriptionQuoteForItemsParams.java index aba9fee2..b88f4f4a 100644 --- a/src/main/java/com/chargebee/v4/models/quote/params/EditUpdateSubscriptionQuoteForItemsParams.java +++ b/src/main/java/com/chargebee/v4/models/quote/params/EditUpdateSubscriptionQuoteForItemsParams.java @@ -715,6 +715,8 @@ public static final class SubscriptionParams { private final Integer contractTermBillingCycleOnRenewal; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.setupFee = builder.setupFee; @@ -730,6 +732,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.offlinePaymentMethod = builder.offlinePaymentMethod; this.contractTermBillingCycleOnRenewal = builder.contractTermBillingCycleOnRenewal; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public Long getSetupFee() { @@ -760,6 +767,10 @@ public Integer getContractTermBillingCycleOnRenewal() { return contractTermBillingCycleOnRenewal; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -800,6 +811,8 @@ public Map toFormData() { "contract_term_billing_cycle_on_renewal", this.contractTermBillingCycleOnRenewal); } + formData.putAll(customFields); + return formData; } @@ -825,6 +838,8 @@ public static final class SubscriptionBuilder { private Integer contractTermBillingCycleOnRenewal; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} @Deprecated @@ -864,6 +879,42 @@ public SubscriptionBuilder contractTermBillingCycleOnRenewal(Integer value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/quote/params/QuoteListParams.java b/src/main/java/com/chargebee/v4/models/quote/params/QuoteListParams.java index 7b1de744..f000901b 100644 --- a/src/main/java/com/chargebee/v4/models/quote/params/QuoteListParams.java +++ b/src/main/java/com/chargebee/v4/models/quote/params/QuoteListParams.java @@ -10,7 +10,6 @@ import com.chargebee.v4.internal.Recommended; import com.chargebee.v4.filters.StringFilter; import com.chargebee.v4.filters.TimestampFilter; - import com.chargebee.v4.filters.CustomFieldSelector; import java.util.Collections; diff --git a/src/main/java/com/chargebee/v4/models/quote/params/UpdateSubscriptionQuoteForItemsParams.java b/src/main/java/com/chargebee/v4/models/quote/params/UpdateSubscriptionQuoteForItemsParams.java index 735c80d0..f71a538a 100644 --- a/src/main/java/com/chargebee/v4/models/quote/params/UpdateSubscriptionQuoteForItemsParams.java +++ b/src/main/java/com/chargebee/v4/models/quote/params/UpdateSubscriptionQuoteForItemsParams.java @@ -734,6 +734,8 @@ public static final class SubscriptionParams { private final Integer contractTermBillingCycleOnRenewal; + private final Map customFields; + private SubscriptionParams(SubscriptionBuilder builder) { this.id = builder.id; @@ -751,6 +753,11 @@ private SubscriptionParams(SubscriptionBuilder builder) { this.offlinePaymentMethod = builder.offlinePaymentMethod; this.contractTermBillingCycleOnRenewal = builder.contractTermBillingCycleOnRenewal; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -785,6 +792,10 @@ public Integer getContractTermBillingCycleOnRenewal() { return contractTermBillingCycleOnRenewal; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -830,6 +841,8 @@ public Map toFormData() { "contract_term_billing_cycle_on_renewal", this.contractTermBillingCycleOnRenewal); } + formData.putAll(customFields); + return formData; } @@ -857,6 +870,8 @@ public static final class SubscriptionBuilder { private Integer contractTermBillingCycleOnRenewal; + private Map customFields = new LinkedHashMap<>(); + private SubscriptionBuilder() {} public SubscriptionBuilder id(String value) { @@ -901,6 +916,42 @@ public SubscriptionBuilder contractTermBillingCycleOnRenewal(Integer value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public SubscriptionBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public SubscriptionBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public SubscriptionParams build() { return new SubscriptionParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/subscription/params/ImportSubscriptionParams.java b/src/main/java/com/chargebee/v4/models/subscription/params/ImportSubscriptionParams.java index 2f8fb71f..3a975b4c 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/params/ImportSubscriptionParams.java +++ b/src/main/java/com/chargebee/v4/models/subscription/params/ImportSubscriptionParams.java @@ -1053,6 +1053,8 @@ public static final class CustomerParams { private final String vatNumberPrefix; + private final Map customFields; + private CustomerParams(CustomerBuilder builder) { this.id = builder.id; @@ -1088,6 +1090,11 @@ private CustomerParams(CustomerBuilder builder) { this.vatNumber = builder.vatNumber; this.vatNumberPrefix = builder.vatNumberPrefix; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -1158,6 +1165,10 @@ public String getVatNumberPrefix() { return vatNumberPrefix; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -1247,6 +1258,8 @@ public Map toFormData() { formData.put("vat_number_prefix", this.vatNumberPrefix); } + formData.putAll(customFields); + return formData; } @@ -1292,6 +1305,8 @@ public static final class CustomerBuilder { private String vatNumberPrefix; + private Map customFields = new LinkedHashMap<>(); + private CustomerBuilder() {} public CustomerBuilder id(String value) { @@ -1379,6 +1394,42 @@ public CustomerBuilder vatNumberPrefix(String value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public CustomerBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public CustomerBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public CustomerParams build() { return new CustomerParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/subscription/params/SubscriptionCreateParams.java b/src/main/java/com/chargebee/v4/models/subscription/params/SubscriptionCreateParams.java index 84ca8fbb..a04a0c52 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/params/SubscriptionCreateParams.java +++ b/src/main/java/com/chargebee/v4/models/subscription/params/SubscriptionCreateParams.java @@ -1348,6 +1348,8 @@ public static final class CustomerParams { private final CustomerType customerType; + private final Map customFields; + private CustomerParams(CustomerBuilder builder) { this.id = builder.id; @@ -1401,6 +1403,11 @@ private CustomerParams(CustomerBuilder builder) { this.exemptionDetails = builder.exemptionDetails; this.customerType = builder.customerType; + + this.customFields = + builder.customFields.isEmpty() + ? Collections.emptyMap() + : Collections.unmodifiableMap(new LinkedHashMap<>(builder.customFields)); } public String getId() { @@ -1507,6 +1514,10 @@ public CustomerType getCustomerType() { return customerType; } + public Map customFields() { + return customFields; + } + /** Get the form data for this request. */ public Map toFormData() { Map formData = new LinkedHashMap<>(); @@ -1641,6 +1652,8 @@ public Map toFormData() { formData.put("customer_type", this.customerType); } + formData.putAll(customFields); + return formData; } @@ -1704,6 +1717,8 @@ public static final class CustomerBuilder { private CustomerType customerType; + private Map customFields = new LinkedHashMap<>(); + private CustomerBuilder() {} public CustomerBuilder id(String value) { @@ -1836,6 +1851,42 @@ public CustomerBuilder customerType(CustomerType value) { return this; } + /** + * Add a custom field to the request. Custom fields must start with "cf_". + * + * @param fieldName the name of the custom field (e.g., "cf_custom_field_name") + * @param value the value of the custom field + * @return this builder + * @throws IllegalArgumentException if fieldName doesn't start with "cf_" + */ + public CustomerBuilder customField(String fieldName, String value) { + if (fieldName == null || !fieldName.startsWith("cf_")) { + throw new IllegalArgumentException("Custom field name must start with 'cf_'"); + } + this.customFields.put(fieldName, value); + return this; + } + + /** + * Add multiple custom fields to the request. All field names must start with "cf_". + * + * @param customFields map of custom field names to values + * @return this builder + * @throws IllegalArgumentException if any field name doesn't start with "cf_" + */ + public CustomerBuilder customFields(Map customFields) { + if (customFields != null) { + for (Map.Entry entry : customFields.entrySet()) { + if (entry.getKey() == null || !entry.getKey().startsWith("cf_")) { + throw new IllegalArgumentException( + "Custom field name must start with 'cf_': " + entry.getKey()); + } + this.customFields.put(entry.getKey(), entry.getValue()); + } + } + return this; + } + public CustomerParams build() { return new CustomerParams(this); } diff --git a/src/main/java/com/chargebee/v4/models/subscription/params/SubscriptionListParams.java b/src/main/java/com/chargebee/v4/models/subscription/params/SubscriptionListParams.java index 06511e02..6c54a55a 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/params/SubscriptionListParams.java +++ b/src/main/java/com/chargebee/v4/models/subscription/params/SubscriptionListParams.java @@ -11,7 +11,6 @@ import com.chargebee.v4.filters.StringFilter; import com.chargebee.v4.filters.NumberFilter; import com.chargebee.v4.filters.TimestampFilter; - import com.chargebee.v4.filters.CustomFieldSelector; import java.util.Collections;