diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e4da7e..342a8c13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,40 @@ +### v4.10.0 (2026-06-12) +* * * +### New Resources: +- [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks) has been added. +- [`LedgerAccountBalance`](https://apidocs.chargebee.com/docs/api/ledger_account_balances) has been added. +- [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations) has been added. +- [`PromotionalGrant`](https://apidocs.chargebee.com/docs/api/promotional_grants) has been added. + + +### New Attributes: +- [`notes`](https://apidocs.chargebee.com/docs/api/credit_notes/credit-note-object#notes) has been added to [`CreditNote`](https://apidocs.chargebee.com/docs/api/credit_notes). +- [`layout`](https://apidocs.chargebee.com/docs/api/hosted_pages/hosted-page-object#layout) has been added to [`HostedPage`](https://apidocs.chargebee.com/docs/api/hosted_pages). + + +### New Parameters: +- [`sort_by`](https://apidocs.chargebee.com/docs/api/omnichannel_subscriptions/list-omnichannel-subscriptions#sort_by) has been added as query parameter to [`list_omnichannel_subscriptions`](https://apidocs.chargebee.com/docs/api/omnichannel_subscriptions/list-omnichannel-subscriptions) in [`OmnichannelSubscription`](https://apidocs.chargebee.com/docs/api/omnichannel_subscriptions). + + +### New Enums: +- `available`, `exhausted`, `scheduled`, and `in_grace_period` have been added as new values enum `Status`. +- `subscription_created`, `subscription_changed`, `top_up`, `promotional_grants`, and `rollover` have been added as new values to enum attribute [`grant_source`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#grant_source) in [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- `provisioned` and `overdraft` have been added as new values to enum attribute [`account_type`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#account_type) in [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- `credit_unit` has been added as a new value to enum attribute [`unit_type`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#unit_type) in [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- `credit_unit` has been added as a new value to enum attribute [`unit_type`](https://apidocs.chargebee.com/docs/api/ledger_account_balances/ledger-account-balance-object#unit_type) in [`LedgerAccountBalance`](https://apidocs.chargebee.com/docs/api/ledger_account_balances). +- `allocation`, `capture`, `authorize`, `release_authorization`, `capture_authorization`, `expiry`, `void`, `rollover`, and `adjustment` have been added as new values to enum attribute [`type`](https://apidocs.chargebee.com/docs/api/ledger_operations/ledger-operation-object#type) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- `credit_unit` has been added as a new value to enum attribute [`unit_type`](https://apidocs.chargebee.com/docs/api/ledger_operations/ledger-operation-object#unit_type) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- `expires_at`, `created_at`, and `effective_from` have been added as new values to enum query parameter `sort_by.asc` in [`list_grant_blocks`](https://apidocs.chargebee.com/docs/api/grant_blocks/list-grant-blocks) of [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- `expires_at`, `created_at`, and `effective_from` have been added as new values to enum query parameter `sort_by.desc` in [`list_grant_blocks`](https://apidocs.chargebee.com/docs/api/grant_blocks/list-grant-blocks) of [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks). +- `allocation`, `release_authorization`, `void`, `capture`, `rollover`, `adjustment`, `expiry`, `authorize`, and `capture_authorization` have been added as new values to enum query parameter `type.is` in [`list_ledger_operations`](https://apidocs.chargebee.com/docs/api/ledger_operations/list-ledger-operations) of [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- `allocation`, `release_authorization`, `void`, `capture`, `rollover`, `adjustment`, `expiry`, `authorize`, and `capture_authorization` have been added as new values to enum query parameter `type.in` in [`list_ledger_operations`](https://apidocs.chargebee.com/docs/api/ledger_operations/list-ledger-operations) of [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- `created_at` has been added as a new value to enum query parameter `sort_by.asc` in [`list_ledger_operations`](https://apidocs.chargebee.com/docs/api/ledger_operations/list-ledger-operations) of [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- `created_at` has been added as a new value to enum query parameter `sort_by.desc` in [`list_ledger_operations`](https://apidocs.chargebee.com/docs/api/ledger_operations/list-ledger-operations) of [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations). +- `updated_at` and `created_at` have been added as new values to enum query parameter `sort_by.asc` in [`list_omnichannel_subscriptions`](https://apidocs.chargebee.com/docs/api/omnichannel_subscriptions/list-omnichannel-subscriptions) of [`OmnichannelSubscription`](https://apidocs.chargebee.com/docs/api/omnichannel_subscriptions). +- `updated_at` and `created_at` have been added as new values to enum query parameter `sort_by.desc` in [`list_omnichannel_subscriptions`](https://apidocs.chargebee.com/docs/api/omnichannel_subscriptions/list-omnichannel-subscriptions) of [`OmnichannelSubscription`](https://apidocs.chargebee.com/docs/api/omnichannel_subscriptions). + + + ### v4.9.0 (2026-06-08) * * * ### New Attributes: diff --git a/VERSION b/VERSION index 6ed7776b..2da43162 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.9.0 +4.10.0 diff --git a/build.gradle.kts b/build.gradle.kts index e939096b..82e550bd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "com.chargebee" -version = "4.9.0" +version = "4.10.0" description = "Java client library for ChargeBee" // Project metadata diff --git a/src/main/java/com/chargebee/v4/client/ClientMethods.java b/src/main/java/com/chargebee/v4/client/ClientMethods.java index 696019a5..5d09536d 100644 --- a/src/main/java/com/chargebee/v4/client/ClientMethods.java +++ b/src/main/java/com/chargebee/v4/client/ClientMethods.java @@ -12,6 +12,8 @@ import com.chargebee.v4.services.OfferEventService; +import com.chargebee.v4.services.PromotionalGrantService; + import com.chargebee.v4.services.InAppSubscriptionService; import com.chargebee.v4.services.Pc2MigrationService; @@ -20,6 +22,8 @@ import com.chargebee.v4.services.CouponSetService; +import com.chargebee.v4.services.LedgerAccountBalanceService; + import com.chargebee.v4.services.QuoteService; import com.chargebee.v4.services.Pc2MigrationItemService; @@ -60,6 +64,8 @@ import com.chargebee.v4.services.AdditionalBillingLogiqService; +import com.chargebee.v4.services.LedgerOperationService; + import com.chargebee.v4.services.UsageSummaryService; import com.chargebee.v4.services.AlertStatusService; @@ -84,6 +90,8 @@ import com.chargebee.v4.services.VirtualBankAccountService; +import com.chargebee.v4.services.GrantBlockService; + import com.chargebee.v4.services.AddonService; import com.chargebee.v4.services.TpSiteUserService; @@ -218,6 +226,13 @@ public interface ClientMethods { */ OfferEventService offerEvents(); + /** + * Access promotional_grant-related operations. + * + * @return PromotionalGrantService instance for fluent API access + */ + PromotionalGrantService promotionalGrants(); + /** * Access in_app_subscription-related operations. * @@ -246,6 +261,13 @@ public interface ClientMethods { */ CouponSetService couponSets(); + /** + * Access ledger_account_balance-related operations. + * + * @return LedgerAccountBalanceService instance for fluent API access + */ + LedgerAccountBalanceService ledgerAccountBalances(); + /** * Access quote-related operations. * @@ -386,6 +408,13 @@ public interface ClientMethods { */ AdditionalBillingLogiqService additionalBillingLogiqs(); + /** + * Access ledger_operation-related operations. + * + * @return LedgerOperationService instance for fluent API access + */ + LedgerOperationService ledgerOperations(); + /** * Access usage_summary-related operations. * @@ -470,6 +499,13 @@ public interface ClientMethods { */ VirtualBankAccountService virtualBankAccounts(); + /** + * Access grant_block-related operations. + * + * @return GrantBlockService instance for fluent API access + */ + GrantBlockService grantBlocks(); + /** * Access addon-related operations. * diff --git a/src/main/java/com/chargebee/v4/client/ClientMethodsImpl.java b/src/main/java/com/chargebee/v4/client/ClientMethodsImpl.java index 8f396b46..dc36f738 100644 --- a/src/main/java/com/chargebee/v4/client/ClientMethodsImpl.java +++ b/src/main/java/com/chargebee/v4/client/ClientMethodsImpl.java @@ -12,6 +12,8 @@ import com.chargebee.v4.services.OfferEventService; +import com.chargebee.v4.services.PromotionalGrantService; + import com.chargebee.v4.services.InAppSubscriptionService; import com.chargebee.v4.services.Pc2MigrationService; @@ -20,6 +22,8 @@ import com.chargebee.v4.services.CouponSetService; +import com.chargebee.v4.services.LedgerAccountBalanceService; + import com.chargebee.v4.services.QuoteService; import com.chargebee.v4.services.Pc2MigrationItemService; @@ -60,6 +64,8 @@ import com.chargebee.v4.services.AdditionalBillingLogiqService; +import com.chargebee.v4.services.LedgerOperationService; + import com.chargebee.v4.services.UsageSummaryService; import com.chargebee.v4.services.AlertStatusService; @@ -84,6 +90,8 @@ import com.chargebee.v4.services.VirtualBankAccountService; +import com.chargebee.v4.services.GrantBlockService; + import com.chargebee.v4.services.AddonService; import com.chargebee.v4.services.TpSiteUserService; @@ -208,6 +216,11 @@ public OfferEventService offerEvents() { return getServiceRegistry().offerEvents(); } + @Override + public PromotionalGrantService promotionalGrants() { + return getServiceRegistry().promotionalGrants(); + } + @Override public InAppSubscriptionService inAppSubscriptions() { return getServiceRegistry().inAppSubscriptions(); @@ -228,6 +241,11 @@ public CouponSetService couponSets() { return getServiceRegistry().couponSets(); } + @Override + public LedgerAccountBalanceService ledgerAccountBalances() { + return getServiceRegistry().ledgerAccountBalances(); + } + @Override public QuoteService quotes() { return getServiceRegistry().quotes(); @@ -328,6 +346,11 @@ public AdditionalBillingLogiqService additionalBillingLogiqs() { return getServiceRegistry().additionalBillingLogiqs(); } + @Override + public LedgerOperationService ledgerOperations() { + return getServiceRegistry().ledgerOperations(); + } + @Override public UsageSummaryService usageSummaries() { return getServiceRegistry().usageSummaries(); @@ -388,6 +411,11 @@ public VirtualBankAccountService virtualBankAccounts() { return getServiceRegistry().virtualBankAccounts(); } + @Override + public GrantBlockService grantBlocks() { + return getServiceRegistry().grantBlocks(); + } + @Override public AddonService addons() { return getServiceRegistry().addons(); diff --git a/src/main/java/com/chargebee/v4/client/ServiceRegistry.java b/src/main/java/com/chargebee/v4/client/ServiceRegistry.java index cba64f85..e01eb214 100644 --- a/src/main/java/com/chargebee/v4/client/ServiceRegistry.java +++ b/src/main/java/com/chargebee/v4/client/ServiceRegistry.java @@ -12,6 +12,8 @@ import com.chargebee.v4.services.OfferEventService; +import com.chargebee.v4.services.PromotionalGrantService; + import com.chargebee.v4.services.InAppSubscriptionService; import com.chargebee.v4.services.Pc2MigrationService; @@ -20,6 +22,8 @@ import com.chargebee.v4.services.CouponSetService; +import com.chargebee.v4.services.LedgerAccountBalanceService; + import com.chargebee.v4.services.QuoteService; import com.chargebee.v4.services.Pc2MigrationItemService; @@ -60,6 +64,8 @@ import com.chargebee.v4.services.AdditionalBillingLogiqService; +import com.chargebee.v4.services.LedgerOperationService; + import com.chargebee.v4.services.UsageSummaryService; import com.chargebee.v4.services.AlertStatusService; @@ -84,6 +90,8 @@ import com.chargebee.v4.services.VirtualBankAccountService; +import com.chargebee.v4.services.GrantBlockService; + import com.chargebee.v4.services.AddonService; import com.chargebee.v4.services.TpSiteUserService; @@ -189,6 +197,8 @@ final class ServiceRegistry { private volatile OfferEventService offerEventService; + private volatile PromotionalGrantService promotionalGrantService; + private volatile InAppSubscriptionService inAppSubscriptionService; private volatile Pc2MigrationService pc2MigrationService; @@ -197,6 +207,8 @@ final class ServiceRegistry { private volatile CouponSetService couponSetService; + private volatile LedgerAccountBalanceService ledgerAccountBalanceService; + private volatile QuoteService quoteService; private volatile Pc2MigrationItemService pc2MigrationItemService; @@ -237,6 +249,8 @@ final class ServiceRegistry { private volatile AdditionalBillingLogiqService additionalBillingLogiqService; + private volatile LedgerOperationService ledgerOperationService; + private volatile UsageSummaryService usageSummaryService; private volatile AlertStatusService alertStatusService; @@ -261,6 +275,8 @@ final class ServiceRegistry { private volatile VirtualBankAccountService virtualBankAccountService; + private volatile GrantBlockService grantBlockService; + private volatile AddonService addonService; private volatile TpSiteUserService tpSiteUserService; @@ -441,6 +457,21 @@ OfferEventService offerEvents() { return offerEventService; } + /** + * Get or create the PromotionalGrantService instance. Thread-safe lazy initialization using + * double-checked locking. + */ + PromotionalGrantService promotionalGrants() { + if (promotionalGrantService == null) { + synchronized (this) { + if (promotionalGrantService == null) { + promotionalGrantService = new PromotionalGrantService(client); + } + } + } + return promotionalGrantService; + } + /** * Get or create the InAppSubscriptionService instance. Thread-safe lazy initialization using * double-checked locking. @@ -501,6 +532,21 @@ CouponSetService couponSets() { return couponSetService; } + /** + * Get or create the LedgerAccountBalanceService instance. Thread-safe lazy initialization using + * double-checked locking. + */ + LedgerAccountBalanceService ledgerAccountBalances() { + if (ledgerAccountBalanceService == null) { + synchronized (this) { + if (ledgerAccountBalanceService == null) { + ledgerAccountBalanceService = new LedgerAccountBalanceService(client); + } + } + } + return ledgerAccountBalanceService; + } + /** * Get or create the QuoteService instance. Thread-safe lazy initialization using double-checked * locking. @@ -801,6 +847,21 @@ AdditionalBillingLogiqService additionalBillingLogiqs() { return additionalBillingLogiqService; } + /** + * Get or create the LedgerOperationService instance. Thread-safe lazy initialization using + * double-checked locking. + */ + LedgerOperationService ledgerOperations() { + if (ledgerOperationService == null) { + synchronized (this) { + if (ledgerOperationService == null) { + ledgerOperationService = new LedgerOperationService(client); + } + } + } + return ledgerOperationService; + } + /** * Get or create the UsageSummaryService instance. Thread-safe lazy initialization using * double-checked locking. @@ -981,6 +1042,21 @@ VirtualBankAccountService virtualBankAccounts() { return virtualBankAccountService; } + /** + * Get or create the GrantBlockService instance. Thread-safe lazy initialization using + * double-checked locking. + */ + GrantBlockService grantBlocks() { + if (grantBlockService == null) { + synchronized (this) { + if (grantBlockService == null) { + grantBlockService = new GrantBlockService(client); + } + } + } + return grantBlockService; + } + /** * Get or create the AddonService instance. Thread-safe lazy initialization using double-checked * locking. diff --git a/src/main/java/com/chargebee/v4/models/creditNote/CreditNote.java b/src/main/java/com/chargebee/v4/models/creditNote/CreditNote.java index a9b42f27..e0883c15 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/CreditNote.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/CreditNote.java @@ -44,6 +44,7 @@ public class CreditNote { private String localCurrencyCode; private Long roundOffAmount; private Long fractionalCorrection; + private List notes; private Boolean deleted; private String taxCategory; private BigDecimal localCurrencyExchangeRate; @@ -179,6 +180,10 @@ public Long getFractionalCorrection() { return fractionalCorrection; } + public List getNotes() { + return notes; + } + public Boolean getDeleted() { return deleted; } @@ -516,6 +521,8 @@ public static CreditNote fromJson(JsonObject jsonObj) { knownFields.add("fractional_correction"); + knownFields.add("notes"); + knownFields.add("deleted"); knownFields.add("tax_category"); @@ -612,6 +619,11 @@ public static CreditNote fromJson(JsonObject jsonObj) { obj.fractionalCorrection = JsonUtil.getLong(jsonObj, "fractional_correction"); + JsonArray __notesArr = JsonUtil.getJsonArray(jsonObj, "notes"); + if (__notesArr != null) { + obj.notes = JsonUtil.parseArrayOfString(__notesArr); + } + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); obj.taxCategory = JsonUtil.getString(jsonObj, "tax_category"); @@ -745,6 +757,8 @@ public String toString() { + roundOffAmount + ", fractionalCorrection=" + fractionalCorrection + + ", notes=" + + notes + ", deleted=" + deleted + ", taxCategory=" @@ -824,6 +838,7 @@ public boolean equals(Object o) { && java.util.Objects.equals(localCurrencyCode, that.localCurrencyCode) && java.util.Objects.equals(roundOffAmount, that.roundOffAmount) && java.util.Objects.equals(fractionalCorrection, that.fractionalCorrection) + && java.util.Objects.equals(notes, that.notes) && java.util.Objects.equals(deleted, that.deleted) && java.util.Objects.equals(taxCategory, that.taxCategory) && java.util.Objects.equals(localCurrencyExchangeRate, that.localCurrencyExchangeRate) @@ -879,6 +894,7 @@ public int hashCode() { localCurrencyCode, roundOffAmount, fractionalCorrection, + notes, deleted, taxCategory, localCurrencyExchangeRate, diff --git a/src/main/java/com/chargebee/v4/models/entitlement/params/EntitlementListParams.java b/src/main/java/com/chargebee/v4/models/entitlement/params/EntitlementListParams.java index 22469fb1..b10179b6 100644 --- a/src/main/java/com/chargebee/v4/models/entitlement/params/EntitlementListParams.java +++ b/src/main/java/com/chargebee/v4/models/entitlement/params/EntitlementListParams.java @@ -157,7 +157,7 @@ public static final class EntityIdFilter extends StringFilter map) { + return fromJson(JsonUtil.toJson(map)); + } + + public static GrantBlock fromJson(JsonObject jsonObj) { + GrantBlock obj = new GrantBlock(); + + obj.id = JsonUtil.getString(jsonObj, "id"); + + obj.grantedAmount = JsonUtil.getString(jsonObj, "granted_amount"); + + obj.effectiveFrom = JsonUtil.getTimestamp(jsonObj, "effective_from"); + + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); + + obj.balance = JsonUtil.getString(jsonObj, "balance"); + + obj.holdAmount = JsonUtil.getString(jsonObj, "hold_amount"); + + obj.usedAmount = JsonUtil.getString(jsonObj, "used_amount"); + + obj.expiredAmount = JsonUtil.getString(jsonObj, "expired_amount"); + + obj.rolledOverAmount = JsonUtil.getString(jsonObj, "rolled_over_amount"); + + obj.voidedAmount = JsonUtil.getString(jsonObj, "voided_amount"); + + obj.originGrantBlockId = JsonUtil.getString(jsonObj, "origin_grant_block_id"); + + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); + + obj.metadata = JsonUtil.getString(jsonObj, "metadata"); + + obj.grantSource = GrantSource.fromString(JsonUtil.getString(jsonObj, "grant_source")); + + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); + + obj.accountType = AccountType.fromString(JsonUtil.getString(jsonObj, "account_type")); + + obj.unitId = JsonUtil.getString(jsonObj, "unit_id"); + + obj.unitType = UnitType.fromString(JsonUtil.getString(jsonObj, "unit_type")); + + return obj; + } + + @Override + public String toString() { + return "GrantBlock{" + + "id=" + + id + + ", grantedAmount=" + + grantedAmount + + ", effectiveFrom=" + + effectiveFrom + + ", expiresAt=" + + expiresAt + + ", balance=" + + balance + + ", holdAmount=" + + holdAmount + + ", usedAmount=" + + usedAmount + + ", expiredAmount=" + + expiredAmount + + ", rolledOverAmount=" + + rolledOverAmount + + ", voidedAmount=" + + voidedAmount + + ", originGrantBlockId=" + + originGrantBlockId + + ", status=" + + status + + ", metadata=" + + metadata + + ", grantSource=" + + grantSource + + ", createdAt=" + + createdAt + + ", accountType=" + + accountType + + ", unitId=" + + unitId + + ", unitType=" + + unitType + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GrantBlock that = (GrantBlock) o; + return java.util.Objects.equals(id, that.id) + && java.util.Objects.equals(grantedAmount, that.grantedAmount) + && java.util.Objects.equals(effectiveFrom, that.effectiveFrom) + && java.util.Objects.equals(expiresAt, that.expiresAt) + && java.util.Objects.equals(balance, that.balance) + && java.util.Objects.equals(holdAmount, that.holdAmount) + && java.util.Objects.equals(usedAmount, that.usedAmount) + && java.util.Objects.equals(expiredAmount, that.expiredAmount) + && java.util.Objects.equals(rolledOverAmount, that.rolledOverAmount) + && java.util.Objects.equals(voidedAmount, that.voidedAmount) + && java.util.Objects.equals(originGrantBlockId, that.originGrantBlockId) + && java.util.Objects.equals(status, that.status) + && java.util.Objects.equals(metadata, that.metadata) + && java.util.Objects.equals(grantSource, that.grantSource) + && java.util.Objects.equals(createdAt, that.createdAt) + && java.util.Objects.equals(accountType, that.accountType) + && java.util.Objects.equals(unitId, that.unitId) + && java.util.Objects.equals(unitType, that.unitType); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash( + id, + grantedAmount, + effectiveFrom, + expiresAt, + balance, + holdAmount, + usedAmount, + expiredAmount, + rolledOverAmount, + voidedAmount, + originGrantBlockId, + status, + metadata, + grantSource, + createdAt, + accountType, + unitId, + unitType); + } +} diff --git a/src/main/java/com/chargebee/v4/models/grantBlock/params/ListGrantBlocksParams.java b/src/main/java/com/chargebee/v4/models/grantBlock/params/ListGrantBlocksParams.java new file mode 100644 index 00000000..107fd8be --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/grantBlock/params/ListGrantBlocksParams.java @@ -0,0 +1,224 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.models.grantBlock.params; + +import com.chargebee.v4.internal.Recommended; +import com.chargebee.v4.filters.StringFilter; +import com.chargebee.v4.filters.TimestampFilter; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +public final class ListGrantBlocksParams { + + private final Map queryParams; + + private ListGrantBlocksParams(ListGrantBlocksBuilder builder) { + this.queryParams = Collections.unmodifiableMap(new LinkedHashMap<>(builder.queryParams)); + } + + /** Get the query parameters for this request. */ + public Map toQueryParams() { + return queryParams; + } + + public ListGrantBlocksBuilder toBuilder() { + ListGrantBlocksBuilder builder = new ListGrantBlocksBuilder(); + builder.queryParams.putAll(queryParams); + return builder; + } + + /** Create a new builder for ListGrantBlocksParams. */ + @Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness") + public static ListGrantBlocksBuilder builder() { + return new ListGrantBlocksBuilder(); + } + + public static final class ListGrantBlocksBuilder { + private final Map queryParams = new LinkedHashMap<>(); + + private ListGrantBlocksBuilder() {} + + public ListGrantBlocksBuilder limit(Integer value) { + queryParams.put("limit", value); + return this; + } + + public ListGrantBlocksBuilder offset(String value) { + queryParams.put("offset", value); + return this; + } + + public SubscriptionIdFilter subscriptionId() { + return new SubscriptionIdFilter("subscription_id", this, queryParams); + } + + public UnitIdFilter unitId() { + return new UnitIdFilter("unit_id", this, queryParams); + } + + public EffectiveFromFilter effectiveFrom() { + return new EffectiveFromFilter("effective_from", this, queryParams); + } + + public ExpiresAtFilter expiresAt() { + return new ExpiresAtFilter("expires_at", this, queryParams); + } + + public CreatedAtFilter createdAt() { + return new CreatedAtFilter("created_at", this, queryParams); + } + + public SortBySortBuilder sortBy() { + return new SortBySortBuilder("sort_by", this); + } + + public ListGrantBlocksParams build() { + return new ListGrantBlocksParams(this); + } + + public static final class SubscriptionIdFilter extends StringFilter { + SubscriptionIdFilter( + String fieldName, ListGrantBlocksBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + + public static final class UnitIdFilter extends StringFilter { + UnitIdFilter(String fieldName, ListGrantBlocksBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + + public static final class EffectiveFromFilter extends TimestampFilter { + EffectiveFromFilter( + String fieldName, ListGrantBlocksBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + + public static final class ExpiresAtFilter extends TimestampFilter { + ExpiresAtFilter( + String fieldName, ListGrantBlocksBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + + public static final class CreatedAtFilter extends TimestampFilter { + CreatedAtFilter( + String fieldName, ListGrantBlocksBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + + public static final class SortBySortBuilder { + private final String fieldName; + private final ListGrantBlocksBuilder builder; + + SortBySortBuilder(String fieldName, ListGrantBlocksBuilder builder) { + this.fieldName = fieldName; + this.builder = builder; + } + + public SortDirection effective_from() { + return new SortDirection(fieldName, "effective_from", builder); + } + + public SortDirection expires_at() { + return new SortDirection(fieldName, "expires_at", builder); + } + + public SortDirection created_at() { + return new SortDirection(fieldName, "created_at", builder); + } + } + + public static final class SortDirection { + private final String fieldName; + private final String selectedField; + private final ListGrantBlocksBuilder builder; + + SortDirection(String fieldName, String selectedField, ListGrantBlocksBuilder builder) { + this.fieldName = fieldName; + this.selectedField = selectedField; + this.builder = builder; + } + + public ListGrantBlocksBuilder asc() { + builder.queryParams.put(fieldName + "[asc]", selectedField); + return builder; + } + + public ListGrantBlocksBuilder desc() { + builder.queryParams.put(fieldName + "[desc]", selectedField); + return builder; + } + } + } + + public enum SortByAsc { + EFFECTIVE_FROM("effective_from"), + + EXPIRES_AT("expires_at"), + + CREATED_AT("created_at"), + + /** An enum member indicating that SortByAsc was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + SortByAsc(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static SortByAsc fromString(String value) { + if (value == null) return _UNKNOWN; + for (SortByAsc enumValue : SortByAsc.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + + public enum SortByDesc { + EFFECTIVE_FROM("effective_from"), + + EXPIRES_AT("expires_at"), + + CREATED_AT("created_at"), + + /** An enum member indicating that SortByDesc was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + SortByDesc(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static SortByDesc fromString(String value) { + if (value == null) return _UNKNOWN; + for (SortByDesc enumValue : SortByDesc.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/grantBlock/responses/ListGrantBlocksResponse.java b/src/main/java/com/chargebee/v4/models/grantBlock/responses/ListGrantBlocksResponse.java new file mode 100644 index 00000000..4ceda16d --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/grantBlock/responses/ListGrantBlocksResponse.java @@ -0,0 +1,211 @@ +package com.chargebee.v4.models.grantBlock.responses; + +import java.util.List; + +import com.chargebee.v4.models.grantBlock.GrantBlock; + +import com.chargebee.v4.exceptions.ChargebeeException; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import com.chargebee.v4.transport.Response; +import com.chargebee.v4.services.GrantBlockService; +import com.chargebee.v4.models.grantBlock.params.ListGrantBlocksParams; + +/** Immutable response object for ListGrantBlocks operation. Contains paginated list data. */ +public final class ListGrantBlocksResponse { + + private final List list; + + private final String nextOffset; + + private final GrantBlockService service; + private final ListGrantBlocksParams originalParams; + private final Response httpResponse; + + private ListGrantBlocksResponse( + List list, + String nextOffset, + GrantBlockService service, + ListGrantBlocksParams originalParams, + Response httpResponse) { + + this.list = list; + + this.nextOffset = nextOffset; + + this.service = service; + this.originalParams = originalParams; + this.httpResponse = httpResponse; + } + + /** + * Parse JSON response into ListGrantBlocksResponse object (no service context). Use this when you + * only need to read a single page (no nextPage()). + */ + public static ListGrantBlocksResponse fromJson(String json) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + + List list = + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), GrantBlockListGrantBlocksItem::fromJson); + + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); + + return new ListGrantBlocksResponse(list, nextOffset, null, null, null); + } catch (Exception e) { + throw new RuntimeException("Failed to parse ListGrantBlocksResponse from JSON", e); + } + } + + /** + * Parse JSON response into ListGrantBlocksResponse object with service context for pagination + * (enables nextPage()). + */ + public static ListGrantBlocksResponse fromJson( + String json, + GrantBlockService service, + ListGrantBlocksParams originalParams, + Response httpResponse) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + + List list = + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), GrantBlockListGrantBlocksItem::fromJson); + + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); + + return new ListGrantBlocksResponse(list, nextOffset, service, originalParams, httpResponse); + } catch (Exception e) { + throw new RuntimeException("Failed to parse ListGrantBlocksResponse from JSON", e); + } + } + + /** Get the list from the response. */ + public List getList() { + return list; + } + + /** Get the nextOffset from the response. */ + public String getNextOffset() { + return nextOffset; + } + + /** Check if there are more pages available. */ + public boolean hasNextPage() { + return nextOffset != null && !nextOffset.isEmpty(); + } + + /** + * Get the next page of results. + * + * @throws ChargebeeException if unable to fetch next page + */ + public ListGrantBlocksResponse nextPage() throws ChargebeeException { + if (!hasNextPage()) { + throw new IllegalStateException("No more pages available"); + } + if (service == null) { + throw new UnsupportedOperationException( + "nextPage() requires service context. Use fromJson(json, service, originalParams, httpResponse)."); + } + + ListGrantBlocksParams nextParams = + (originalParams != null ? originalParams.toBuilder() : ListGrantBlocksParams.builder()) + .offset(nextOffset) + .build(); + + return service.listGrantBlocks(nextParams); + } + + /** Get the raw response payload as JSON string. */ + public String responsePayload() { + return httpResponse != null ? httpResponse.getBodyAsString() : null; + } + + /** Get the HTTP status code. */ + public int httpStatus() { + return httpResponse != null ? httpResponse.getStatusCode() : 0; + } + + /** Get response headers. */ + public java.util.Map> headers() { + return httpResponse != null ? httpResponse.getHeaders() : java.util.Collections.emptyMap(); + } + + /** Get a specific header value. */ + public java.util.List header(String name) { + if (httpResponse == null) return null; + return httpResponse.getHeaders().entrySet().stream() + .filter(e -> e.getKey().equalsIgnoreCase(name)) + .map(java.util.Map.Entry::getValue) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "ListGrantBlocksResponse{" + "list=" + list + ", nextOffset=" + nextOffset + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ListGrantBlocksResponse that = (ListGrantBlocksResponse) o; + return java.util.Objects.equals(list, that.list) + && java.util.Objects.equals(nextOffset, that.nextOffset); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(list, nextOffset); + } + + public static class GrantBlockListGrantBlocksItem { + + private GrantBlock grantBlock; + + public GrantBlock getGrantBlock() { + return grantBlock; + } + + public static GrantBlockListGrantBlocksItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GrantBlockListGrantBlocksItem fromJson(JsonObject jsonObj) { + GrantBlockListGrantBlocksItem item = new GrantBlockListGrantBlocksItem(); + + JsonObject __grantBlockObj = JsonUtil.getJsonObject(jsonObj, "grant_block"); + if (__grantBlockObj != null) { + item.grantBlock = GrantBlock.fromJson(__grantBlockObj); + } + + return item; + } + + @Override + public String toString() { + return "GrantBlockListGrantBlocksItem{" + "grantBlock=" + grantBlock + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GrantBlockListGrantBlocksItem that = (GrantBlockListGrantBlocksItem) o; + return java.util.Objects.equals(grantBlock, that.grantBlock); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(grantBlock); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/HostedPage.java b/src/main/java/com/chargebee/v4/models/hostedPage/HostedPage.java index 7fcedf0a..eefe313a 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/HostedPage.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/HostedPage.java @@ -21,6 +21,7 @@ public class HostedPage { private String passThruContent; private Timestamp createdAt; private Timestamp expiresAt; + private Layout layout; private java.util.Map content; private Timestamp updatedAt; private Long resourceVersion; @@ -61,6 +62,10 @@ public Timestamp getExpiresAt() { return expiresAt; } + public Layout getLayout() { + return layout; + } + public java.util.Map getContent() { return content; } @@ -199,6 +204,34 @@ public static FailureReason fromString(String value) { } } + public enum Layout { + IN_APP("in_app"), + + FULL_PAGE("full_page"), + + /** An enum member indicating that Layout was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + Layout(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static Layout fromString(String value) { + if (value == null) return _UNKNOWN; + for (Layout enumValue : Layout.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + public static HostedPage fromJson(String json) { return fromJson(JsonUtil.parse(json)); } @@ -226,6 +259,8 @@ public static HostedPage fromJson(JsonObject jsonObj) { obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); + obj.layout = Layout.fromString(JsonUtil.getString(jsonObj, "layout")); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); obj.content = __contentObj != null @@ -268,6 +303,8 @@ public String toString() { + createdAt + ", expiresAt=" + expiresAt + + ", layout=" + + layout + ", content=" + content + ", updatedAt=" @@ -297,6 +334,7 @@ public boolean equals(Object o) { && java.util.Objects.equals(passThruContent, that.passThruContent) && java.util.Objects.equals(createdAt, that.createdAt) && java.util.Objects.equals(expiresAt, that.expiresAt) + && java.util.Objects.equals(layout, that.layout) && java.util.Objects.equals(content, that.content) && java.util.Objects.equals(updatedAt, that.updatedAt) && java.util.Objects.equals(resourceVersion, that.resourceVersion) @@ -317,6 +355,7 @@ public int hashCode() { passThruContent, createdAt, expiresAt, + layout, content, updatedAt, resourceVersion, diff --git a/src/main/java/com/chargebee/v4/models/ledgerAccountBalance/LedgerAccountBalance.java b/src/main/java/com/chargebee/v4/models/ledgerAccountBalance/LedgerAccountBalance.java new file mode 100644 index 00000000..718fe385 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerAccountBalance/LedgerAccountBalance.java @@ -0,0 +1,310 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.models.ledgerAccountBalance; + +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import java.sql.Timestamp; + +public class LedgerAccountBalance { + + private String subscriptionId; + private String unitId; + private UnitType unitType; + private Timestamp modifiedAt; + private ProvisionedBalance provisionedBalance; + private OverdraftBalance overdraftBalance; + + public String getSubscriptionId() { + return subscriptionId; + } + + public String getUnitId() { + return unitId; + } + + public UnitType getUnitType() { + return unitType; + } + + public Timestamp getModifiedAt() { + return modifiedAt; + } + + public ProvisionedBalance getProvisionedBalance() { + return provisionedBalance; + } + + public OverdraftBalance getOverdraftBalance() { + return overdraftBalance; + } + + public enum UnitType { + CREDIT_UNIT("credit_unit"), + + /** An enum member indicating that UnitType was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + UnitType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static UnitType fromString(String value) { + if (value == null) return _UNKNOWN; + for (UnitType enumValue : UnitType.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + + public static LedgerAccountBalance fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LedgerAccountBalance fromJson(java.util.Map map) { + return fromJson(JsonUtil.toJson(map)); + } + + public static LedgerAccountBalance fromJson(JsonObject jsonObj) { + LedgerAccountBalance obj = new LedgerAccountBalance(); + + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); + + obj.unitId = JsonUtil.getString(jsonObj, "unit_id"); + + obj.unitType = UnitType.fromString(JsonUtil.getString(jsonObj, "unit_type")); + + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); + + JsonObject __provisionedBalanceObj = JsonUtil.getJsonObject(jsonObj, "provisioned_balance"); + if (__provisionedBalanceObj != null) { + obj.provisionedBalance = ProvisionedBalance.fromJson(__provisionedBalanceObj); + } + + JsonObject __overdraftBalanceObj = JsonUtil.getJsonObject(jsonObj, "overdraft_balance"); + if (__overdraftBalanceObj != null) { + obj.overdraftBalance = OverdraftBalance.fromJson(__overdraftBalanceObj); + } + + return obj; + } + + @Override + public String toString() { + return "LedgerAccountBalance{" + + "subscriptionId=" + + subscriptionId + + ", unitId=" + + unitId + + ", unitType=" + + unitType + + ", modifiedAt=" + + modifiedAt + + ", provisionedBalance=" + + provisionedBalance + + ", overdraftBalance=" + + overdraftBalance + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LedgerAccountBalance that = (LedgerAccountBalance) o; + return java.util.Objects.equals(subscriptionId, that.subscriptionId) + && java.util.Objects.equals(unitId, that.unitId) + && java.util.Objects.equals(unitType, that.unitType) + && java.util.Objects.equals(modifiedAt, that.modifiedAt) + && java.util.Objects.equals(provisionedBalance, that.provisionedBalance) + && java.util.Objects.equals(overdraftBalance, that.overdraftBalance); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash( + subscriptionId, unitId, unitType, modifiedAt, provisionedBalance, overdraftBalance); + } + + public static class ProvisionedBalance { + + private String totalBalance; + private String usableBalance; + private String holdAmount; + + public String getTotalBalance() { + return totalBalance; + } + + public String getUsableBalance() { + return usableBalance; + } + + public String getHoldAmount() { + return holdAmount; + } + + public static ProvisionedBalance fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ProvisionedBalance fromJson(java.util.Map map) { + return fromJson(JsonUtil.toJson(map)); + } + + public static ProvisionedBalance fromJson(JsonObject jsonObj) { + ProvisionedBalance obj = new ProvisionedBalance(); + + obj.totalBalance = JsonUtil.getString(jsonObj, "total_balance"); + + obj.usableBalance = JsonUtil.getString(jsonObj, "usable_balance"); + + obj.holdAmount = JsonUtil.getString(jsonObj, "hold_amount"); + + return obj; + } + + @Override + public String toString() { + return "ProvisionedBalance{" + + "totalBalance=" + + totalBalance + + ", usableBalance=" + + usableBalance + + ", holdAmount=" + + holdAmount + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ProvisionedBalance that = (ProvisionedBalance) o; + return java.util.Objects.equals(totalBalance, that.totalBalance) + && java.util.Objects.equals(usableBalance, that.usableBalance) + && java.util.Objects.equals(holdAmount, that.holdAmount); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(totalBalance, usableBalance, holdAmount); + } + } + + public static class OverdraftBalance { + + private Boolean isUnlimited; + private String limit; + private String totalBalance; + private String usableBalance; + private String usedAmount; + private String holdAmount; + + public Boolean getIsUnlimited() { + return isUnlimited; + } + + public String getLimit() { + return limit; + } + + public String getTotalBalance() { + return totalBalance; + } + + public String getUsableBalance() { + return usableBalance; + } + + public String getUsedAmount() { + return usedAmount; + } + + public String getHoldAmount() { + return holdAmount; + } + + public static OverdraftBalance fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OverdraftBalance fromJson(java.util.Map map) { + return fromJson(JsonUtil.toJson(map)); + } + + public static OverdraftBalance fromJson(JsonObject jsonObj) { + OverdraftBalance obj = new OverdraftBalance(); + + obj.isUnlimited = JsonUtil.getBoolean(jsonObj, "is_unlimited"); + + obj.limit = JsonUtil.getString(jsonObj, "limit"); + + obj.totalBalance = JsonUtil.getString(jsonObj, "total_balance"); + + obj.usableBalance = JsonUtil.getString(jsonObj, "usable_balance"); + + obj.usedAmount = JsonUtil.getString(jsonObj, "used_amount"); + + obj.holdAmount = JsonUtil.getString(jsonObj, "hold_amount"); + + return obj; + } + + @Override + public String toString() { + return "OverdraftBalance{" + + "isUnlimited=" + + isUnlimited + + ", limit=" + + limit + + ", totalBalance=" + + totalBalance + + ", usableBalance=" + + usableBalance + + ", usedAmount=" + + usedAmount + + ", holdAmount=" + + holdAmount + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + OverdraftBalance that = (OverdraftBalance) o; + return java.util.Objects.equals(isUnlimited, that.isUnlimited) + && java.util.Objects.equals(limit, that.limit) + && java.util.Objects.equals(totalBalance, that.totalBalance) + && java.util.Objects.equals(usableBalance, that.usableBalance) + && java.util.Objects.equals(usedAmount, that.usedAmount) + && java.util.Objects.equals(holdAmount, that.holdAmount); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash( + isUnlimited, limit, totalBalance, usableBalance, usedAmount, holdAmount); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerAccountBalance/params/ListLedgerAccountBalancesParams.java b/src/main/java/com/chargebee/v4/models/ledgerAccountBalance/params/ListLedgerAccountBalancesParams.java new file mode 100644 index 00000000..70c490be --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerAccountBalance/params/ListLedgerAccountBalancesParams.java @@ -0,0 +1,84 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.models.ledgerAccountBalance.params; + +import com.chargebee.v4.internal.Recommended; +import com.chargebee.v4.filters.StringFilter; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +public final class ListLedgerAccountBalancesParams { + + private final Map queryParams; + + private ListLedgerAccountBalancesParams(ListLedgerAccountBalancesBuilder builder) { + this.queryParams = Collections.unmodifiableMap(new LinkedHashMap<>(builder.queryParams)); + } + + /** Get the query parameters for this request. */ + public Map toQueryParams() { + return queryParams; + } + + public ListLedgerAccountBalancesBuilder toBuilder() { + ListLedgerAccountBalancesBuilder builder = new ListLedgerAccountBalancesBuilder(); + builder.queryParams.putAll(queryParams); + return builder; + } + + /** Create a new builder for ListLedgerAccountBalancesParams. */ + @Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness") + public static ListLedgerAccountBalancesBuilder builder() { + return new ListLedgerAccountBalancesBuilder(); + } + + public static final class ListLedgerAccountBalancesBuilder { + private final Map queryParams = new LinkedHashMap<>(); + + private ListLedgerAccountBalancesBuilder() {} + + public ListLedgerAccountBalancesBuilder limit(Integer value) { + queryParams.put("limit", value); + return this; + } + + public ListLedgerAccountBalancesBuilder offset(String value) { + queryParams.put("offset", value); + return this; + } + + public SubscriptionIdFilter subscriptionId() { + return new SubscriptionIdFilter("subscription_id", this, queryParams); + } + + public UnitIdFilter unitId() { + return new UnitIdFilter("unit_id", this, queryParams); + } + + public ListLedgerAccountBalancesParams build() { + return new ListLedgerAccountBalancesParams(this); + } + + public static final class SubscriptionIdFilter + extends StringFilter { + SubscriptionIdFilter( + String fieldName, ListLedgerAccountBalancesBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + + public static final class UnitIdFilter extends StringFilter { + UnitIdFilter( + String fieldName, ListLedgerAccountBalancesBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerAccountBalance/responses/ListLedgerAccountBalancesResponse.java b/src/main/java/com/chargebee/v4/models/ledgerAccountBalance/responses/ListLedgerAccountBalancesResponse.java new file mode 100644 index 00000000..8969b2ab --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerAccountBalance/responses/ListLedgerAccountBalancesResponse.java @@ -0,0 +1,229 @@ +package com.chargebee.v4.models.ledgerAccountBalance.responses; + +import java.util.List; + +import com.chargebee.v4.models.ledgerAccountBalance.LedgerAccountBalance; + +import com.chargebee.v4.exceptions.ChargebeeException; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import com.chargebee.v4.transport.Response; +import com.chargebee.v4.services.LedgerAccountBalanceService; +import com.chargebee.v4.models.ledgerAccountBalance.params.ListLedgerAccountBalancesParams; + +/** + * Immutable response object for ListLedgerAccountBalances operation. Contains paginated list data. + */ +public final class ListLedgerAccountBalancesResponse { + + private final List list; + + private final String nextOffset; + + private final LedgerAccountBalanceService service; + private final ListLedgerAccountBalancesParams originalParams; + private final Response httpResponse; + + private ListLedgerAccountBalancesResponse( + List list, + String nextOffset, + LedgerAccountBalanceService service, + ListLedgerAccountBalancesParams originalParams, + Response httpResponse) { + + this.list = list; + + this.nextOffset = nextOffset; + + this.service = service; + this.originalParams = originalParams; + this.httpResponse = httpResponse; + } + + /** + * Parse JSON response into ListLedgerAccountBalancesResponse object (no service context). Use + * this when you only need to read a single page (no nextPage()). + */ + public static ListLedgerAccountBalancesResponse fromJson(String json) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + + List list = + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + LedgerAccountBalanceListLedgerAccountBalancesItem::fromJson); + + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); + + return new ListLedgerAccountBalancesResponse(list, nextOffset, null, null, null); + } catch (Exception e) { + throw new RuntimeException("Failed to parse ListLedgerAccountBalancesResponse from JSON", e); + } + } + + /** + * Parse JSON response into ListLedgerAccountBalancesResponse object with service context for + * pagination (enables nextPage()). + */ + public static ListLedgerAccountBalancesResponse fromJson( + String json, + LedgerAccountBalanceService service, + ListLedgerAccountBalancesParams originalParams, + Response httpResponse) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + + List list = + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + LedgerAccountBalanceListLedgerAccountBalancesItem::fromJson); + + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); + + return new ListLedgerAccountBalancesResponse( + list, nextOffset, service, originalParams, httpResponse); + } catch (Exception e) { + throw new RuntimeException("Failed to parse ListLedgerAccountBalancesResponse from JSON", e); + } + } + + /** Get the list from the response. */ + public List getList() { + return list; + } + + /** Get the nextOffset from the response. */ + public String getNextOffset() { + return nextOffset; + } + + /** Check if there are more pages available. */ + public boolean hasNextPage() { + return nextOffset != null && !nextOffset.isEmpty(); + } + + /** + * Get the next page of results. + * + * @throws ChargebeeException if unable to fetch next page + */ + public ListLedgerAccountBalancesResponse nextPage() throws ChargebeeException { + if (!hasNextPage()) { + throw new IllegalStateException("No more pages available"); + } + if (service == null) { + throw new UnsupportedOperationException( + "nextPage() requires service context. Use fromJson(json, service, originalParams, httpResponse)."); + } + + ListLedgerAccountBalancesParams nextParams = + (originalParams != null + ? originalParams.toBuilder() + : ListLedgerAccountBalancesParams.builder()) + .offset(nextOffset) + .build(); + + return service.listLedgerAccountBalances(nextParams); + } + + /** Get the raw response payload as JSON string. */ + public String responsePayload() { + return httpResponse != null ? httpResponse.getBodyAsString() : null; + } + + /** Get the HTTP status code. */ + public int httpStatus() { + return httpResponse != null ? httpResponse.getStatusCode() : 0; + } + + /** Get response headers. */ + public java.util.Map> headers() { + return httpResponse != null ? httpResponse.getHeaders() : java.util.Collections.emptyMap(); + } + + /** Get a specific header value. */ + public java.util.List header(String name) { + if (httpResponse == null) return null; + return httpResponse.getHeaders().entrySet().stream() + .filter(e -> e.getKey().equalsIgnoreCase(name)) + .map(java.util.Map.Entry::getValue) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "ListLedgerAccountBalancesResponse{" + + "list=" + + list + + ", nextOffset=" + + nextOffset + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ListLedgerAccountBalancesResponse that = (ListLedgerAccountBalancesResponse) o; + return java.util.Objects.equals(list, that.list) + && java.util.Objects.equals(nextOffset, that.nextOffset); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(list, nextOffset); + } + + public static class LedgerAccountBalanceListLedgerAccountBalancesItem { + + private LedgerAccountBalance ledgerAccountBalance; + + public LedgerAccountBalance getLedgerAccountBalance() { + return ledgerAccountBalance; + } + + public static LedgerAccountBalanceListLedgerAccountBalancesItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LedgerAccountBalanceListLedgerAccountBalancesItem fromJson(JsonObject jsonObj) { + LedgerAccountBalanceListLedgerAccountBalancesItem item = + new LedgerAccountBalanceListLedgerAccountBalancesItem(); + + JsonObject __ledgerAccountBalanceObj = + JsonUtil.getJsonObject(jsonObj, "ledger_account_balance"); + if (__ledgerAccountBalanceObj != null) { + item.ledgerAccountBalance = LedgerAccountBalance.fromJson(__ledgerAccountBalanceObj); + } + + return item; + } + + @Override + public String toString() { + return "LedgerAccountBalanceListLedgerAccountBalancesItem{" + + "ledgerAccountBalance=" + + ledgerAccountBalance + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LedgerAccountBalanceListLedgerAccountBalancesItem that = + (LedgerAccountBalanceListLedgerAccountBalancesItem) o; + return java.util.Objects.equals(ledgerAccountBalance, that.ledgerAccountBalance); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(ledgerAccountBalance); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/LedgerOperation.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/LedgerOperation.java new file mode 100644 index 00000000..37e6667a --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/LedgerOperation.java @@ -0,0 +1,316 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.models.ledgerOperation; + +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import java.sql.Timestamp; + +public class LedgerOperation { + + private String id; + private Type type; + private String amount; + private String startBalance; + private String endBalance; + private String provisionedStartBalance; + private String provisionedEndBalance; + private String overdraftStartBalance; + private String overdraftEndBalance; + private String parentLedgerOperationId; + private Timestamp ledgerOperationTimestamp; + private Timestamp autoReleaseTimestamp; + private String metadata; + private Timestamp createdAt; + private Timestamp modifiedAt; + private String subscriptionId; + private String unitId; + private UnitType unitType; + + public String getId() { + return id; + } + + public Type getType() { + return type; + } + + public String getAmount() { + return amount; + } + + public String getStartBalance() { + return startBalance; + } + + public String getEndBalance() { + return endBalance; + } + + public String getProvisionedStartBalance() { + return provisionedStartBalance; + } + + public String getProvisionedEndBalance() { + return provisionedEndBalance; + } + + public String getOverdraftStartBalance() { + return overdraftStartBalance; + } + + public String getOverdraftEndBalance() { + return overdraftEndBalance; + } + + public String getParentLedgerOperationId() { + return parentLedgerOperationId; + } + + public Timestamp getLedgerOperationTimestamp() { + return ledgerOperationTimestamp; + } + + public Timestamp getAutoReleaseTimestamp() { + return autoReleaseTimestamp; + } + + public String getMetadata() { + return metadata; + } + + public Timestamp getCreatedAt() { + return createdAt; + } + + public Timestamp getModifiedAt() { + return modifiedAt; + } + + public String getSubscriptionId() { + return subscriptionId; + } + + public String getUnitId() { + return unitId; + } + + public UnitType getUnitType() { + return unitType; + } + + public enum Type { + ALLOCATION("allocation"), + + CAPTURE("capture"), + + AUTHORIZE("authorize"), + + RELEASE_AUTHORIZATION("release_authorization"), + + CAPTURE_AUTHORIZATION("capture_authorization"), + + EXPIRY("expiry"), + + VOID("void"), + + ROLLOVER("rollover"), + + ADJUSTMENT("adjustment"), + + /** An enum member indicating that Type was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + Type(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static Type fromString(String value) { + if (value == null) return _UNKNOWN; + for (Type enumValue : Type.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + + public enum UnitType { + CREDIT_UNIT("credit_unit"), + + /** An enum member indicating that UnitType was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + UnitType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static UnitType fromString(String value) { + if (value == null) return _UNKNOWN; + for (UnitType enumValue : UnitType.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + + public static LedgerOperation fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LedgerOperation fromJson(java.util.Map map) { + return fromJson(JsonUtil.toJson(map)); + } + + public static LedgerOperation fromJson(JsonObject jsonObj) { + LedgerOperation obj = new LedgerOperation(); + + obj.id = JsonUtil.getString(jsonObj, "id"); + + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); + + obj.amount = JsonUtil.getString(jsonObj, "amount"); + + obj.startBalance = JsonUtil.getString(jsonObj, "start_balance"); + + obj.endBalance = JsonUtil.getString(jsonObj, "end_balance"); + + obj.provisionedStartBalance = JsonUtil.getString(jsonObj, "provisioned_start_balance"); + + obj.provisionedEndBalance = JsonUtil.getString(jsonObj, "provisioned_end_balance"); + + obj.overdraftStartBalance = JsonUtil.getString(jsonObj, "overdraft_start_balance"); + + obj.overdraftEndBalance = JsonUtil.getString(jsonObj, "overdraft_end_balance"); + + obj.parentLedgerOperationId = JsonUtil.getString(jsonObj, "parent_ledger_operation_id"); + + obj.ledgerOperationTimestamp = JsonUtil.getTimestamp(jsonObj, "ledger_operation_timestamp"); + + obj.autoReleaseTimestamp = JsonUtil.getTimestamp(jsonObj, "auto_release_timestamp"); + + obj.metadata = JsonUtil.getString(jsonObj, "metadata"); + + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); + + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); + + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); + + obj.unitId = JsonUtil.getString(jsonObj, "unit_id"); + + obj.unitType = UnitType.fromString(JsonUtil.getString(jsonObj, "unit_type")); + + return obj; + } + + @Override + public String toString() { + return "LedgerOperation{" + + "id=" + + id + + ", type=" + + type + + ", amount=" + + amount + + ", startBalance=" + + startBalance + + ", endBalance=" + + endBalance + + ", provisionedStartBalance=" + + provisionedStartBalance + + ", provisionedEndBalance=" + + provisionedEndBalance + + ", overdraftStartBalance=" + + overdraftStartBalance + + ", overdraftEndBalance=" + + overdraftEndBalance + + ", parentLedgerOperationId=" + + parentLedgerOperationId + + ", ledgerOperationTimestamp=" + + ledgerOperationTimestamp + + ", autoReleaseTimestamp=" + + autoReleaseTimestamp + + ", metadata=" + + metadata + + ", createdAt=" + + createdAt + + ", modifiedAt=" + + modifiedAt + + ", subscriptionId=" + + subscriptionId + + ", unitId=" + + unitId + + ", unitType=" + + unitType + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LedgerOperation that = (LedgerOperation) o; + return java.util.Objects.equals(id, that.id) + && java.util.Objects.equals(type, that.type) + && java.util.Objects.equals(amount, that.amount) + && java.util.Objects.equals(startBalance, that.startBalance) + && java.util.Objects.equals(endBalance, that.endBalance) + && java.util.Objects.equals(provisionedStartBalance, that.provisionedStartBalance) + && java.util.Objects.equals(provisionedEndBalance, that.provisionedEndBalance) + && java.util.Objects.equals(overdraftStartBalance, that.overdraftStartBalance) + && java.util.Objects.equals(overdraftEndBalance, that.overdraftEndBalance) + && java.util.Objects.equals(parentLedgerOperationId, that.parentLedgerOperationId) + && java.util.Objects.equals(ledgerOperationTimestamp, that.ledgerOperationTimestamp) + && java.util.Objects.equals(autoReleaseTimestamp, that.autoReleaseTimestamp) + && java.util.Objects.equals(metadata, that.metadata) + && java.util.Objects.equals(createdAt, that.createdAt) + && java.util.Objects.equals(modifiedAt, that.modifiedAt) + && java.util.Objects.equals(subscriptionId, that.subscriptionId) + && java.util.Objects.equals(unitId, that.unitId) + && java.util.Objects.equals(unitType, that.unitType); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash( + id, + type, + amount, + startBalance, + endBalance, + provisionedStartBalance, + provisionedEndBalance, + overdraftStartBalance, + overdraftEndBalance, + parentLedgerOperationId, + ledgerOperationTimestamp, + autoReleaseTimestamp, + metadata, + createdAt, + modifiedAt, + subscriptionId, + unitId, + unitType); + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationAuthorizeParams.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationAuthorizeParams.java new file mode 100644 index 00000000..cc2e6bb3 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationAuthorizeParams.java @@ -0,0 +1,187 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ +package com.chargebee.v4.models.ledgerOperation.params; + +import com.chargebee.v4.internal.Recommended; +import com.chargebee.v4.internal.JsonUtil; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.sql.Timestamp; + +public final class LedgerOperationAuthorizeParams { + + private final String id; + + private final String subscriptionId; + + private final String unitId; + + private final String amount; + + private final Timestamp ledgerOperationTimestamp; + + private final Timestamp autoReleaseTimestamp; + + private final java.util.Map metadata; + + private LedgerOperationAuthorizeParams(LedgerOperationAuthorizeBuilder builder) { + + this.id = builder.id; + + this.subscriptionId = builder.subscriptionId; + + this.unitId = builder.unitId; + + this.amount = builder.amount; + + this.ledgerOperationTimestamp = builder.ledgerOperationTimestamp; + + this.autoReleaseTimestamp = builder.autoReleaseTimestamp; + + this.metadata = builder.metadata; + } + + public String getId() { + return id; + } + + public String getSubscriptionId() { + return subscriptionId; + } + + public String getUnitId() { + return unitId; + } + + public String getAmount() { + return amount; + } + + public Timestamp getLedgerOperationTimestamp() { + return ledgerOperationTimestamp; + } + + public Timestamp getAutoReleaseTimestamp() { + return autoReleaseTimestamp; + } + + public java.util.Map getMetadata() { + return metadata; + } + + /** Get the form data for this request. */ + public Map toFormData() { + Map formData = new LinkedHashMap<>(); + + if (this.id != null) { + + formData.put("id", this.id); + } + + if (this.subscriptionId != null) { + + formData.put("subscription_id", this.subscriptionId); + } + + if (this.unitId != null) { + + formData.put("unit_id", this.unitId); + } + + if (this.amount != null) { + + formData.put("amount", this.amount); + } + + if (this.ledgerOperationTimestamp != null) { + + formData.put("ledger_operation_timestamp", this.ledgerOperationTimestamp); + } + + if (this.autoReleaseTimestamp != null) { + + formData.put("auto_release_timestamp", this.autoReleaseTimestamp); + } + + if (this.metadata != null) { + + formData.put("metadata", JsonUtil.toJson(this.metadata)); + } + + return formData; + } + + /** Get the JSON string representation for this request. */ + public String toJsonString() { + return JsonUtil.toJson(toFormData()); + } + + /** Create a new builder for LedgerOperationAuthorizeParams. */ + @Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness") + public static LedgerOperationAuthorizeBuilder builder() { + return new LedgerOperationAuthorizeBuilder(); + } + + public static final class LedgerOperationAuthorizeBuilder { + + private String id; + + private String subscriptionId; + + private String unitId; + + private String amount; + + private Timestamp ledgerOperationTimestamp; + + private Timestamp autoReleaseTimestamp; + + private java.util.Map metadata; + + private LedgerOperationAuthorizeBuilder() {} + + public LedgerOperationAuthorizeBuilder id(String value) { + this.id = value; + return this; + } + + public LedgerOperationAuthorizeBuilder subscriptionId(String value) { + this.subscriptionId = value; + return this; + } + + public LedgerOperationAuthorizeBuilder unitId(String value) { + this.unitId = value; + return this; + } + + public LedgerOperationAuthorizeBuilder amount(String value) { + this.amount = value; + return this; + } + + public LedgerOperationAuthorizeBuilder ledgerOperationTimestamp(Timestamp value) { + this.ledgerOperationTimestamp = value; + return this; + } + + public LedgerOperationAuthorizeBuilder autoReleaseTimestamp(Timestamp value) { + this.autoReleaseTimestamp = value; + return this; + } + + public LedgerOperationAuthorizeBuilder metadata(java.util.Map value) { + this.metadata = value; + return this; + } + + public LedgerOperationAuthorizeParams build() { + return new LedgerOperationAuthorizeParams(this); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationCaptureAuthorizationParams.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationCaptureAuthorizationParams.java new file mode 100644 index 00000000..9c583883 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationCaptureAuthorizationParams.java @@ -0,0 +1,149 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ +package com.chargebee.v4.models.ledgerOperation.params; + +import com.chargebee.v4.internal.Recommended; +import com.chargebee.v4.internal.JsonUtil; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.sql.Timestamp; + +public final class LedgerOperationCaptureAuthorizationParams { + + private final String authorizationId; + + private final String id; + + private final String amount; + + private final Timestamp ledgerOperationTimestamp; + + private final java.util.Map metadata; + + private LedgerOperationCaptureAuthorizationParams( + LedgerOperationCaptureAuthorizationBuilder builder) { + + this.authorizationId = builder.authorizationId; + + this.id = builder.id; + + this.amount = builder.amount; + + this.ledgerOperationTimestamp = builder.ledgerOperationTimestamp; + + this.metadata = builder.metadata; + } + + public String getAuthorizationId() { + return authorizationId; + } + + public String getId() { + return id; + } + + public String getAmount() { + return amount; + } + + public Timestamp getLedgerOperationTimestamp() { + return ledgerOperationTimestamp; + } + + public java.util.Map getMetadata() { + return metadata; + } + + /** Get the form data for this request. */ + public Map toFormData() { + Map formData = new LinkedHashMap<>(); + + if (this.authorizationId != null) { + + formData.put("authorization_id", this.authorizationId); + } + + if (this.id != null) { + + formData.put("id", this.id); + } + + if (this.amount != null) { + + formData.put("amount", this.amount); + } + + if (this.ledgerOperationTimestamp != null) { + + formData.put("ledger_operation_timestamp", this.ledgerOperationTimestamp); + } + + if (this.metadata != null) { + + formData.put("metadata", JsonUtil.toJson(this.metadata)); + } + + return formData; + } + + /** Get the JSON string representation for this request. */ + public String toJsonString() { + return JsonUtil.toJson(toFormData()); + } + + /** Create a new builder for LedgerOperationCaptureAuthorizationParams. */ + @Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness") + public static LedgerOperationCaptureAuthorizationBuilder builder() { + return new LedgerOperationCaptureAuthorizationBuilder(); + } + + public static final class LedgerOperationCaptureAuthorizationBuilder { + + private String authorizationId; + + private String id; + + private String amount; + + private Timestamp ledgerOperationTimestamp; + + private java.util.Map metadata; + + private LedgerOperationCaptureAuthorizationBuilder() {} + + public LedgerOperationCaptureAuthorizationBuilder authorizationId(String value) { + this.authorizationId = value; + return this; + } + + public LedgerOperationCaptureAuthorizationBuilder id(String value) { + this.id = value; + return this; + } + + public LedgerOperationCaptureAuthorizationBuilder amount(String value) { + this.amount = value; + return this; + } + + public LedgerOperationCaptureAuthorizationBuilder ledgerOperationTimestamp(Timestamp value) { + this.ledgerOperationTimestamp = value; + return this; + } + + public LedgerOperationCaptureAuthorizationBuilder metadata( + java.util.Map value) { + this.metadata = value; + return this; + } + + public LedgerOperationCaptureAuthorizationParams build() { + return new LedgerOperationCaptureAuthorizationParams(this); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationCaptureParams.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationCaptureParams.java new file mode 100644 index 00000000..afcbb298 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationCaptureParams.java @@ -0,0 +1,167 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ +package com.chargebee.v4.models.ledgerOperation.params; + +import com.chargebee.v4.internal.Recommended; +import com.chargebee.v4.internal.JsonUtil; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.sql.Timestamp; + +public final class LedgerOperationCaptureParams { + + private final String id; + + private final String subscriptionId; + + private final String unitId; + + private final String amount; + + private final Timestamp ledgerOperationTimestamp; + + private final java.util.Map metadata; + + private LedgerOperationCaptureParams(LedgerOperationCaptureBuilder builder) { + + this.id = builder.id; + + this.subscriptionId = builder.subscriptionId; + + this.unitId = builder.unitId; + + this.amount = builder.amount; + + this.ledgerOperationTimestamp = builder.ledgerOperationTimestamp; + + this.metadata = builder.metadata; + } + + public String getId() { + return id; + } + + public String getSubscriptionId() { + return subscriptionId; + } + + public String getUnitId() { + return unitId; + } + + public String getAmount() { + return amount; + } + + public Timestamp getLedgerOperationTimestamp() { + return ledgerOperationTimestamp; + } + + public java.util.Map getMetadata() { + return metadata; + } + + /** Get the form data for this request. */ + public Map toFormData() { + Map formData = new LinkedHashMap<>(); + + if (this.id != null) { + + formData.put("id", this.id); + } + + if (this.subscriptionId != null) { + + formData.put("subscription_id", this.subscriptionId); + } + + if (this.unitId != null) { + + formData.put("unit_id", this.unitId); + } + + if (this.amount != null) { + + formData.put("amount", this.amount); + } + + if (this.ledgerOperationTimestamp != null) { + + formData.put("ledger_operation_timestamp", this.ledgerOperationTimestamp); + } + + if (this.metadata != null) { + + formData.put("metadata", JsonUtil.toJson(this.metadata)); + } + + return formData; + } + + /** Get the JSON string representation for this request. */ + public String toJsonString() { + return JsonUtil.toJson(toFormData()); + } + + /** Create a new builder for LedgerOperationCaptureParams. */ + @Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness") + public static LedgerOperationCaptureBuilder builder() { + return new LedgerOperationCaptureBuilder(); + } + + public static final class LedgerOperationCaptureBuilder { + + private String id; + + private String subscriptionId; + + private String unitId; + + private String amount; + + private Timestamp ledgerOperationTimestamp; + + private java.util.Map metadata; + + private LedgerOperationCaptureBuilder() {} + + public LedgerOperationCaptureBuilder id(String value) { + this.id = value; + return this; + } + + public LedgerOperationCaptureBuilder subscriptionId(String value) { + this.subscriptionId = value; + return this; + } + + public LedgerOperationCaptureBuilder unitId(String value) { + this.unitId = value; + return this; + } + + public LedgerOperationCaptureBuilder amount(String value) { + this.amount = value; + return this; + } + + public LedgerOperationCaptureBuilder ledgerOperationTimestamp(Timestamp value) { + this.ledgerOperationTimestamp = value; + return this; + } + + public LedgerOperationCaptureBuilder metadata(java.util.Map value) { + this.metadata = value; + return this; + } + + public LedgerOperationCaptureParams build() { + return new LedgerOperationCaptureParams(this); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationReleaseAuthorizationParams.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationReleaseAuthorizationParams.java new file mode 100644 index 00000000..75a26187 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/LedgerOperationReleaseAuthorizationParams.java @@ -0,0 +1,129 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ +package com.chargebee.v4.models.ledgerOperation.params; + +import com.chargebee.v4.internal.Recommended; +import com.chargebee.v4.internal.JsonUtil; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.sql.Timestamp; + +public final class LedgerOperationReleaseAuthorizationParams { + + private final String authorizationId; + + private final String id; + + private final Timestamp ledgerOperationTimestamp; + + private final java.util.Map metadata; + + private LedgerOperationReleaseAuthorizationParams( + LedgerOperationReleaseAuthorizationBuilder builder) { + + this.authorizationId = builder.authorizationId; + + this.id = builder.id; + + this.ledgerOperationTimestamp = builder.ledgerOperationTimestamp; + + this.metadata = builder.metadata; + } + + public String getAuthorizationId() { + return authorizationId; + } + + public String getId() { + return id; + } + + public Timestamp getLedgerOperationTimestamp() { + return ledgerOperationTimestamp; + } + + public java.util.Map getMetadata() { + return metadata; + } + + /** Get the form data for this request. */ + public Map toFormData() { + Map formData = new LinkedHashMap<>(); + + if (this.authorizationId != null) { + + formData.put("authorization_id", this.authorizationId); + } + + if (this.id != null) { + + formData.put("id", this.id); + } + + if (this.ledgerOperationTimestamp != null) { + + formData.put("ledger_operation_timestamp", this.ledgerOperationTimestamp); + } + + if (this.metadata != null) { + + formData.put("metadata", JsonUtil.toJson(this.metadata)); + } + + return formData; + } + + /** Get the JSON string representation for this request. */ + public String toJsonString() { + return JsonUtil.toJson(toFormData()); + } + + /** Create a new builder for LedgerOperationReleaseAuthorizationParams. */ + @Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness") + public static LedgerOperationReleaseAuthorizationBuilder builder() { + return new LedgerOperationReleaseAuthorizationBuilder(); + } + + public static final class LedgerOperationReleaseAuthorizationBuilder { + + private String authorizationId; + + private String id; + + private Timestamp ledgerOperationTimestamp; + + private java.util.Map metadata; + + private LedgerOperationReleaseAuthorizationBuilder() {} + + public LedgerOperationReleaseAuthorizationBuilder authorizationId(String value) { + this.authorizationId = value; + return this; + } + + public LedgerOperationReleaseAuthorizationBuilder id(String value) { + this.id = value; + return this; + } + + public LedgerOperationReleaseAuthorizationBuilder ledgerOperationTimestamp(Timestamp value) { + this.ledgerOperationTimestamp = value; + return this; + } + + public LedgerOperationReleaseAuthorizationBuilder metadata( + java.util.Map value) { + this.metadata = value; + return this; + } + + public LedgerOperationReleaseAuthorizationParams build() { + return new LedgerOperationReleaseAuthorizationParams(this); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/params/ListLedgerOperationsParams.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/ListLedgerOperationsParams.java new file mode 100644 index 00000000..5de0838d --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/ListLedgerOperationsParams.java @@ -0,0 +1,378 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.models.ledgerOperation.params; + +import com.chargebee.v4.internal.Recommended; +import com.chargebee.v4.filters.StringFilter; +import com.chargebee.v4.filters.TimestampFilter; +import com.chargebee.v4.filters.EnumFilter; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +public final class ListLedgerOperationsParams { + + private final Map queryParams; + + private ListLedgerOperationsParams(ListLedgerOperationsBuilder builder) { + this.queryParams = Collections.unmodifiableMap(new LinkedHashMap<>(builder.queryParams)); + } + + /** Get the query parameters for this request. */ + public Map toQueryParams() { + return queryParams; + } + + public ListLedgerOperationsBuilder toBuilder() { + ListLedgerOperationsBuilder builder = new ListLedgerOperationsBuilder(); + builder.queryParams.putAll(queryParams); + return builder; + } + + /** Create a new builder for ListLedgerOperationsParams. */ + @Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness") + public static ListLedgerOperationsBuilder builder() { + return new ListLedgerOperationsBuilder(); + } + + public static final class ListLedgerOperationsBuilder { + private final Map queryParams = new LinkedHashMap<>(); + + private ListLedgerOperationsBuilder() {} + + public ListLedgerOperationsBuilder limit(Integer value) { + queryParams.put("limit", value); + return this; + } + + public ListLedgerOperationsBuilder offset(String value) { + queryParams.put("offset", value); + return this; + } + + public SubscriptionIdFilter subscriptionId() { + return new SubscriptionIdFilter("subscription_id", this, queryParams); + } + + public UnitIdFilter unitId() { + return new UnitIdFilter("unit_id", this, queryParams); + } + + public CreatedAtFilter createdAt() { + return new CreatedAtFilter("created_at", this, queryParams); + } + + public TypeFilter type() { + return new TypeFilter("type", this, queryParams); + } + + public SortBySortBuilder sortBy() { + return new SortBySortBuilder("sort_by", this); + } + + public ListLedgerOperationsParams build() { + return new ListLedgerOperationsParams(this); + } + + public static final class SubscriptionIdFilter + extends StringFilter { + SubscriptionIdFilter( + String fieldName, ListLedgerOperationsBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + + public static final class UnitIdFilter extends StringFilter { + UnitIdFilter( + String fieldName, ListLedgerOperationsBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + + public static final class CreatedAtFilter extends TimestampFilter { + CreatedAtFilter( + String fieldName, ListLedgerOperationsBuilder builder, Map params) { + super(fieldName, builder, params); + } + } + + public static final class TypeFilter extends EnumFilter { + TypeFilter( + String fieldName, ListLedgerOperationsBuilder builder, Map params) { + super(fieldName, builder, params, Type::getValue); + } + + /** + * @deprecated This method accepting raw String will be removed in a future version. Use the + * type-safe enum overload instead: + *
{@code .type().is(Type.YOUR_VALUE)}
+ * + * @see #is(Type) + */ + @Deprecated + public ListLedgerOperationsBuilder is(String value) { + params.put(fieldName + "[is]", value); + return builder; + } + + /** + * @deprecated This method accepting raw String will be removed in a future version. Use the + * type-safe enum overload instead: + *
{@code .type().isNot(Type.YOUR_VALUE)}
+ * + * @see #isNot(Type) + */ + @Deprecated + public ListLedgerOperationsBuilder isNot(String value) { + params.put(fieldName + "[is_not]", value); + return builder; + } + + /** + * @deprecated This method accepting raw String will be removed in a future version. Use the + * type-safe enum overload instead: + *
{@code .type().in(Type.VALUE1, Type.VALUE2)}
+ * + * @see #in(Type[]) + */ + @Deprecated + public ListLedgerOperationsBuilder in(String... values) { + params.put(fieldName + "[in]", "[" + String.join(",", values) + "]"); + return builder; + } + + /** + * @deprecated This method accepting raw String will be removed in a future version. Use the + * type-safe enum overload instead: + *
{@code .type().notIn(Type.VALUE1, Type.VALUE2)}
+ * + * @see #notIn(Type[]) + */ + @Deprecated + public ListLedgerOperationsBuilder notIn(String... values) { + params.put(fieldName + "[not_in]", "[" + String.join(",", values) + "]"); + return builder; + } + } + + public static final class SortBySortBuilder { + private final String fieldName; + private final ListLedgerOperationsBuilder builder; + + SortBySortBuilder(String fieldName, ListLedgerOperationsBuilder builder) { + this.fieldName = fieldName; + this.builder = builder; + } + + public SortDirection created_at() { + return new SortDirection(fieldName, "created_at", builder); + } + } + + public static final class SortDirection { + private final String fieldName; + private final String selectedField; + private final ListLedgerOperationsBuilder builder; + + SortDirection(String fieldName, String selectedField, ListLedgerOperationsBuilder builder) { + this.fieldName = fieldName; + this.selectedField = selectedField; + this.builder = builder; + } + + public ListLedgerOperationsBuilder asc() { + builder.queryParams.put(fieldName + "[asc]", selectedField); + return builder; + } + + public ListLedgerOperationsBuilder desc() { + builder.queryParams.put(fieldName + "[desc]", selectedField); + return builder; + } + } + } + + public enum TypeIs { + ALLOCATION("allocation"), + + CAPTURE("capture"), + + AUTHORIZE("authorize"), + + RELEASE_AUTHORIZATION("release_authorization"), + + CAPTURE_AUTHORIZATION("capture_authorization"), + + EXPIRY("expiry"), + + VOID("void"), + + ROLLOVER("rollover"), + + ADJUSTMENT("adjustment"), + + /** An enum member indicating that TypeIs was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + TypeIs(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static TypeIs fromString(String value) { + if (value == null) return _UNKNOWN; + for (TypeIs enumValue : TypeIs.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + + public enum TypeIn { + ALLOCATION("allocation"), + + CAPTURE("capture"), + + AUTHORIZE("authorize"), + + RELEASE_AUTHORIZATION("release_authorization"), + + CAPTURE_AUTHORIZATION("capture_authorization"), + + EXPIRY("expiry"), + + VOID("void"), + + ROLLOVER("rollover"), + + ADJUSTMENT("adjustment"), + + /** An enum member indicating that TypeIn was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + TypeIn(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static TypeIn fromString(String value) { + if (value == null) return _UNKNOWN; + for (TypeIn enumValue : TypeIn.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + + public enum SortByAsc { + CREATED_AT("created_at"), + + /** An enum member indicating that SortByAsc was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + SortByAsc(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static SortByAsc fromString(String value) { + if (value == null) return _UNKNOWN; + for (SortByAsc enumValue : SortByAsc.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + + public enum SortByDesc { + CREATED_AT("created_at"), + + /** An enum member indicating that SortByDesc was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + SortByDesc(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static SortByDesc fromString(String value) { + if (value == null) return _UNKNOWN; + for (SortByDesc enumValue : SortByDesc.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + + public enum Type { + ALLOCATION("allocation"), + + CAPTURE("capture"), + + AUTHORIZE("authorize"), + + RELEASE_AUTHORIZATION("release_authorization"), + + CAPTURE_AUTHORIZATION("capture_authorization"), + + EXPIRY("expiry"), + + VOID("void"), + + ROLLOVER("rollover"), + + ADJUSTMENT("adjustment"), + + /** An enum member indicating that Type was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + Type(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static Type fromString(String value) { + if (value == null) return _UNKNOWN; + for (Type enumValue : Type.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/params/RetrieveLedgerOperationParams.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/RetrieveLedgerOperationParams.java new file mode 100644 index 00000000..1f1c727f --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/params/RetrieveLedgerOperationParams.java @@ -0,0 +1,50 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.models.ledgerOperation.params; + +import com.chargebee.v4.internal.Recommended; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +public final class RetrieveLedgerOperationParams { + + private final Map queryParams; + + private RetrieveLedgerOperationParams(RetrieveLedgerOperationBuilder builder) { + this.queryParams = Collections.unmodifiableMap(new LinkedHashMap<>(builder.queryParams)); + } + + /** Get the query parameters for this request. */ + public Map toQueryParams() { + return queryParams; + } + + public RetrieveLedgerOperationBuilder toBuilder() { + RetrieveLedgerOperationBuilder builder = new RetrieveLedgerOperationBuilder(); + builder.queryParams.putAll(queryParams); + return builder; + } + + /** Create a new builder for RetrieveLedgerOperationParams. */ + @Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness") + public static RetrieveLedgerOperationBuilder builder() { + return new RetrieveLedgerOperationBuilder(); + } + + public static final class RetrieveLedgerOperationBuilder { + private final Map queryParams = new LinkedHashMap<>(); + + private RetrieveLedgerOperationBuilder() {} + + public RetrieveLedgerOperationParams build() { + return new RetrieveLedgerOperationParams(this); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationAuthorizeResponse.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationAuthorizeResponse.java new file mode 100644 index 00000000..6f1d6d2d --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationAuthorizeResponse.java @@ -0,0 +1,129 @@ +package com.chargebee.v4.models.ledgerOperation.responses; + +import com.chargebee.v4.models.ledgerOperation.LedgerOperation; + +import com.chargebee.v4.models.ledgerAccountBalance.LedgerAccountBalance; + +import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import com.chargebee.v4.transport.Response; + +/** + * Immutable response object for LedgerOperationAuthorize operation. Contains the response data from + * the API. + */ +public final class LedgerOperationAuthorizeResponse extends BaseResponse { + private final LedgerOperation ledgerOperation; + + private final LedgerAccountBalance ledgerAccountBalance; + + private LedgerOperationAuthorizeResponse(Builder builder) { + super(builder.httpResponse); + + this.ledgerOperation = builder.ledgerOperation; + + this.ledgerAccountBalance = builder.ledgerAccountBalance; + } + + /** Parse JSON response into LedgerOperationAuthorizeResponse object. */ + public static LedgerOperationAuthorizeResponse fromJson(String json) { + return fromJson(json, null); + } + + /** Parse JSON response into LedgerOperationAuthorizeResponse object with HTTP response. */ + public static LedgerOperationAuthorizeResponse fromJson(String json, Response httpResponse) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + Builder builder = builder(); + + JsonObject __ledgerOperationObj = JsonUtil.getJsonObject(jsonObj, "ledger_operation"); + if (__ledgerOperationObj != null) { + builder.ledgerOperation(LedgerOperation.fromJson(__ledgerOperationObj)); + } + + JsonObject __ledgerAccountBalanceObj = + JsonUtil.getJsonObject(jsonObj, "ledger_account_balance"); + if (__ledgerAccountBalanceObj != null) { + builder.ledgerAccountBalance(LedgerAccountBalance.fromJson(__ledgerAccountBalanceObj)); + } + + builder.httpResponse(httpResponse); + return builder.build(); + } catch (Exception e) { + throw new RuntimeException("Failed to parse LedgerOperationAuthorizeResponse from JSON", e); + } + } + + /** Create a new builder for LedgerOperationAuthorizeResponse. */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for LedgerOperationAuthorizeResponse. */ + public static class Builder { + + private LedgerOperation ledgerOperation; + + private LedgerAccountBalance ledgerAccountBalance; + + private Response httpResponse; + + private Builder() {} + + public Builder ledgerOperation(LedgerOperation ledgerOperation) { + this.ledgerOperation = ledgerOperation; + return this; + } + + public Builder ledgerAccountBalance(LedgerAccountBalance ledgerAccountBalance) { + this.ledgerAccountBalance = ledgerAccountBalance; + return this; + } + + public Builder httpResponse(Response httpResponse) { + this.httpResponse = httpResponse; + return this; + } + + public LedgerOperationAuthorizeResponse build() { + return new LedgerOperationAuthorizeResponse(this); + } + } + + /** Get the ledgerOperation from the response. */ + public LedgerOperation getLedgerOperation() { + return ledgerOperation; + } + + /** Get the ledgerAccountBalance from the response. */ + public LedgerAccountBalance getLedgerAccountBalance() { + return ledgerAccountBalance; + } + + @Override + public String toString() { + return "LedgerOperationAuthorizeResponse{" + + "ledgerOperation=" + + ledgerOperation + + ", ledgerAccountBalance=" + + ledgerAccountBalance + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LedgerOperationAuthorizeResponse that = (LedgerOperationAuthorizeResponse) o; + return java.util.Objects.equals(ledgerOperation, that.ledgerOperation) + && java.util.Objects.equals(ledgerAccountBalance, that.ledgerAccountBalance); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(ledgerOperation, ledgerAccountBalance); + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationCaptureAuthorizationResponse.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationCaptureAuthorizationResponse.java new file mode 100644 index 00000000..a9c3fc03 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationCaptureAuthorizationResponse.java @@ -0,0 +1,134 @@ +package com.chargebee.v4.models.ledgerOperation.responses; + +import com.chargebee.v4.models.ledgerOperation.LedgerOperation; + +import com.chargebee.v4.models.ledgerAccountBalance.LedgerAccountBalance; + +import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import com.chargebee.v4.transport.Response; + +/** + * Immutable response object for LedgerOperationCaptureAuthorization operation. Contains the + * response data from the API. + */ +public final class LedgerOperationCaptureAuthorizationResponse extends BaseResponse { + private final LedgerOperation ledgerOperation; + + private final LedgerAccountBalance ledgerAccountBalance; + + private LedgerOperationCaptureAuthorizationResponse(Builder builder) { + super(builder.httpResponse); + + this.ledgerOperation = builder.ledgerOperation; + + this.ledgerAccountBalance = builder.ledgerAccountBalance; + } + + /** Parse JSON response into LedgerOperationCaptureAuthorizationResponse object. */ + public static LedgerOperationCaptureAuthorizationResponse fromJson(String json) { + return fromJson(json, null); + } + + /** + * Parse JSON response into LedgerOperationCaptureAuthorizationResponse object with HTTP response. + */ + public static LedgerOperationCaptureAuthorizationResponse fromJson( + String json, Response httpResponse) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + Builder builder = builder(); + + JsonObject __ledgerOperationObj = JsonUtil.getJsonObject(jsonObj, "ledger_operation"); + if (__ledgerOperationObj != null) { + builder.ledgerOperation(LedgerOperation.fromJson(__ledgerOperationObj)); + } + + JsonObject __ledgerAccountBalanceObj = + JsonUtil.getJsonObject(jsonObj, "ledger_account_balance"); + if (__ledgerAccountBalanceObj != null) { + builder.ledgerAccountBalance(LedgerAccountBalance.fromJson(__ledgerAccountBalanceObj)); + } + + builder.httpResponse(httpResponse); + return builder.build(); + } catch (Exception e) { + throw new RuntimeException( + "Failed to parse LedgerOperationCaptureAuthorizationResponse from JSON", e); + } + } + + /** Create a new builder for LedgerOperationCaptureAuthorizationResponse. */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for LedgerOperationCaptureAuthorizationResponse. */ + public static class Builder { + + private LedgerOperation ledgerOperation; + + private LedgerAccountBalance ledgerAccountBalance; + + private Response httpResponse; + + private Builder() {} + + public Builder ledgerOperation(LedgerOperation ledgerOperation) { + this.ledgerOperation = ledgerOperation; + return this; + } + + public Builder ledgerAccountBalance(LedgerAccountBalance ledgerAccountBalance) { + this.ledgerAccountBalance = ledgerAccountBalance; + return this; + } + + public Builder httpResponse(Response httpResponse) { + this.httpResponse = httpResponse; + return this; + } + + public LedgerOperationCaptureAuthorizationResponse build() { + return new LedgerOperationCaptureAuthorizationResponse(this); + } + } + + /** Get the ledgerOperation from the response. */ + public LedgerOperation getLedgerOperation() { + return ledgerOperation; + } + + /** Get the ledgerAccountBalance from the response. */ + public LedgerAccountBalance getLedgerAccountBalance() { + return ledgerAccountBalance; + } + + @Override + public String toString() { + return "LedgerOperationCaptureAuthorizationResponse{" + + "ledgerOperation=" + + ledgerOperation + + ", ledgerAccountBalance=" + + ledgerAccountBalance + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LedgerOperationCaptureAuthorizationResponse that = + (LedgerOperationCaptureAuthorizationResponse) o; + return java.util.Objects.equals(ledgerOperation, that.ledgerOperation) + && java.util.Objects.equals(ledgerAccountBalance, that.ledgerAccountBalance); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(ledgerOperation, ledgerAccountBalance); + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationCaptureResponse.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationCaptureResponse.java new file mode 100644 index 00000000..72c5afd7 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationCaptureResponse.java @@ -0,0 +1,129 @@ +package com.chargebee.v4.models.ledgerOperation.responses; + +import com.chargebee.v4.models.ledgerOperation.LedgerOperation; + +import com.chargebee.v4.models.ledgerAccountBalance.LedgerAccountBalance; + +import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import com.chargebee.v4.transport.Response; + +/** + * Immutable response object for LedgerOperationCapture operation. Contains the response data from + * the API. + */ +public final class LedgerOperationCaptureResponse extends BaseResponse { + private final LedgerOperation ledgerOperation; + + private final LedgerAccountBalance ledgerAccountBalance; + + private LedgerOperationCaptureResponse(Builder builder) { + super(builder.httpResponse); + + this.ledgerOperation = builder.ledgerOperation; + + this.ledgerAccountBalance = builder.ledgerAccountBalance; + } + + /** Parse JSON response into LedgerOperationCaptureResponse object. */ + public static LedgerOperationCaptureResponse fromJson(String json) { + return fromJson(json, null); + } + + /** Parse JSON response into LedgerOperationCaptureResponse object with HTTP response. */ + public static LedgerOperationCaptureResponse fromJson(String json, Response httpResponse) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + Builder builder = builder(); + + JsonObject __ledgerOperationObj = JsonUtil.getJsonObject(jsonObj, "ledger_operation"); + if (__ledgerOperationObj != null) { + builder.ledgerOperation(LedgerOperation.fromJson(__ledgerOperationObj)); + } + + JsonObject __ledgerAccountBalanceObj = + JsonUtil.getJsonObject(jsonObj, "ledger_account_balance"); + if (__ledgerAccountBalanceObj != null) { + builder.ledgerAccountBalance(LedgerAccountBalance.fromJson(__ledgerAccountBalanceObj)); + } + + builder.httpResponse(httpResponse); + return builder.build(); + } catch (Exception e) { + throw new RuntimeException("Failed to parse LedgerOperationCaptureResponse from JSON", e); + } + } + + /** Create a new builder for LedgerOperationCaptureResponse. */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for LedgerOperationCaptureResponse. */ + public static class Builder { + + private LedgerOperation ledgerOperation; + + private LedgerAccountBalance ledgerAccountBalance; + + private Response httpResponse; + + private Builder() {} + + public Builder ledgerOperation(LedgerOperation ledgerOperation) { + this.ledgerOperation = ledgerOperation; + return this; + } + + public Builder ledgerAccountBalance(LedgerAccountBalance ledgerAccountBalance) { + this.ledgerAccountBalance = ledgerAccountBalance; + return this; + } + + public Builder httpResponse(Response httpResponse) { + this.httpResponse = httpResponse; + return this; + } + + public LedgerOperationCaptureResponse build() { + return new LedgerOperationCaptureResponse(this); + } + } + + /** Get the ledgerOperation from the response. */ + public LedgerOperation getLedgerOperation() { + return ledgerOperation; + } + + /** Get the ledgerAccountBalance from the response. */ + public LedgerAccountBalance getLedgerAccountBalance() { + return ledgerAccountBalance; + } + + @Override + public String toString() { + return "LedgerOperationCaptureResponse{" + + "ledgerOperation=" + + ledgerOperation + + ", ledgerAccountBalance=" + + ledgerAccountBalance + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LedgerOperationCaptureResponse that = (LedgerOperationCaptureResponse) o; + return java.util.Objects.equals(ledgerOperation, that.ledgerOperation) + && java.util.Objects.equals(ledgerAccountBalance, that.ledgerAccountBalance); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(ledgerOperation, ledgerAccountBalance); + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationReleaseAuthorizationResponse.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationReleaseAuthorizationResponse.java new file mode 100644 index 00000000..42bb9fbb --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/LedgerOperationReleaseAuthorizationResponse.java @@ -0,0 +1,134 @@ +package com.chargebee.v4.models.ledgerOperation.responses; + +import com.chargebee.v4.models.ledgerOperation.LedgerOperation; + +import com.chargebee.v4.models.ledgerAccountBalance.LedgerAccountBalance; + +import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import com.chargebee.v4.transport.Response; + +/** + * Immutable response object for LedgerOperationReleaseAuthorization operation. Contains the + * response data from the API. + */ +public final class LedgerOperationReleaseAuthorizationResponse extends BaseResponse { + private final LedgerOperation ledgerOperation; + + private final LedgerAccountBalance ledgerAccountBalance; + + private LedgerOperationReleaseAuthorizationResponse(Builder builder) { + super(builder.httpResponse); + + this.ledgerOperation = builder.ledgerOperation; + + this.ledgerAccountBalance = builder.ledgerAccountBalance; + } + + /** Parse JSON response into LedgerOperationReleaseAuthorizationResponse object. */ + public static LedgerOperationReleaseAuthorizationResponse fromJson(String json) { + return fromJson(json, null); + } + + /** + * Parse JSON response into LedgerOperationReleaseAuthorizationResponse object with HTTP response. + */ + public static LedgerOperationReleaseAuthorizationResponse fromJson( + String json, Response httpResponse) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + Builder builder = builder(); + + JsonObject __ledgerOperationObj = JsonUtil.getJsonObject(jsonObj, "ledger_operation"); + if (__ledgerOperationObj != null) { + builder.ledgerOperation(LedgerOperation.fromJson(__ledgerOperationObj)); + } + + JsonObject __ledgerAccountBalanceObj = + JsonUtil.getJsonObject(jsonObj, "ledger_account_balance"); + if (__ledgerAccountBalanceObj != null) { + builder.ledgerAccountBalance(LedgerAccountBalance.fromJson(__ledgerAccountBalanceObj)); + } + + builder.httpResponse(httpResponse); + return builder.build(); + } catch (Exception e) { + throw new RuntimeException( + "Failed to parse LedgerOperationReleaseAuthorizationResponse from JSON", e); + } + } + + /** Create a new builder for LedgerOperationReleaseAuthorizationResponse. */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for LedgerOperationReleaseAuthorizationResponse. */ + public static class Builder { + + private LedgerOperation ledgerOperation; + + private LedgerAccountBalance ledgerAccountBalance; + + private Response httpResponse; + + private Builder() {} + + public Builder ledgerOperation(LedgerOperation ledgerOperation) { + this.ledgerOperation = ledgerOperation; + return this; + } + + public Builder ledgerAccountBalance(LedgerAccountBalance ledgerAccountBalance) { + this.ledgerAccountBalance = ledgerAccountBalance; + return this; + } + + public Builder httpResponse(Response httpResponse) { + this.httpResponse = httpResponse; + return this; + } + + public LedgerOperationReleaseAuthorizationResponse build() { + return new LedgerOperationReleaseAuthorizationResponse(this); + } + } + + /** Get the ledgerOperation from the response. */ + public LedgerOperation getLedgerOperation() { + return ledgerOperation; + } + + /** Get the ledgerAccountBalance from the response. */ + public LedgerAccountBalance getLedgerAccountBalance() { + return ledgerAccountBalance; + } + + @Override + public String toString() { + return "LedgerOperationReleaseAuthorizationResponse{" + + "ledgerOperation=" + + ledgerOperation + + ", ledgerAccountBalance=" + + ledgerAccountBalance + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LedgerOperationReleaseAuthorizationResponse that = + (LedgerOperationReleaseAuthorizationResponse) o; + return java.util.Objects.equals(ledgerOperation, that.ledgerOperation) + && java.util.Objects.equals(ledgerAccountBalance, that.ledgerAccountBalance); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(ledgerOperation, ledgerAccountBalance); + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/ListLedgerOperationsResponse.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/ListLedgerOperationsResponse.java new file mode 100644 index 00000000..4a1c4796 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/ListLedgerOperationsResponse.java @@ -0,0 +1,217 @@ +package com.chargebee.v4.models.ledgerOperation.responses; + +import java.util.List; + +import com.chargebee.v4.models.ledgerOperation.LedgerOperation; + +import com.chargebee.v4.exceptions.ChargebeeException; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import com.chargebee.v4.transport.Response; +import com.chargebee.v4.services.LedgerOperationService; +import com.chargebee.v4.models.ledgerOperation.params.ListLedgerOperationsParams; + +/** Immutable response object for ListLedgerOperations operation. Contains paginated list data. */ +public final class ListLedgerOperationsResponse { + + private final List list; + + private final String nextOffset; + + private final LedgerOperationService service; + private final ListLedgerOperationsParams originalParams; + private final Response httpResponse; + + private ListLedgerOperationsResponse( + List list, + String nextOffset, + LedgerOperationService service, + ListLedgerOperationsParams originalParams, + Response httpResponse) { + + this.list = list; + + this.nextOffset = nextOffset; + + this.service = service; + this.originalParams = originalParams; + this.httpResponse = httpResponse; + } + + /** + * Parse JSON response into ListLedgerOperationsResponse object (no service context). Use this + * when you only need to read a single page (no nextPage()). + */ + public static ListLedgerOperationsResponse fromJson(String json) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + + List list = + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + LedgerOperationListLedgerOperationsItem::fromJson); + + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); + + return new ListLedgerOperationsResponse(list, nextOffset, null, null, null); + } catch (Exception e) { + throw new RuntimeException("Failed to parse ListLedgerOperationsResponse from JSON", e); + } + } + + /** + * Parse JSON response into ListLedgerOperationsResponse object with service context for + * pagination (enables nextPage()). + */ + public static ListLedgerOperationsResponse fromJson( + String json, + LedgerOperationService service, + ListLedgerOperationsParams originalParams, + Response httpResponse) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + + List list = + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + LedgerOperationListLedgerOperationsItem::fromJson); + + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); + + return new ListLedgerOperationsResponse( + list, nextOffset, service, originalParams, httpResponse); + } catch (Exception e) { + throw new RuntimeException("Failed to parse ListLedgerOperationsResponse from JSON", e); + } + } + + /** Get the list from the response. */ + public List getList() { + return list; + } + + /** Get the nextOffset from the response. */ + public String getNextOffset() { + return nextOffset; + } + + /** Check if there are more pages available. */ + public boolean hasNextPage() { + return nextOffset != null && !nextOffset.isEmpty(); + } + + /** + * Get the next page of results. + * + * @throws ChargebeeException if unable to fetch next page + */ + public ListLedgerOperationsResponse nextPage() throws ChargebeeException { + if (!hasNextPage()) { + throw new IllegalStateException("No more pages available"); + } + if (service == null) { + throw new UnsupportedOperationException( + "nextPage() requires service context. Use fromJson(json, service, originalParams, httpResponse)."); + } + + ListLedgerOperationsParams nextParams = + (originalParams != null ? originalParams.toBuilder() : ListLedgerOperationsParams.builder()) + .offset(nextOffset) + .build(); + + return service.listLedgerOperations(nextParams); + } + + /** Get the raw response payload as JSON string. */ + public String responsePayload() { + return httpResponse != null ? httpResponse.getBodyAsString() : null; + } + + /** Get the HTTP status code. */ + public int httpStatus() { + return httpResponse != null ? httpResponse.getStatusCode() : 0; + } + + /** Get response headers. */ + public java.util.Map> headers() { + return httpResponse != null ? httpResponse.getHeaders() : java.util.Collections.emptyMap(); + } + + /** Get a specific header value. */ + public java.util.List header(String name) { + if (httpResponse == null) return null; + return httpResponse.getHeaders().entrySet().stream() + .filter(e -> e.getKey().equalsIgnoreCase(name)) + .map(java.util.Map.Entry::getValue) + .findFirst() + .orElse(null); + } + + @Override + public String toString() { + return "ListLedgerOperationsResponse{" + "list=" + list + ", nextOffset=" + nextOffset + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ListLedgerOperationsResponse that = (ListLedgerOperationsResponse) o; + return java.util.Objects.equals(list, that.list) + && java.util.Objects.equals(nextOffset, that.nextOffset); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(list, nextOffset); + } + + public static class LedgerOperationListLedgerOperationsItem { + + private LedgerOperation ledgerOperation; + + public LedgerOperation getLedgerOperation() { + return ledgerOperation; + } + + public static LedgerOperationListLedgerOperationsItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LedgerOperationListLedgerOperationsItem fromJson(JsonObject jsonObj) { + LedgerOperationListLedgerOperationsItem item = new LedgerOperationListLedgerOperationsItem(); + + JsonObject __ledgerOperationObj = JsonUtil.getJsonObject(jsonObj, "ledger_operation"); + if (__ledgerOperationObj != null) { + item.ledgerOperation = LedgerOperation.fromJson(__ledgerOperationObj); + } + + return item; + } + + @Override + public String toString() { + return "LedgerOperationListLedgerOperationsItem{" + + "ledgerOperation=" + + ledgerOperation + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LedgerOperationListLedgerOperationsItem that = (LedgerOperationListLedgerOperationsItem) o; + return java.util.Objects.equals(ledgerOperation, that.ledgerOperation); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(ledgerOperation); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/RetrieveLedgerOperationResponse.java b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/RetrieveLedgerOperationResponse.java new file mode 100644 index 00000000..dd22ce80 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/ledgerOperation/responses/RetrieveLedgerOperationResponse.java @@ -0,0 +1,99 @@ +package com.chargebee.v4.models.ledgerOperation.responses; + +import com.chargebee.v4.models.ledgerOperation.LedgerOperation; + +import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import com.chargebee.v4.transport.Response; + +/** + * Immutable response object for RetrieveLedgerOperation operation. Contains the response data from + * a single resource get operation. + */ +public final class RetrieveLedgerOperationResponse extends BaseResponse { + private final LedgerOperation ledgerOperation; + + private RetrieveLedgerOperationResponse(Builder builder) { + super(builder.httpResponse); + + this.ledgerOperation = builder.ledgerOperation; + } + + /** Parse JSON response into RetrieveLedgerOperationResponse object. */ + public static RetrieveLedgerOperationResponse fromJson(String json) { + return fromJson(json, null); + } + + /** Parse JSON response into RetrieveLedgerOperationResponse object with HTTP response. */ + public static RetrieveLedgerOperationResponse fromJson(String json, Response httpResponse) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + Builder builder = builder(); + + JsonObject __ledgerOperationObj = JsonUtil.getJsonObject(jsonObj, "ledger_operation"); + if (__ledgerOperationObj != null) { + builder.ledgerOperation(LedgerOperation.fromJson(__ledgerOperationObj)); + } + + builder.httpResponse(httpResponse); + return builder.build(); + } catch (Exception e) { + throw new RuntimeException("Failed to parse RetrieveLedgerOperationResponse from JSON", e); + } + } + + /** Create a new builder for RetrieveLedgerOperationResponse. */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for RetrieveLedgerOperationResponse. */ + public static class Builder { + + private LedgerOperation ledgerOperation; + + private Response httpResponse; + + private Builder() {} + + public Builder ledgerOperation(LedgerOperation ledgerOperation) { + this.ledgerOperation = ledgerOperation; + return this; + } + + public Builder httpResponse(Response httpResponse) { + this.httpResponse = httpResponse; + return this; + } + + public RetrieveLedgerOperationResponse build() { + return new RetrieveLedgerOperationResponse(this); + } + } + + /** Get the ledgerOperation from the response. */ + public LedgerOperation getLedgerOperation() { + return ledgerOperation; + } + + @Override + public String toString() { + return "RetrieveLedgerOperationResponse{" + "ledgerOperation=" + ledgerOperation + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + RetrieveLedgerOperationResponse that = (RetrieveLedgerOperationResponse) o; + return java.util.Objects.equals(ledgerOperation, that.ledgerOperation); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(ledgerOperation); + } +} diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/params/OmnichannelSubscriptionListParams.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/params/OmnichannelSubscriptionListParams.java index d541976d..08c17b55 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/params/OmnichannelSubscriptionListParams.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/params/OmnichannelSubscriptionListParams.java @@ -80,6 +80,10 @@ public PurchasedAtFilter purchasedAt() { return new PurchasedAtFilter("purchased_at", this, queryParams); } + public SortBySortBuilder sortBy() { + return new SortBySortBuilder("sort_by", this); + } + public OmnichannelSubscriptionListBuilder omnichannelSubscriptionItem( OmnichannelSubscriptionItemParams value) { queryParams.put("omnichannel_subscription_item", value); @@ -200,6 +204,47 @@ public static final class PurchasedAtFilter super(fieldName, builder, params); } } + + public static final class SortBySortBuilder { + private final String fieldName; + private final OmnichannelSubscriptionListBuilder builder; + + SortBySortBuilder(String fieldName, OmnichannelSubscriptionListBuilder builder) { + this.fieldName = fieldName; + this.builder = builder; + } + + public SortDirection created_at() { + return new SortDirection(fieldName, "created_at", builder); + } + + public SortDirection updated_at() { + return new SortDirection(fieldName, "updated_at", builder); + } + } + + public static final class SortDirection { + private final String fieldName; + private final String selectedField; + private final OmnichannelSubscriptionListBuilder builder; + + SortDirection( + String fieldName, String selectedField, OmnichannelSubscriptionListBuilder builder) { + this.fieldName = fieldName; + this.selectedField = selectedField; + this.builder = builder; + } + + public OmnichannelSubscriptionListBuilder asc() { + builder.queryParams.put(fieldName + "[asc]", selectedField); + return builder; + } + + public OmnichannelSubscriptionListBuilder desc() { + builder.queryParams.put(fieldName + "[desc]", selectedField); + return builder; + } + } } public enum SourceIs { @@ -314,6 +359,62 @@ public static SourceNotIn fromString(String value) { } } + public enum SortByAsc { + CREATED_AT("created_at"), + + UPDATED_AT("updated_at"), + + /** An enum member indicating that SortByAsc was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + SortByAsc(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static SortByAsc fromString(String value) { + if (value == null) return _UNKNOWN; + for (SortByAsc enumValue : SortByAsc.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + + public enum SortByDesc { + CREATED_AT("created_at"), + + UPDATED_AT("updated_at"), + + /** An enum member indicating that SortByDesc was instantiated with an unknown value. */ + _UNKNOWN(null); + private final String value; + + SortByDesc(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static SortByDesc fromString(String value) { + if (value == null) return _UNKNOWN; + for (SortByDesc enumValue : SortByDesc.values()) { + if (enumValue.value != null && enumValue.value.equals(value)) { + return enumValue; + } + } + return _UNKNOWN; + } + } + public enum Source { APPLE_APP_STORE("apple_app_store"), diff --git a/src/main/java/com/chargebee/v4/models/promotionalGrant/PromotionalGrant.java b/src/main/java/com/chargebee/v4/models/promotionalGrant/PromotionalGrant.java new file mode 100644 index 00000000..a4af910f --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/promotionalGrant/PromotionalGrant.java @@ -0,0 +1,100 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.models.promotionalGrant; + +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import java.sql.Timestamp; + +public class PromotionalGrant { + + private String subscriptionId; + private String unitId; + private String amount; + private Timestamp expiresAt; + private String metadata; + + public String getSubscriptionId() { + return subscriptionId; + } + + public String getUnitId() { + return unitId; + } + + public String getAmount() { + return amount; + } + + public Timestamp getExpiresAt() { + return expiresAt; + } + + public String getMetadata() { + return metadata; + } + + public static PromotionalGrant fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PromotionalGrant fromJson(java.util.Map map) { + return fromJson(JsonUtil.toJson(map)); + } + + public static PromotionalGrant fromJson(JsonObject jsonObj) { + PromotionalGrant obj = new PromotionalGrant(); + + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); + + obj.unitId = JsonUtil.getString(jsonObj, "unit_id"); + + obj.amount = JsonUtil.getString(jsonObj, "amount"); + + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); + + obj.metadata = JsonUtil.getString(jsonObj, "metadata"); + + return obj; + } + + @Override + public String toString() { + return "PromotionalGrant{" + + "subscriptionId=" + + subscriptionId + + ", unitId=" + + unitId + + ", amount=" + + amount + + ", expiresAt=" + + expiresAt + + ", metadata=" + + metadata + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PromotionalGrant that = (PromotionalGrant) o; + return java.util.Objects.equals(subscriptionId, that.subscriptionId) + && java.util.Objects.equals(unitId, that.unitId) + && java.util.Objects.equals(amount, that.amount) + && java.util.Objects.equals(expiresAt, that.expiresAt) + && java.util.Objects.equals(metadata, that.metadata); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(subscriptionId, unitId, amount, expiresAt, metadata); + } +} diff --git a/src/main/java/com/chargebee/v4/models/promotionalGrant/params/PromotionalGrantsParams.java b/src/main/java/com/chargebee/v4/models/promotionalGrant/params/PromotionalGrantsParams.java new file mode 100644 index 00000000..b60db290 --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/promotionalGrant/params/PromotionalGrantsParams.java @@ -0,0 +1,147 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ +package com.chargebee.v4.models.promotionalGrant.params; + +import com.chargebee.v4.internal.Recommended; +import com.chargebee.v4.internal.JsonUtil; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.sql.Timestamp; + +public final class PromotionalGrantsParams { + + private final String subscriptionId; + + private final String unitId; + + private final String amount; + + private final Timestamp expiresAt; + + private final java.util.Map metadata; + + private PromotionalGrantsParams(PromotionalGrantsBuilder builder) { + + this.subscriptionId = builder.subscriptionId; + + this.unitId = builder.unitId; + + this.amount = builder.amount; + + this.expiresAt = builder.expiresAt; + + this.metadata = builder.metadata; + } + + public String getSubscriptionId() { + return subscriptionId; + } + + public String getUnitId() { + return unitId; + } + + public String getAmount() { + return amount; + } + + public Timestamp getExpiresAt() { + return expiresAt; + } + + public java.util.Map getMetadata() { + return metadata; + } + + /** Get the form data for this request. */ + public Map toFormData() { + Map formData = new LinkedHashMap<>(); + + if (this.subscriptionId != null) { + + formData.put("subscription_id", this.subscriptionId); + } + + if (this.unitId != null) { + + formData.put("unit_id", this.unitId); + } + + if (this.amount != null) { + + formData.put("amount", this.amount); + } + + if (this.expiresAt != null) { + + formData.put("expires_at", this.expiresAt); + } + + if (this.metadata != null) { + + formData.put("metadata", JsonUtil.toJson(this.metadata)); + } + + return formData; + } + + /** Get the JSON string representation for this request. */ + public String toJsonString() { + return JsonUtil.toJson(toFormData()); + } + + /** Create a new builder for PromotionalGrantsParams. */ + @Recommended(reason = "Preferred for reusability, validation, and LLM-friendliness") + public static PromotionalGrantsBuilder builder() { + return new PromotionalGrantsBuilder(); + } + + public static final class PromotionalGrantsBuilder { + + private String subscriptionId; + + private String unitId; + + private String amount; + + private Timestamp expiresAt; + + private java.util.Map metadata; + + private PromotionalGrantsBuilder() {} + + public PromotionalGrantsBuilder subscriptionId(String value) { + this.subscriptionId = value; + return this; + } + + public PromotionalGrantsBuilder unitId(String value) { + this.unitId = value; + return this; + } + + public PromotionalGrantsBuilder amount(String value) { + this.amount = value; + return this; + } + + public PromotionalGrantsBuilder expiresAt(Timestamp value) { + this.expiresAt = value; + return this; + } + + public PromotionalGrantsBuilder metadata(java.util.Map value) { + this.metadata = value; + return this; + } + + public PromotionalGrantsParams build() { + return new PromotionalGrantsParams(this); + } + } +} diff --git a/src/main/java/com/chargebee/v4/models/promotionalGrant/responses/PromotionalGrantsResponse.java b/src/main/java/com/chargebee/v4/models/promotionalGrant/responses/PromotionalGrantsResponse.java new file mode 100644 index 00000000..859d1dfc --- /dev/null +++ b/src/main/java/com/chargebee/v4/models/promotionalGrant/responses/PromotionalGrantsResponse.java @@ -0,0 +1,127 @@ +package com.chargebee.v4.models.promotionalGrant.responses; + +import java.util.List; + +import com.chargebee.v4.models.ledgerOperation.LedgerOperation; + +import com.chargebee.v4.models.grantBlock.GrantBlock; + +import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; +import com.chargebee.v4.transport.Response; + +/** + * Immutable response object for PromotionalGrants operation. Contains the response data from the + * API. + */ +public final class PromotionalGrantsResponse extends BaseResponse { + private final List ledgerOperations; + + private final List grantBlocks; + + private PromotionalGrantsResponse(Builder builder) { + super(builder.httpResponse); + + this.ledgerOperations = builder.ledgerOperations; + + this.grantBlocks = builder.grantBlocks; + } + + /** Parse JSON response into PromotionalGrantsResponse object. */ + public static PromotionalGrantsResponse fromJson(String json) { + return fromJson(json, null); + } + + /** Parse JSON response into PromotionalGrantsResponse object with HTTP response. */ + public static PromotionalGrantsResponse fromJson(String json, Response httpResponse) { + try { + JsonObject jsonObj = JsonUtil.parse(json); + Builder builder = builder(); + + builder.ledgerOperations( + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "ledger_operations"), LedgerOperation::fromJson)); + + builder.grantBlocks( + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "grant_blocks"), GrantBlock::fromJson)); + + builder.httpResponse(httpResponse); + return builder.build(); + } catch (Exception e) { + throw new RuntimeException("Failed to parse PromotionalGrantsResponse from JSON", e); + } + } + + /** Create a new builder for PromotionalGrantsResponse. */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for PromotionalGrantsResponse. */ + public static class Builder { + + private List ledgerOperations; + + private List grantBlocks; + + private Response httpResponse; + + private Builder() {} + + public Builder ledgerOperations(List ledgerOperations) { + this.ledgerOperations = ledgerOperations; + return this; + } + + public Builder grantBlocks(List grantBlocks) { + this.grantBlocks = grantBlocks; + return this; + } + + public Builder httpResponse(Response httpResponse) { + this.httpResponse = httpResponse; + return this; + } + + public PromotionalGrantsResponse build() { + return new PromotionalGrantsResponse(this); + } + } + + /** Get the ledgerOperations from the response. */ + public List getLedgerOperations() { + return ledgerOperations; + } + + /** Get the grantBlocks from the response. */ + public List getGrantBlocks() { + return grantBlocks; + } + + @Override + public String toString() { + return "PromotionalGrantsResponse{" + + "ledgerOperations=" + + ledgerOperations + + ", grantBlocks=" + + grantBlocks + + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PromotionalGrantsResponse that = (PromotionalGrantsResponse) o; + return java.util.Objects.equals(ledgerOperations, that.ledgerOperations) + && java.util.Objects.equals(grantBlocks, that.grantBlocks); + } + + @Override + public int hashCode() { + + return java.util.Objects.hash(ledgerOperations, grantBlocks); + } +} diff --git a/src/main/java/com/chargebee/v4/models/ramp/params/RampListParams.java b/src/main/java/com/chargebee/v4/models/ramp/params/RampListParams.java index 2fe4523f..3d48cea1 100644 --- a/src/main/java/com/chargebee/v4/models/ramp/params/RampListParams.java +++ b/src/main/java/com/chargebee/v4/models/ramp/params/RampListParams.java @@ -202,7 +202,7 @@ public RampListBuilder desc() { } } - public enum StatusIn { + public enum StatusIs { SCHEDULED("scheduled"), SUCCEEDED("succeeded"), @@ -211,11 +211,11 @@ public enum StatusIn { DRAFT("draft"), - /** An enum member indicating that StatusIn was instantiated with an unknown value. */ + /** An enum member indicating that StatusIs was instantiated with an unknown value. */ _UNKNOWN(null); private final String value; - StatusIn(String value) { + StatusIs(String value) { this.value = value; } @@ -223,9 +223,9 @@ public String getValue() { return value; } - public static StatusIn fromString(String value) { + public static StatusIs fromString(String value) { if (value == null) return _UNKNOWN; - for (StatusIn enumValue : StatusIn.values()) { + for (StatusIs enumValue : StatusIs.values()) { if (enumValue.value != null && enumValue.value.equals(value)) { return enumValue; } @@ -234,7 +234,7 @@ public static StatusIn fromString(String value) { } } - public enum StatusIs { + public enum StatusIn { SCHEDULED("scheduled"), SUCCEEDED("succeeded"), @@ -243,11 +243,11 @@ public enum StatusIs { DRAFT("draft"), - /** An enum member indicating that StatusIs was instantiated with an unknown value. */ + /** An enum member indicating that StatusIn was instantiated with an unknown value. */ _UNKNOWN(null); private final String value; - StatusIs(String value) { + StatusIn(String value) { this.value = value; } @@ -255,9 +255,9 @@ public String getValue() { return value; } - public static StatusIs fromString(String value) { + public static StatusIn fromString(String value) { if (value == null) return _UNKNOWN; - for (StatusIs enumValue : StatusIs.values()) { + for (StatusIn enumValue : StatusIn.values()) { if (enumValue.value != null && enumValue.value.equals(value)) { return enumValue; } diff --git a/src/main/java/com/chargebee/v4/services/GrantBlockService.java b/src/main/java/com/chargebee/v4/services/GrantBlockService.java new file mode 100644 index 00000000..20870d59 --- /dev/null +++ b/src/main/java/com/chargebee/v4/services/GrantBlockService.java @@ -0,0 +1,110 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.services; + +import com.chargebee.v4.client.ChargebeeClient; +import com.chargebee.v4.client.request.RequestOptions; +import com.chargebee.v4.exceptions.ChargebeeException; +import com.chargebee.v4.transport.Response; +import java.util.concurrent.CompletableFuture; + +import com.chargebee.v4.models.grantBlock.params.ListGrantBlocksParams; + +import com.chargebee.v4.models.grantBlock.responses.ListGrantBlocksResponse; + +public final class GrantBlockService extends BaseService { + + private final ServiceConfig config; + + public GrantBlockService(ChargebeeClient client) { + super(client); + this.config = ServiceConfig.defaultConfig(); + } + + private GrantBlockService(ChargebeeClient client, RequestOptions options) { + super(client, options); + this.config = ServiceConfig.defaultConfig(); + } + + private GrantBlockService(ChargebeeClient client, RequestOptions options, ServiceConfig config) { + super(client, options); + this.config = config; + } + + @Override + GrantBlockService with(RequestOptions newOptions) { + return new GrantBlockService(client, newOptions, config); + } + + /** + * Apply per-request options for this service instance. Users can chain .withOptions or .options + * to set headers and other options. + */ + public GrantBlockService withOptions(RequestOptions options) { + return with(options); + } + + // === Operations === + + /** + * listGrantBlocks a grantBlock using immutable params (executes immediately) - returns raw + * Response. + */ + Response listGrantBlocksRaw(ListGrantBlocksParams params) throws ChargebeeException { + + return get("/grant_blocks", params != null ? params.toQueryParams() : null); + } + + /** listGrantBlocks a grantBlock without params (executes immediately) - returns raw Response. */ + Response listGrantBlocksRaw() throws ChargebeeException { + + return get("/grant_blocks", null); + } + + /** + * listGrantBlocks a grantBlock using raw JSON payload (executes immediately) - returns raw + * Response. + */ + Response listGrantBlocksRaw(String jsonPayload) throws ChargebeeException { + + throw new UnsupportedOperationException("JSON payload not supported for GET operations"); + } + + public ListGrantBlocksResponse listGrantBlocks(ListGrantBlocksParams params) + throws ChargebeeException { + Response response = listGrantBlocksRaw(params); + + return ListGrantBlocksResponse.fromJson(response.getBodyAsString(), this, params, response); + } + + /** Async variant of listGrantBlocks for grantBlock with params. */ + public CompletableFuture listGrantBlocksAsync( + ListGrantBlocksParams params) { + + return getAsync("/grant_blocks", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ListGrantBlocksResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + + public ListGrantBlocksResponse listGrantBlocks() throws ChargebeeException { + Response response = listGrantBlocksRaw(); + + return ListGrantBlocksResponse.fromJson(response.getBodyAsString(), this, null, response); + } + + /** Async variant of listGrantBlocks for grantBlock without params. */ + public CompletableFuture listGrantBlocksAsync() { + + return getAsync("/grant_blocks", null) + .thenApply( + response -> + ListGrantBlocksResponse.fromJson(response.getBodyAsString(), this, null, response)); + } +} diff --git a/src/main/java/com/chargebee/v4/services/LedgerAccountBalanceService.java b/src/main/java/com/chargebee/v4/services/LedgerAccountBalanceService.java new file mode 100644 index 00000000..e1a895c7 --- /dev/null +++ b/src/main/java/com/chargebee/v4/services/LedgerAccountBalanceService.java @@ -0,0 +1,118 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.services; + +import com.chargebee.v4.client.ChargebeeClient; +import com.chargebee.v4.client.request.RequestOptions; +import com.chargebee.v4.exceptions.ChargebeeException; +import com.chargebee.v4.transport.Response; +import java.util.concurrent.CompletableFuture; + +import com.chargebee.v4.models.ledgerAccountBalance.params.ListLedgerAccountBalancesParams; + +import com.chargebee.v4.models.ledgerAccountBalance.responses.ListLedgerAccountBalancesResponse; + +public final class LedgerAccountBalanceService extends BaseService { + + private final ServiceConfig config; + + public LedgerAccountBalanceService(ChargebeeClient client) { + super(client); + this.config = ServiceConfig.defaultConfig(); + } + + private LedgerAccountBalanceService(ChargebeeClient client, RequestOptions options) { + super(client, options); + this.config = ServiceConfig.defaultConfig(); + } + + private LedgerAccountBalanceService( + ChargebeeClient client, RequestOptions options, ServiceConfig config) { + super(client, options); + this.config = config; + } + + @Override + LedgerAccountBalanceService with(RequestOptions newOptions) { + return new LedgerAccountBalanceService(client, newOptions, config); + } + + /** + * Apply per-request options for this service instance. Users can chain .withOptions or .options + * to set headers and other options. + */ + public LedgerAccountBalanceService withOptions(RequestOptions options) { + return with(options); + } + + // === Operations === + + /** + * listLedgerAccountBalances a ledgerAccountBalance using immutable params (executes immediately) + * - returns raw Response. + */ + Response listLedgerAccountBalancesRaw(ListLedgerAccountBalancesParams params) + throws ChargebeeException { + + return get("/ledger_account_balances", params != null ? params.toQueryParams() : null); + } + + /** + * listLedgerAccountBalances a ledgerAccountBalance without params (executes immediately) - + * returns raw Response. + */ + Response listLedgerAccountBalancesRaw() throws ChargebeeException { + + return get("/ledger_account_balances", null); + } + + /** + * listLedgerAccountBalances a ledgerAccountBalance using raw JSON payload (executes immediately) + * - returns raw Response. + */ + Response listLedgerAccountBalancesRaw(String jsonPayload) throws ChargebeeException { + + throw new UnsupportedOperationException("JSON payload not supported for GET operations"); + } + + public ListLedgerAccountBalancesResponse listLedgerAccountBalances( + ListLedgerAccountBalancesParams params) throws ChargebeeException { + Response response = listLedgerAccountBalancesRaw(params); + + return ListLedgerAccountBalancesResponse.fromJson( + response.getBodyAsString(), this, params, response); + } + + /** Async variant of listLedgerAccountBalances for ledgerAccountBalance with params. */ + public CompletableFuture listLedgerAccountBalancesAsync( + ListLedgerAccountBalancesParams params) { + + return getAsync("/ledger_account_balances", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ListLedgerAccountBalancesResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + + public ListLedgerAccountBalancesResponse listLedgerAccountBalances() throws ChargebeeException { + Response response = listLedgerAccountBalancesRaw(); + + return ListLedgerAccountBalancesResponse.fromJson( + response.getBodyAsString(), this, null, response); + } + + /** Async variant of listLedgerAccountBalances for ledgerAccountBalance without params. */ + public CompletableFuture listLedgerAccountBalancesAsync() { + + return getAsync("/ledger_account_balances", null) + .thenApply( + response -> + ListLedgerAccountBalancesResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } +} diff --git a/src/main/java/com/chargebee/v4/services/LedgerOperationService.java b/src/main/java/com/chargebee/v4/services/LedgerOperationService.java new file mode 100644 index 00000000..32afe9eb --- /dev/null +++ b/src/main/java/com/chargebee/v4/services/LedgerOperationService.java @@ -0,0 +1,314 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.services; + +import com.chargebee.v4.client.ChargebeeClient; +import com.chargebee.v4.client.request.RequestOptions; +import com.chargebee.v4.exceptions.ChargebeeException; +import com.chargebee.v4.transport.Response; +import java.util.concurrent.CompletableFuture; + +import com.chargebee.v4.models.ledgerOperation.params.LedgerOperationReleaseAuthorizationParams; + +import com.chargebee.v4.models.ledgerOperation.params.LedgerOperationCaptureParams; + +import com.chargebee.v4.models.ledgerOperation.params.LedgerOperationAuthorizeParams; + +import com.chargebee.v4.models.ledgerOperation.params.ListLedgerOperationsParams; + +import com.chargebee.v4.models.ledgerOperation.params.LedgerOperationCaptureAuthorizationParams; + +import com.chargebee.v4.models.ledgerOperation.responses.LedgerOperationReleaseAuthorizationResponse; + +import com.chargebee.v4.models.ledgerOperation.responses.LedgerOperationCaptureResponse; + +import com.chargebee.v4.models.ledgerOperation.responses.LedgerOperationAuthorizeResponse; + +import com.chargebee.v4.models.ledgerOperation.responses.ListLedgerOperationsResponse; + +import com.chargebee.v4.models.ledgerOperation.responses.LedgerOperationCaptureAuthorizationResponse; + +import com.chargebee.v4.models.ledgerOperation.responses.RetrieveLedgerOperationResponse; + +public final class LedgerOperationService extends BaseService { + + private final ServiceConfig config; + + public LedgerOperationService(ChargebeeClient client) { + super(client); + this.config = ServiceConfig.defaultConfig(); + } + + private LedgerOperationService(ChargebeeClient client, RequestOptions options) { + super(client, options); + this.config = ServiceConfig.defaultConfig(); + } + + private LedgerOperationService( + ChargebeeClient client, RequestOptions options, ServiceConfig config) { + super(client, options); + this.config = config; + } + + @Override + LedgerOperationService with(RequestOptions newOptions) { + return new LedgerOperationService(client, newOptions, config); + } + + /** + * Apply per-request options for this service instance. Users can chain .withOptions or .options + * to set headers and other options. + */ + public LedgerOperationService withOptions(RequestOptions options) { + return with(options); + } + + // === Operations === + + /** + * releaseAuthorization a ledgerOperation using immutable params (executes immediately) - returns + * raw Response. + */ + Response releaseAuthorizationRaw(LedgerOperationReleaseAuthorizationParams params) + throws ChargebeeException { + + return postJson( + "/ledger_operations/release_authorization", params != null ? params.toJsonString() : null); + } + + /** + * releaseAuthorization a ledgerOperation using raw JSON payload (executes immediately) - returns + * raw Response. + */ + Response releaseAuthorizationRaw(String jsonPayload) throws ChargebeeException { + + return postJson("/ledger_operations/release_authorization", jsonPayload); + } + + public LedgerOperationReleaseAuthorizationResponse releaseAuthorization( + LedgerOperationReleaseAuthorizationParams params) throws ChargebeeException { + Response response = releaseAuthorizationRaw(params); + + return LedgerOperationReleaseAuthorizationResponse.fromJson( + response.getBodyAsString(), response); + } + + /** Async variant of releaseAuthorization for ledgerOperation with params. */ + public CompletableFuture releaseAuthorizationAsync( + LedgerOperationReleaseAuthorizationParams params) { + + return postJsonAsync( + "/ledger_operations/release_authorization", + params != null ? params.toJsonString() : null) + .thenApply( + response -> + LedgerOperationReleaseAuthorizationResponse.fromJson( + response.getBodyAsString(), response)); + } + + /** + * capture a ledgerOperation using immutable params (executes immediately) - returns raw Response. + */ + Response captureRaw(LedgerOperationCaptureParams params) throws ChargebeeException { + + return postJson("/ledger_operations/capture", params != null ? params.toJsonString() : null); + } + + /** + * capture a ledgerOperation using raw JSON payload (executes immediately) - returns raw Response. + */ + Response captureRaw(String jsonPayload) throws ChargebeeException { + + return postJson("/ledger_operations/capture", jsonPayload); + } + + public LedgerOperationCaptureResponse capture(LedgerOperationCaptureParams params) + throws ChargebeeException { + Response response = captureRaw(params); + + return LedgerOperationCaptureResponse.fromJson(response.getBodyAsString(), response); + } + + /** Async variant of capture for ledgerOperation with params. */ + public CompletableFuture captureAsync( + LedgerOperationCaptureParams params) { + + return postJsonAsync( + "/ledger_operations/capture", params != null ? params.toJsonString() : null) + .thenApply( + response -> + LedgerOperationCaptureResponse.fromJson(response.getBodyAsString(), response)); + } + + /** + * authorize a ledgerOperation using immutable params (executes immediately) - returns raw + * Response. + */ + Response authorizeRaw(LedgerOperationAuthorizeParams params) throws ChargebeeException { + + return postJson("/ledger_operations/authorize", params != null ? params.toJsonString() : null); + } + + /** + * authorize a ledgerOperation using raw JSON payload (executes immediately) - returns raw + * Response. + */ + Response authorizeRaw(String jsonPayload) throws ChargebeeException { + + return postJson("/ledger_operations/authorize", jsonPayload); + } + + public LedgerOperationAuthorizeResponse authorize(LedgerOperationAuthorizeParams params) + throws ChargebeeException { + Response response = authorizeRaw(params); + + return LedgerOperationAuthorizeResponse.fromJson(response.getBodyAsString(), response); + } + + /** Async variant of authorize for ledgerOperation with params. */ + public CompletableFuture authorizeAsync( + LedgerOperationAuthorizeParams params) { + + return postJsonAsync( + "/ledger_operations/authorize", params != null ? params.toJsonString() : null) + .thenApply( + response -> + LedgerOperationAuthorizeResponse.fromJson(response.getBodyAsString(), response)); + } + + /** + * listLedgerOperations a ledgerOperation using immutable params (executes immediately) - returns + * raw Response. + */ + Response listLedgerOperationsRaw(ListLedgerOperationsParams params) throws ChargebeeException { + + return get("/ledger_operations", params != null ? params.toQueryParams() : null); + } + + /** + * listLedgerOperations a ledgerOperation without params (executes immediately) - returns raw + * Response. + */ + Response listLedgerOperationsRaw() throws ChargebeeException { + + return get("/ledger_operations", null); + } + + /** + * listLedgerOperations a ledgerOperation using raw JSON payload (executes immediately) - returns + * raw Response. + */ + Response listLedgerOperationsRaw(String jsonPayload) throws ChargebeeException { + + throw new UnsupportedOperationException("JSON payload not supported for GET operations"); + } + + public ListLedgerOperationsResponse listLedgerOperations(ListLedgerOperationsParams params) + throws ChargebeeException { + Response response = listLedgerOperationsRaw(params); + + return ListLedgerOperationsResponse.fromJson( + response.getBodyAsString(), this, params, response); + } + + /** Async variant of listLedgerOperations for ledgerOperation with params. */ + public CompletableFuture listLedgerOperationsAsync( + ListLedgerOperationsParams params) { + + return getAsync("/ledger_operations", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ListLedgerOperationsResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + + public ListLedgerOperationsResponse listLedgerOperations() throws ChargebeeException { + Response response = listLedgerOperationsRaw(); + + return ListLedgerOperationsResponse.fromJson(response.getBodyAsString(), this, null, response); + } + + /** Async variant of listLedgerOperations for ledgerOperation without params. */ + public CompletableFuture listLedgerOperationsAsync() { + + return getAsync("/ledger_operations", null) + .thenApply( + response -> + ListLedgerOperationsResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + + /** + * captureAuthorization a ledgerOperation using immutable params (executes immediately) - returns + * raw Response. + */ + Response captureAuthorizationRaw(LedgerOperationCaptureAuthorizationParams params) + throws ChargebeeException { + + return postJson( + "/ledger_operations/capture_authorization", params != null ? params.toJsonString() : null); + } + + /** + * captureAuthorization a ledgerOperation using raw JSON payload (executes immediately) - returns + * raw Response. + */ + Response captureAuthorizationRaw(String jsonPayload) throws ChargebeeException { + + return postJson("/ledger_operations/capture_authorization", jsonPayload); + } + + public LedgerOperationCaptureAuthorizationResponse captureAuthorization( + LedgerOperationCaptureAuthorizationParams params) throws ChargebeeException { + Response response = captureAuthorizationRaw(params); + + return LedgerOperationCaptureAuthorizationResponse.fromJson( + response.getBodyAsString(), response); + } + + /** Async variant of captureAuthorization for ledgerOperation with params. */ + public CompletableFuture captureAuthorizationAsync( + LedgerOperationCaptureAuthorizationParams params) { + + return postJsonAsync( + "/ledger_operations/capture_authorization", + params != null ? params.toJsonString() : null) + .thenApply( + response -> + LedgerOperationCaptureAuthorizationResponse.fromJson( + response.getBodyAsString(), response)); + } + + /** retrieveLedgerOperation a ledgerOperation (executes immediately) - returns raw Response. */ + Response retrieveLedgerOperationRaw(String ledgerOperationId) throws ChargebeeException { + String path = + buildPathWithParams( + "/ledger_operations/{ledger-operation-id}", "ledger-operation-id", ledgerOperationId); + + return get(path, null); + } + + public RetrieveLedgerOperationResponse retrieveLedgerOperation(String ledgerOperationId) + throws ChargebeeException { + Response response = retrieveLedgerOperationRaw(ledgerOperationId); + return RetrieveLedgerOperationResponse.fromJson(response.getBodyAsString(), response); + } + + /** Async variant of retrieveLedgerOperation for ledgerOperation without params. */ + public CompletableFuture retrieveLedgerOperationAsync( + String ledgerOperationId) { + String path = + buildPathWithParams( + "/ledger_operations/{ledger-operation-id}", "ledger-operation-id", ledgerOperationId); + + return getAsync(path, null) + .thenApply( + response -> + RetrieveLedgerOperationResponse.fromJson(response.getBodyAsString(), response)); + } +} diff --git a/src/main/java/com/chargebee/v4/services/PromotionalGrantService.java b/src/main/java/com/chargebee/v4/services/PromotionalGrantService.java new file mode 100644 index 00000000..2f50224e --- /dev/null +++ b/src/main/java/com/chargebee/v4/services/PromotionalGrantService.java @@ -0,0 +1,88 @@ +/* + * This file is auto-generated by Chargebee. + * For more information on how to make changes to this file, please see the README. + * Reach out to dx@chargebee.com for any questions. + * Copyright 2025 Chargebee Inc. + */ + +package com.chargebee.v4.services; + +import com.chargebee.v4.client.ChargebeeClient; +import com.chargebee.v4.client.request.RequestOptions; +import com.chargebee.v4.exceptions.ChargebeeException; +import com.chargebee.v4.transport.Response; +import java.util.concurrent.CompletableFuture; + +import com.chargebee.v4.models.promotionalGrant.params.PromotionalGrantsParams; + +import com.chargebee.v4.models.promotionalGrant.responses.PromotionalGrantsResponse; + +public final class PromotionalGrantService extends BaseService { + + private final ServiceConfig config; + + public PromotionalGrantService(ChargebeeClient client) { + super(client); + this.config = ServiceConfig.defaultConfig(); + } + + private PromotionalGrantService(ChargebeeClient client, RequestOptions options) { + super(client, options); + this.config = ServiceConfig.defaultConfig(); + } + + private PromotionalGrantService( + ChargebeeClient client, RequestOptions options, ServiceConfig config) { + super(client, options); + this.config = config; + } + + @Override + PromotionalGrantService with(RequestOptions newOptions) { + return new PromotionalGrantService(client, newOptions, config); + } + + /** + * Apply per-request options for this service instance. Users can chain .withOptions or .options + * to set headers and other options. + */ + public PromotionalGrantService withOptions(RequestOptions options) { + return with(options); + } + + // === Operations === + + /** + * promotionalGrants a promotionalGrant using immutable params (executes immediately) - returns + * raw Response. + */ + Response promotionalGrantsRaw(PromotionalGrantsParams params) throws ChargebeeException { + + return postJson("/promotional_grants", params != null ? params.toJsonString() : null); + } + + /** + * promotionalGrants a promotionalGrant using raw JSON payload (executes immediately) - returns + * raw Response. + */ + Response promotionalGrantsRaw(String jsonPayload) throws ChargebeeException { + + return postJson("/promotional_grants", jsonPayload); + } + + public PromotionalGrantsResponse promotionalGrants(PromotionalGrantsParams params) + throws ChargebeeException { + Response response = promotionalGrantsRaw(params); + + return PromotionalGrantsResponse.fromJson(response.getBodyAsString(), response); + } + + /** Async variant of promotionalGrants for promotionalGrant with params. */ + public CompletableFuture promotionalGrantsAsync( + PromotionalGrantsParams params) { + + return postJsonAsync("/promotional_grants", params != null ? params.toJsonString() : null) + .thenApply( + response -> PromotionalGrantsResponse.fromJson(response.getBodyAsString(), response)); + } +}