diff --git a/CHANGELOG.md b/CHANGELOG.md index 516a6be5..dbce63f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### v4.3.0 (2026-02-20) +* * * + +### New Features: +* Added async API support for all resource operations via `CompletableFuture`-based async methods (e.g., `createAsync`, `listAsync`, `retrieveAsync`). + ### v4.2.0 (2026-02-16) * * * diff --git a/README.md b/README.md index 8da1f945..873383db 100644 --- a/README.md +++ b/README.md @@ -516,20 +516,33 @@ try { ``` ##### Async exception handling + +> **Important:** When using async methods, exceptions are wrapped in a `java.util.concurrent.CompletionException`. +> Unlike sync methods that throw `ChargebeeException` directly, async methods deliver errors through +> `CompletableFuture`'s `.exceptionally()` or `.handle()` callbacks, where the original exception is +> available via `throwable.getCause()`. Always unwrap the `CompletionException` to access the +> underlying `ChargebeeException` (e.g., `InvalidRequestException`, `APIException`). + ```java import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; -CompletableFuture futureCustomer = customers.create(params); +CompletableFuture futureCustomer = customers.createAsync(params); futureCustomer - .thenAccept(customer -> { - System.out.println("Customer created: " + customer.getCustomer().getId()); + .thenAccept(response -> { + System.out.println("Customer created: " + response.getCustomer().getId()); }) .exceptionally(throwable -> { - if (throwable.getCause() instanceof InvalidRequestException) { - InvalidRequestException e = (InvalidRequestException) throwable.getCause(); + // Unwrap CompletionException to get the actual ChargebeeException + Throwable cause = throwable instanceof CompletionException + ? throwable.getCause() + : throwable; + + if (cause instanceof InvalidRequestException) { + InvalidRequestException e = (InvalidRequestException) cause; ApiErrorCode errorCode = e.getApiErrorCode(); - + if (errorCode instanceof BadRequestApiErrorCode) { BadRequestApiErrorCode code = (BadRequestApiErrorCode) errorCode; if (code == BadRequestApiErrorCode.DUPLICATE_ENTRY) { @@ -538,16 +551,35 @@ futureCustomer } else { System.err.println("Validation error: " + e.getMessage()); } - } else if (throwable.getCause() instanceof APIException) { - APIException e = (APIException) throwable.getCause(); + } else if (cause instanceof APIException) { + APIException e = (APIException) cause; System.err.println("API error: " + e.getApiErrorCodeRaw()); } else { - System.err.println("Unexpected error: " + throwable.getMessage()); + System.err.println("Unexpected error: " + cause.getMessage()); } return null; }); ``` +If you prefer blocking on the result, use a try-catch around `.join()` or `.get()`: + +```java +try { + CustomerCreateResponse response = customers.createAsync(params).join(); + System.out.println("Customer created: " + response.getCustomer().getId()); +} catch (CompletionException e) { + // Unwrap to get the original ChargebeeException + Throwable cause = e.getCause(); + if (cause instanceof InvalidRequestException) { + System.err.println("Validation error: " + cause.getMessage()); + } else if (cause instanceof APIException) { + System.err.println("API error: " + ((APIException) cause).getApiErrorCodeRaw()); + } else { + throw e; // Re-throw unexpected errors + } +} +``` + ### Retry Handling Chargebee's SDK includes built-in retry logic to handle temporary network issues and server-side errors. This feature is **disabled by default** but can be **enabled when needed**. diff --git a/VERSION b/VERSION index 6aba2b24..80895903 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.2.0 +4.3.0 diff --git a/build.gradle.kts b/build.gradle.kts index c3ec526e..2366bb74 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "com.chargebee" -version = "4.2.0" +version = "4.3.0" description = "Java client library for ChargeBee" // Project metadata diff --git a/src/main/java/com/chargebee/v4/client/ChargebeeClient.java b/src/main/java/com/chargebee/v4/client/ChargebeeClient.java index 00a378a3..387793f0 100644 --- a/src/main/java/com/chargebee/v4/client/ChargebeeClient.java +++ b/src/main/java/com/chargebee/v4/client/ChargebeeClient.java @@ -14,7 +14,10 @@ import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; /** * Immutable, thread-safe Chargebee API client with pluggable transport. @@ -25,7 +28,7 @@ * .build(); * } */ -public final class ChargebeeClient extends ClientMethodsImpl { +public final class ChargebeeClient extends ClientMethodsImpl implements AutoCloseable { private final String apiKey; private final String siteName; private final String endpoint; @@ -37,7 +40,8 @@ public final class ChargebeeClient extends ClientMethodsImpl { private final String protocol; private final RequestInterceptor requestInterceptor; private final RequestContext clientHeaders; - + private final ScheduledExecutorService retryScheduler; + // Auto-generated service registry for lazy loading private final ServiceRegistry serviceRegistry; @@ -53,6 +57,11 @@ private ChargebeeClient(Builder builder) { this.protocol = builder.protocol; this.requestInterceptor = builder.requestInterceptor; this.clientHeaders = new RequestContext(builder.clientHeaders.getHeaders()); + this.retryScheduler = Executors.newSingleThreadScheduledExecutor(r -> { + Thread t = new Thread(r, "chargebee-retry-scheduler"); + t.setDaemon(true); + return t; + }); this.serviceRegistry = new ServiceRegistry(this); } @@ -83,7 +92,19 @@ public static Builder builder(String apiKey, String siteName) { public String getProtocol() { return protocol; } public RequestInterceptor getRequestInterceptor() { return requestInterceptor; } public RequestContext getClientHeaders() { return clientHeaders; } - + + @Override + public void close() { + retryScheduler.shutdown(); + if (transport instanceof AutoCloseable) { + try { + ((AutoCloseable) transport).close(); + } catch (Exception e) { + // best-effort cleanup + } + } + } + // (Header decoration removed from public API) // Resource Services - Auto-generated via ClientMethodsImpl @@ -477,25 +498,18 @@ private CompletableFuture sendWithRetryAsyncInternal(Request request, private CompletableFuture delayAndRetry(Request request, int nextAttempt, long delayMs, int maxRetries) { CompletableFuture delayedRetry = new CompletableFuture<>(); - - // Use a separate thread for the delay to avoid blocking - CompletableFuture.runAsync(() -> { - try { - Thread.sleep(delayMs); - sendWithRetryAsyncInternal(request, nextAttempt, maxRetries) - .whenComplete((response, throwable) -> { - if (throwable != null) { - delayedRetry.completeExceptionally(throwable); - } else { - delayedRetry.complete(response); - } - }); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - delayedRetry.completeExceptionally(new RuntimeException("Interrupted during retry delay", e)); - } - }); - + + retryScheduler.schedule(() -> { + sendWithRetryAsyncInternal(request, nextAttempt, maxRetries) + .whenComplete((response, throwable) -> { + if (throwable != null) { + delayedRetry.completeExceptionally(throwable); + } else { + delayedRetry.complete(response); + } + }); + }, delayMs, TimeUnit.MILLISECONDS); + return delayedRetry; } diff --git a/src/main/java/com/chargebee/v4/services/AdditionalBillingLogiqService.java b/src/main/java/com/chargebee/v4/services/AdditionalBillingLogiqService.java index 3902c083..c02a61dc 100644 --- a/src/main/java/com/chargebee/v4/services/AdditionalBillingLogiqService.java +++ b/src/main/java/com/chargebee/v4/services/AdditionalBillingLogiqService.java @@ -11,6 +11,7 @@ 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.additionalBillingLogiq.params.AdditionalBillingLogiqRetrieveParams; @@ -85,9 +86,30 @@ public AdditionalBillingLogiqRetrieveResponse retrieve( return AdditionalBillingLogiqRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for additionalBillingLogiq with params. */ + public CompletableFuture retrieveAsync( + AdditionalBillingLogiqRetrieveParams params) { + + return getAsync("/additional_billing_logiqs", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + AdditionalBillingLogiqRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } + public AdditionalBillingLogiqRetrieveResponse retrieve() throws ChargebeeException { Response response = retrieveRaw(); return AdditionalBillingLogiqRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for additionalBillingLogiq without params. */ + public CompletableFuture retrieveAsync() { + + return getAsync("/additional_billing_logiqs", null) + .thenApply( + response -> + AdditionalBillingLogiqRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/AddonService.java b/src/main/java/com/chargebee/v4/services/AddonService.java index cb8a1dab..88acc89a 100644 --- a/src/main/java/com/chargebee/v4/services/AddonService.java +++ b/src/main/java/com/chargebee/v4/services/AddonService.java @@ -11,6 +11,7 @@ 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.addon.params.AddonCopyParams; @@ -86,6 +87,13 @@ public AddonCopyResponse copy(AddonCopyParams params) throws ChargebeeException return AddonCopyResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of copy for addon with params. */ + public CompletableFuture copyAsync(AddonCopyParams params) { + + return postAsync("/addons/copy", params != null ? params.toFormData() : null) + .thenApply(response -> AddonCopyResponse.fromJson(response.getBodyAsString(), response)); + } + /** unarchive a addon (executes immediately) - returns raw Response. */ Response unarchiveRaw(String addonId) throws ChargebeeException { String path = buildPathWithParams("/addons/{addon-id}/unarchive", "addon-id", addonId); @@ -98,6 +106,15 @@ public AddonUnarchiveResponse unarchive(String addonId) throws ChargebeeExceptio return AddonUnarchiveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of unarchive for addon without params. */ + public CompletableFuture unarchiveAsync(String addonId) { + String path = buildPathWithParams("/addons/{addon-id}/unarchive", "addon-id", addonId); + + return postAsync(path, null) + .thenApply( + response -> AddonUnarchiveResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a addon (executes immediately) - returns raw Response. */ Response retrieveRaw(String addonId) throws ChargebeeException { String path = buildPathWithParams("/addons/{addon-id}", "addon-id", addonId); @@ -110,6 +127,15 @@ public AddonRetrieveResponse retrieve(String addonId) throws ChargebeeException return AddonRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for addon without params. */ + public CompletableFuture retrieveAsync(String addonId) { + String path = buildPathWithParams("/addons/{addon-id}", "addon-id", addonId); + + return getAsync(path, null) + .thenApply( + response -> AddonRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a addon (executes immediately) - returns raw Response. */ Response updateRaw(String addonId) throws ChargebeeException { String path = buildPathWithParams("/addons/{addon-id}", "addon-id", addonId); @@ -135,11 +161,27 @@ public AddonUpdateResponse update(String addonId, AddonUpdateParams params) return AddonUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for addon with params. */ + public CompletableFuture updateAsync( + String addonId, AddonUpdateParams params) { + String path = buildPathWithParams("/addons/{addon-id}", "addon-id", addonId); + return postAsync(path, params.toFormData()) + .thenApply(response -> AddonUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public AddonUpdateResponse update(String addonId) throws ChargebeeException { Response response = updateRaw(addonId); return AddonUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for addon without params. */ + public CompletableFuture updateAsync(String addonId) { + String path = buildPathWithParams("/addons/{addon-id}", "addon-id", addonId); + + return postAsync(path, null) + .thenApply(response -> AddonUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a addon using immutable params (executes immediately) - returns raw Response. */ Response listRaw(AddonListParams params) throws ChargebeeException { @@ -164,12 +206,30 @@ public AddonListResponse list(AddonListParams params) throws ChargebeeException return AddonListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for addon with params. */ + public CompletableFuture listAsync(AddonListParams params) { + + return getAsync("/addons", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + AddonListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public AddonListResponse list() throws ChargebeeException { Response response = listRaw(); return AddonListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for addon without params. */ + public CompletableFuture listAsync() { + + return getAsync("/addons", null) + .thenApply( + response -> + AddonListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a addon using immutable params (executes immediately) - returns raw Response. */ Response createRaw(AddonCreateParams params) throws ChargebeeException { @@ -188,6 +248,13 @@ public AddonCreateResponse create(AddonCreateParams params) throws ChargebeeExce return AddonCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for addon with params. */ + public CompletableFuture createAsync(AddonCreateParams params) { + + return postAsync("/addons", params != null ? params.toFormData() : null) + .thenApply(response -> AddonCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a addon (executes immediately) - returns raw Response. */ Response deleteRaw(String addonId) throws ChargebeeException { String path = buildPathWithParams("/addons/{addon-id}/delete", "addon-id", addonId); @@ -199,4 +266,12 @@ public AddonDeleteResponse delete(String addonId) throws ChargebeeException { Response response = deleteRaw(addonId); return AddonDeleteResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of delete for addon without params. */ + public CompletableFuture deleteAsync(String addonId) { + String path = buildPathWithParams("/addons/{addon-id}/delete", "addon-id", addonId); + + return postAsync(path, null) + .thenApply(response -> AddonDeleteResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/AddressService.java b/src/main/java/com/chargebee/v4/services/AddressService.java index dd8de8df..af875f04 100644 --- a/src/main/java/com/chargebee/v4/services/AddressService.java +++ b/src/main/java/com/chargebee/v4/services/AddressService.java @@ -11,6 +11,7 @@ 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.address.params.AddressRetrieveParams; @@ -72,6 +73,14 @@ public AddressRetrieveResponse retrieve(AddressRetrieveParams params) throws Cha return AddressRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for address with params. */ + public CompletableFuture retrieveAsync(AddressRetrieveParams params) { + + return getAsync("/addresses", params != null ? params.toQueryParams() : null) + .thenApply( + response -> AddressRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a address using immutable params (executes immediately) - returns raw Response. */ Response updateRaw(AddressUpdateParams params) throws ChargebeeException { @@ -89,4 +98,12 @@ public AddressUpdateResponse update(AddressUpdateParams params) throws Chargebee return AddressUpdateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of update for address with params. */ + public CompletableFuture updateAsync(AddressUpdateParams params) { + + return postAsync("/addresses", params != null ? params.toFormData() : null) + .thenApply( + response -> AddressUpdateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/AttachedItemService.java b/src/main/java/com/chargebee/v4/services/AttachedItemService.java index 81c197e3..96188ad1 100644 --- a/src/main/java/com/chargebee/v4/services/AttachedItemService.java +++ b/src/main/java/com/chargebee/v4/services/AttachedItemService.java @@ -11,6 +11,7 @@ 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.attachedItem.params.AttachedItemRetrieveParams; @@ -93,11 +94,35 @@ public AttachedItemRetrieveResponse retrieve( return AttachedItemRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for attachedItem with params. */ + public CompletableFuture retrieveAsync( + String attachedItemId, AttachedItemRetrieveParams params) { + String path = + buildPathWithParams( + "/attached_items/{attached-item-id}", "attached-item-id", attachedItemId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + AttachedItemRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + public AttachedItemRetrieveResponse retrieve(String attachedItemId) throws ChargebeeException { Response response = retrieveRaw(attachedItemId); return AttachedItemRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for attachedItem without params. */ + public CompletableFuture retrieveAsync(String attachedItemId) { + String path = + buildPathWithParams( + "/attached_items/{attached-item-id}", "attached-item-id", attachedItemId); + + return getAsync(path, null) + .thenApply( + response -> + AttachedItemRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a attachedItem (executes immediately) - returns raw Response. */ Response updateRaw(String attachedItemId) throws ChargebeeException { String path = @@ -130,6 +155,17 @@ public AttachedItemUpdateResponse update(String attachedItemId, AttachedItemUpda return AttachedItemUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for attachedItem with params. */ + public CompletableFuture updateAsync( + String attachedItemId, AttachedItemUpdateParams params) { + String path = + buildPathWithParams( + "/attached_items/{attached-item-id}", "attached-item-id", attachedItemId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> AttachedItemUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a attachedItem using immutable params (executes immediately) - returns raw Response. */ Response listRaw(String itemId, AttachedItemListParams params) throws ChargebeeException { String path = buildPathWithParams("/items/{item-id}/attached_items", "item-id", itemId); @@ -161,6 +197,27 @@ public AttachedItemListResponse list(String itemId) throws ChargebeeException { response.getBodyAsString(), this, null, itemId, response); } + /** Async variant of list for attachedItem with params. */ + public CompletableFuture listAsync( + String itemId, AttachedItemListParams params) { + String path = buildPathWithParams("/items/{item-id}/attached_items", "item-id", itemId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + AttachedItemListResponse.fromJson( + response.getBodyAsString(), this, params, itemId, response)); + } + + /** Async variant of list for attachedItem without params. */ + public CompletableFuture listAsync(String itemId) { + String path = buildPathWithParams("/items/{item-id}/attached_items", "item-id", itemId); + return getAsync(path, null) + .thenApply( + response -> + AttachedItemListResponse.fromJson( + response.getBodyAsString(), this, null, itemId, response)); + } + /** create a attachedItem (executes immediately) - returns raw Response. */ Response createRaw(String itemId) throws ChargebeeException { String path = buildPathWithParams("/items/{item-id}/attached_items", "item-id", itemId); @@ -186,6 +243,15 @@ public AttachedItemCreateResponse create(String itemId, AttachedItemCreateParams return AttachedItemCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for attachedItem with params. */ + public CompletableFuture createAsync( + String itemId, AttachedItemCreateParams params) { + String path = buildPathWithParams("/items/{item-id}/attached_items", "item-id", itemId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> AttachedItemCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a attachedItem (executes immediately) - returns raw Response. */ Response deleteRaw(String attachedItemId) throws ChargebeeException { String path = @@ -217,4 +283,15 @@ public AttachedItemDeleteResponse delete(String attachedItemId, AttachedItemDele Response response = deleteRaw(attachedItemId, params); return AttachedItemDeleteResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of delete for attachedItem with params. */ + public CompletableFuture deleteAsync( + String attachedItemId, AttachedItemDeleteParams params) { + String path = + buildPathWithParams( + "/attached_items/{attached-item-id}/delete", "attached-item-id", attachedItemId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> AttachedItemDeleteResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/BaseService.java b/src/main/java/com/chargebee/v4/services/BaseService.java index 4008e326..6e6f0e73 100644 --- a/src/main/java/com/chargebee/v4/services/BaseService.java +++ b/src/main/java/com/chargebee/v4/services/BaseService.java @@ -234,6 +234,44 @@ private String baseUrlWithSubDomain(String subDomain) { client.getProtocol(), client.getSiteName(), subDomain, client.getDomainSuffix()); } + /** + * POST async with subdomain routing. + */ + protected CompletableFuture postWithSubDomainAsync(String path, String subDomain, Map formData) { + String fullUrl = UrlBuilder.buildUrl(baseUrlWithSubDomain(subDomain), path, null); + Request.Builder builder = Request.builder() + .method("POST") + .url(fullUrl) + .formBody(formData); + applyMergedHeaders(builder); + return client.executeWithInterceptorAsync(builder.build()); + } + + /** + * POST JSON async with subdomain routing. + */ + protected CompletableFuture postJsonWithSubDomainAsync(String path, String subDomain, String jsonData) { + String fullUrl = UrlBuilder.buildUrl(baseUrlWithSubDomain(subDomain), path, null); + Request.Builder builder = Request.builder() + .method("POST") + .url(fullUrl) + .jsonBody(jsonData); + applyMergedHeaders(builder); + return client.executeWithInterceptorAsync(builder.build()); + } + + /** + * GET async with subdomain routing. + */ + protected CompletableFuture getWithSubDomainAsync(String path, String subDomain, Map queryParams) { + String fullUrl = UrlBuilder.buildUrl(baseUrlWithSubDomain(subDomain), path, queryParams); + Request.Builder builder = Request.builder() + .method("GET") + .url(fullUrl); + applyMergedHeaders(builder); + return client.executeWithInterceptorAsync(builder.build()); + } + /** * GET async with Object query parameters. */ diff --git a/src/main/java/com/chargebee/v4/services/BrandConfigurationService.java b/src/main/java/com/chargebee/v4/services/BrandConfigurationService.java index 7589447c..399ce0c8 100644 --- a/src/main/java/com/chargebee/v4/services/BrandConfigurationService.java +++ b/src/main/java/com/chargebee/v4/services/BrandConfigurationService.java @@ -11,6 +11,7 @@ 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.brandConfiguration.params.BrandConfigurationRetrieveParams; @@ -82,9 +83,28 @@ public BrandConfigurationRetrieveResponse retrieve(BrandConfigurationRetrievePar return BrandConfigurationRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for brandConfiguration with params. */ + public CompletableFuture retrieveAsync( + BrandConfigurationRetrieveParams params) { + + return getAsync("/brand_configurations", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + BrandConfigurationRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + public BrandConfigurationRetrieveResponse retrieve() throws ChargebeeException { Response response = retrieveRaw(); return BrandConfigurationRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for brandConfiguration without params. */ + public CompletableFuture retrieveAsync() { + + return getAsync("/brand_configurations", null) + .thenApply( + response -> + BrandConfigurationRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/BusinessEntityService.java b/src/main/java/com/chargebee/v4/services/BusinessEntityService.java index a5b16684..1b348ecc 100644 --- a/src/main/java/com/chargebee/v4/services/BusinessEntityService.java +++ b/src/main/java/com/chargebee/v4/services/BusinessEntityService.java @@ -11,6 +11,7 @@ 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.businessEntity.params.BusinessEntityGetTransfersParams; @@ -87,6 +88,17 @@ public BusinessEntityGetTransfersResponse getTransfers(BusinessEntityGetTransfer response.getBodyAsString(), this, params, response); } + /** Async variant of getTransfers for businessEntity with params. */ + public CompletableFuture getTransfersAsync( + BusinessEntityGetTransfersParams params) { + + return getAsync("/business_entities/transfers", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + BusinessEntityGetTransfersResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public BusinessEntityGetTransfersResponse getTransfers() throws ChargebeeException { Response response = getTransfersRaw(); @@ -94,6 +106,16 @@ public BusinessEntityGetTransfersResponse getTransfers() throws ChargebeeExcepti response.getBodyAsString(), this, null, response); } + /** Async variant of getTransfers for businessEntity without params. */ + public CompletableFuture getTransfersAsync() { + + return getAsync("/business_entities/transfers", null) + .thenApply( + response -> + BusinessEntityGetTransfersResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** * createTransfers a businessEntity using immutable params (executes immediately) - returns raw * Response. @@ -119,4 +141,15 @@ public BusinessEntityCreateTransfersResponse createTransfers( return BusinessEntityCreateTransfersResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of createTransfers for businessEntity with params. */ + public CompletableFuture createTransfersAsync( + BusinessEntityCreateTransfersParams params) { + + return postAsync("/business_entities/transfers", params != null ? params.toFormData() : null) + .thenApply( + response -> + BusinessEntityCreateTransfersResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/BusinessProfileService.java b/src/main/java/com/chargebee/v4/services/BusinessProfileService.java index f365165f..76517abb 100644 --- a/src/main/java/com/chargebee/v4/services/BusinessProfileService.java +++ b/src/main/java/com/chargebee/v4/services/BusinessProfileService.java @@ -11,6 +11,7 @@ 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.businessProfile.params.BusinessProfileRetrieveParams; @@ -82,9 +83,28 @@ public BusinessProfileRetrieveResponse retrieve(BusinessProfileRetrieveParams pa return BusinessProfileRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for businessProfile with params. */ + public CompletableFuture retrieveAsync( + BusinessProfileRetrieveParams params) { + + return getAsync("/business_profiles", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + BusinessProfileRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + public BusinessProfileRetrieveResponse retrieve() throws ChargebeeException { Response response = retrieveRaw(); return BusinessProfileRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for businessProfile without params. */ + public CompletableFuture retrieveAsync() { + + return getAsync("/business_profiles", null) + .thenApply( + response -> + BusinessProfileRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CardService.java b/src/main/java/com/chargebee/v4/services/CardService.java index 7df2fa95..10f40159 100644 --- a/src/main/java/com/chargebee/v4/services/CardService.java +++ b/src/main/java/com/chargebee/v4/services/CardService.java @@ -11,6 +11,7 @@ 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.card.params.CopyCardForCustomerParams; @@ -97,6 +98,16 @@ public CopyCardForCustomerResponse copyCardForCustomer( return CopyCardForCustomerResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of copyCardForCustomer for card with params. */ + public CompletableFuture copyCardForCustomerAsync( + String customerId, CopyCardForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/copy_card", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CopyCardForCustomerResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a card (executes immediately) - returns raw Response. */ Response retrieveRaw(String customerId) throws ChargebeeException { String path = buildPathWithParams("/cards/{customer-id}", "customer-id", customerId); @@ -109,6 +120,14 @@ public CardRetrieveResponse retrieve(String customerId) throws ChargebeeExceptio return CardRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for card without params. */ + public CompletableFuture retrieveAsync(String customerId) { + String path = buildPathWithParams("/cards/{customer-id}", "customer-id", customerId); + + return getAsync(path, null) + .thenApply(response -> CardRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** switchGatewayForCustomer a card (executes immediately) - returns raw Response. */ Response switchGatewayForCustomerRaw(String customerId) throws ChargebeeException { String path = @@ -145,6 +164,18 @@ public CardSwitchGatewayForCustomerResponse switchGatewayForCustomer( return CardSwitchGatewayForCustomerResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of switchGatewayForCustomer for card with params. */ + public CompletableFuture switchGatewayForCustomerAsync( + String customerId, CardSwitchGatewayForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/switch_gateway", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CardSwitchGatewayForCustomerResponse.fromJson( + response.getBodyAsString(), response)); + } + /** deleteCardForCustomer a card (executes immediately) - returns raw Response. */ Response deleteCardForCustomerRaw(String customerId) throws ChargebeeException { String path = @@ -159,6 +190,18 @@ public DeleteCardForCustomerResponse deleteCardForCustomer(String customerId) return DeleteCardForCustomerResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteCardForCustomer for card without params. */ + public CompletableFuture deleteCardForCustomerAsync( + String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/delete_card", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + DeleteCardForCustomerResponse.fromJson(response.getBodyAsString(), response)); + } + /** updateCardForCustomer a card (executes immediately) - returns raw Response. */ Response updateCardForCustomerRaw(String customerId) throws ChargebeeException { String path = @@ -194,4 +237,15 @@ public UpdateCardForCustomerResponse updateCardForCustomer( Response response = updateCardForCustomerRaw(customerId, params); return UpdateCardForCustomerResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of updateCardForCustomer for card with params. */ + public CompletableFuture updateCardForCustomerAsync( + String customerId, UpdateCardForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/credit_card", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + UpdateCardForCustomerResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CommentService.java b/src/main/java/com/chargebee/v4/services/CommentService.java index 826ec37a..5246caa9 100644 --- a/src/main/java/com/chargebee/v4/services/CommentService.java +++ b/src/main/java/com/chargebee/v4/services/CommentService.java @@ -11,6 +11,7 @@ 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.comment.params.CommentListParams; @@ -70,6 +71,15 @@ public CommentDeleteResponse delete(String commentId) throws ChargebeeException return CommentDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for comment without params. */ + public CompletableFuture deleteAsync(String commentId) { + String path = buildPathWithParams("/comments/{comment-id}/delete", "comment-id", commentId); + + return postAsync(path, null) + .thenApply( + response -> CommentDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a comment (executes immediately) - returns raw Response. */ Response retrieveRaw(String commentId) throws ChargebeeException { String path = buildPathWithParams("/comments/{comment-id}", "comment-id", commentId); @@ -82,6 +92,15 @@ public CommentRetrieveResponse retrieve(String commentId) throws ChargebeeExcept return CommentRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for comment without params. */ + public CompletableFuture retrieveAsync(String commentId) { + String path = buildPathWithParams("/comments/{comment-id}", "comment-id", commentId); + + return getAsync(path, null) + .thenApply( + response -> CommentRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a comment using immutable params (executes immediately) - returns raw Response. */ Response listRaw(CommentListParams params) throws ChargebeeException { @@ -106,12 +125,30 @@ public CommentListResponse list(CommentListParams params) throws ChargebeeExcept return CommentListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for comment with params. */ + public CompletableFuture listAsync(CommentListParams params) { + + return getAsync("/comments", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CommentListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public CommentListResponse list() throws ChargebeeException { Response response = listRaw(); return CommentListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for comment without params. */ + public CompletableFuture listAsync() { + + return getAsync("/comments", null) + .thenApply( + response -> + CommentListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a comment using immutable params (executes immediately) - returns raw Response. */ Response createRaw(CommentCreateParams params) throws ChargebeeException { @@ -129,4 +166,12 @@ public CommentCreateResponse create(CommentCreateParams params) throws Chargebee return CommentCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for comment with params. */ + public CompletableFuture createAsync(CommentCreateParams params) { + + return postAsync("/comments", params != null ? params.toFormData() : null) + .thenApply( + response -> CommentCreateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ConfigurationService.java b/src/main/java/com/chargebee/v4/services/ConfigurationService.java index fde115f4..cb51c043 100644 --- a/src/main/java/com/chargebee/v4/services/ConfigurationService.java +++ b/src/main/java/com/chargebee/v4/services/ConfigurationService.java @@ -11,6 +11,7 @@ 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.configuration.params.ConfigurationListParams; @@ -75,9 +76,25 @@ public ConfigurationListResponse list(ConfigurationListParams params) throws Cha return ConfigurationListResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of list for configuration with params. */ + public CompletableFuture listAsync(ConfigurationListParams params) { + + return getAsync("/configurations", params != null ? params.toQueryParams() : null) + .thenApply( + response -> ConfigurationListResponse.fromJson(response.getBodyAsString(), response)); + } + public ConfigurationListResponse list() throws ChargebeeException { Response response = listRaw(); return ConfigurationListResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of list for configuration without params. */ + public CompletableFuture listAsync() { + + return getAsync("/configurations", null) + .thenApply( + response -> ConfigurationListResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CouponCodeService.java b/src/main/java/com/chargebee/v4/services/CouponCodeService.java index acb4a3c9..c84d2970 100644 --- a/src/main/java/com/chargebee/v4/services/CouponCodeService.java +++ b/src/main/java/com/chargebee/v4/services/CouponCodeService.java @@ -11,6 +11,7 @@ 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.couponCode.params.CouponCodeListParams; @@ -82,12 +83,31 @@ public CouponCodeListResponse list(CouponCodeListParams params) throws Chargebee return CouponCodeListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for couponCode with params. */ + public CompletableFuture listAsync(CouponCodeListParams params) { + + return getAsync("/coupon_codes", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CouponCodeListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public CouponCodeListResponse list() throws ChargebeeException { Response response = listRaw(); return CouponCodeListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for couponCode without params. */ + public CompletableFuture listAsync() { + + return getAsync("/coupon_codes", null) + .thenApply( + response -> + CouponCodeListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a couponCode using immutable params (executes immediately) - returns raw Response. */ Response createRaw(CouponCodeCreateParams params) throws ChargebeeException { @@ -106,6 +126,14 @@ public CouponCodeCreateResponse create(CouponCodeCreateParams params) throws Cha return CouponCodeCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for couponCode with params. */ + public CompletableFuture createAsync(CouponCodeCreateParams params) { + + return postAsync("/coupon_codes", params != null ? params.toFormData() : null) + .thenApply( + response -> CouponCodeCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a couponCode (executes immediately) - returns raw Response. */ Response retrieveRaw(String couponCodeCode) throws ChargebeeException { String path = @@ -119,6 +147,16 @@ public CouponCodeRetrieveResponse retrieve(String couponCodeCode) throws Chargeb return CouponCodeRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for couponCode without params. */ + public CompletableFuture retrieveAsync(String couponCodeCode) { + String path = + buildPathWithParams("/coupon_codes/{coupon-code-code}", "coupon-code-code", couponCodeCode); + + return getAsync(path, null) + .thenApply( + response -> CouponCodeRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** archive a couponCode (executes immediately) - returns raw Response. */ Response archiveRaw(String couponCodeCode) throws ChargebeeException { String path = @@ -132,4 +170,15 @@ public CouponCodeArchiveResponse archive(String couponCodeCode) throws Chargebee Response response = archiveRaw(couponCodeCode); return CouponCodeArchiveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of archive for couponCode without params. */ + public CompletableFuture archiveAsync(String couponCodeCode) { + String path = + buildPathWithParams( + "/coupon_codes/{coupon-code-code}/archive", "coupon-code-code", couponCodeCode); + + return postAsync(path, null) + .thenApply( + response -> CouponCodeArchiveResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CouponService.java b/src/main/java/com/chargebee/v4/services/CouponService.java index a04c7775..6e9ff55c 100644 --- a/src/main/java/com/chargebee/v4/services/CouponService.java +++ b/src/main/java/com/chargebee/v4/services/CouponService.java @@ -11,6 +11,7 @@ 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.coupon.params.CouponListParams; @@ -100,12 +101,30 @@ public CouponListResponse list(CouponListParams params) throws ChargebeeExceptio return CouponListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for coupon with params. */ + public CompletableFuture listAsync(CouponListParams params) { + + return getAsync("/coupons", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CouponListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public CouponListResponse list() throws ChargebeeException { Response response = listRaw(); return CouponListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for coupon without params. */ + public CompletableFuture listAsync() { + + return getAsync("/coupons", null) + .thenApply( + response -> + CouponListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a coupon using immutable params (executes immediately) - returns raw Response. */ Response createRaw(CouponCreateParams params) throws ChargebeeException { @@ -124,6 +143,13 @@ public CouponCreateResponse create(CouponCreateParams params) throws ChargebeeEx return CouponCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for coupon with params. */ + public CompletableFuture createAsync(CouponCreateParams params) { + + return postAsync("/coupons", params != null ? params.toFormData() : null) + .thenApply(response -> CouponCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** updateForItems a coupon (executes immediately) - returns raw Response. */ Response updateForItemsRaw(String couponId) throws ChargebeeException { String path = @@ -157,11 +183,33 @@ public CouponUpdateForItemsResponse updateForItems( return CouponUpdateForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateForItems for coupon with params. */ + public CompletableFuture updateForItemsAsync( + String couponId, CouponUpdateForItemsParams params) { + String path = + buildPathWithParams("/coupons/{coupon-id}/update_for_items", "coupon-id", couponId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CouponUpdateForItemsResponse.fromJson(response.getBodyAsString(), response)); + } + public CouponUpdateForItemsResponse updateForItems(String couponId) throws ChargebeeException { Response response = updateForItemsRaw(couponId); return CouponUpdateForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateForItems for coupon without params. */ + public CompletableFuture updateForItemsAsync(String couponId) { + String path = + buildPathWithParams("/coupons/{coupon-id}/update_for_items", "coupon-id", couponId); + + return postAsync(path, null) + .thenApply( + response -> + CouponUpdateForItemsResponse.fromJson(response.getBodyAsString(), response)); + } + /** unarchive a coupon (executes immediately) - returns raw Response. */ Response unarchiveRaw(String couponId) throws ChargebeeException { String path = buildPathWithParams("/coupons/{coupon-id}/unarchive", "coupon-id", couponId); @@ -174,6 +222,15 @@ public CouponUnarchiveResponse unarchive(String couponId) throws ChargebeeExcept return CouponUnarchiveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of unarchive for coupon without params. */ + public CompletableFuture unarchiveAsync(String couponId) { + String path = buildPathWithParams("/coupons/{coupon-id}/unarchive", "coupon-id", couponId); + + return postAsync(path, null) + .thenApply( + response -> CouponUnarchiveResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a coupon (executes immediately) - returns raw Response. */ Response deleteRaw(String couponId) throws ChargebeeException { String path = buildPathWithParams("/coupons/{coupon-id}/delete", "coupon-id", couponId); @@ -186,6 +243,14 @@ public CouponDeleteResponse delete(String couponId) throws ChargebeeException { return CouponDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for coupon without params. */ + public CompletableFuture deleteAsync(String couponId) { + String path = buildPathWithParams("/coupons/{coupon-id}/delete", "coupon-id", couponId); + + return postAsync(path, null) + .thenApply(response -> CouponDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** copy a coupon using immutable params (executes immediately) - returns raw Response. */ Response copyRaw(CouponCopyParams params) throws ChargebeeException { @@ -204,6 +269,13 @@ public CouponCopyResponse copy(CouponCopyParams params) throws ChargebeeExceptio return CouponCopyResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of copy for coupon with params. */ + public CompletableFuture copyAsync(CouponCopyParams params) { + + return postAsync("/coupons/copy", params != null ? params.toFormData() : null) + .thenApply(response -> CouponCopyResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a coupon (executes immediately) - returns raw Response. */ Response retrieveRaw(String couponId) throws ChargebeeException { String path = buildPathWithParams("/coupons/{coupon-id}", "coupon-id", couponId); @@ -216,6 +288,15 @@ public CouponRetrieveResponse retrieve(String couponId) throws ChargebeeExceptio return CouponRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for coupon without params. */ + public CompletableFuture retrieveAsync(String couponId) { + String path = buildPathWithParams("/coupons/{coupon-id}", "coupon-id", couponId); + + return getAsync(path, null) + .thenApply( + response -> CouponRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a coupon (executes immediately) - returns raw Response. */ Response updateRaw(String couponId) throws ChargebeeException { String path = buildPathWithParams("/coupons/{coupon-id}", "coupon-id", couponId); @@ -241,11 +322,27 @@ public CouponUpdateResponse update(String couponId, CouponUpdateParams params) return CouponUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for coupon with params. */ + public CompletableFuture updateAsync( + String couponId, CouponUpdateParams params) { + String path = buildPathWithParams("/coupons/{coupon-id}", "coupon-id", couponId); + return postAsync(path, params.toFormData()) + .thenApply(response -> CouponUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public CouponUpdateResponse update(String couponId) throws ChargebeeException { Response response = updateRaw(couponId); return CouponUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for coupon without params. */ + public CompletableFuture updateAsync(String couponId) { + String path = buildPathWithParams("/coupons/{coupon-id}", "coupon-id", couponId); + + return postAsync(path, null) + .thenApply(response -> CouponUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createForItems a coupon using immutable params (executes immediately) - returns raw Response. */ @@ -268,4 +365,14 @@ public CouponCreateForItemsResponse createForItems(CouponCreateForItemsParams pa return CouponCreateForItemsResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of createForItems for coupon with params. */ + public CompletableFuture createForItemsAsync( + CouponCreateForItemsParams params) { + + return postAsync("/coupons/create_for_items", params != null ? params.toFormData() : null) + .thenApply( + response -> + CouponCreateForItemsResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CouponSetService.java b/src/main/java/com/chargebee/v4/services/CouponSetService.java index 761bbdbc..ef39960c 100644 --- a/src/main/java/com/chargebee/v4/services/CouponSetService.java +++ b/src/main/java/com/chargebee/v4/services/CouponSetService.java @@ -11,6 +11,7 @@ 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.couponSet.params.CouponSetListParams; @@ -92,12 +93,30 @@ public CouponSetListResponse list(CouponSetListParams params) throws ChargebeeEx return CouponSetListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for couponSet with params. */ + public CompletableFuture listAsync(CouponSetListParams params) { + + return getAsync("/coupon_sets", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CouponSetListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public CouponSetListResponse list() throws ChargebeeException { Response response = listRaw(); return CouponSetListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for couponSet without params. */ + public CompletableFuture listAsync() { + + return getAsync("/coupon_sets", null) + .thenApply( + response -> + CouponSetListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a couponSet using immutable params (executes immediately) - returns raw Response. */ Response createRaw(CouponSetCreateParams params) throws ChargebeeException { @@ -116,6 +135,14 @@ public CouponSetCreateResponse create(CouponSetCreateParams params) throws Charg return CouponSetCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for couponSet with params. */ + public CompletableFuture createAsync(CouponSetCreateParams params) { + + return postAsync("/coupon_sets", params != null ? params.toFormData() : null) + .thenApply( + response -> CouponSetCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a couponSet (executes immediately) - returns raw Response. */ Response updateRaw(String couponSetId) throws ChargebeeException { String path = @@ -144,11 +171,31 @@ public CouponSetUpdateResponse update(String couponSetId, CouponSetUpdateParams return CouponSetUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for couponSet with params. */ + public CompletableFuture updateAsync( + String couponSetId, CouponSetUpdateParams params) { + String path = + buildPathWithParams("/coupon_sets/{coupon-set-id}/update", "coupon-set-id", couponSetId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CouponSetUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public CouponSetUpdateResponse update(String couponSetId) throws ChargebeeException { Response response = updateRaw(couponSetId); return CouponSetUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for couponSet without params. */ + public CompletableFuture updateAsync(String couponSetId) { + String path = + buildPathWithParams("/coupon_sets/{coupon-set-id}/update", "coupon-set-id", couponSetId); + + return postAsync(path, null) + .thenApply( + response -> CouponSetUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a couponSet (executes immediately) - returns raw Response. */ Response retrieveRaw(String couponSetId) throws ChargebeeException { String path = buildPathWithParams("/coupon_sets/{coupon-set-id}", "coupon-set-id", couponSetId); @@ -161,6 +208,15 @@ public CouponSetRetrieveResponse retrieve(String couponSetId) throws ChargebeeEx return CouponSetRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for couponSet without params. */ + public CompletableFuture retrieveAsync(String couponSetId) { + String path = buildPathWithParams("/coupon_sets/{coupon-set-id}", "coupon-set-id", couponSetId); + + return getAsync(path, null) + .thenApply( + response -> CouponSetRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** addCouponCodes a couponSet (executes immediately) - returns raw Response. */ Response addCouponCodesRaw(String couponSetId) throws ChargebeeException { String path = @@ -199,12 +255,37 @@ public CouponSetAddCouponCodesResponse addCouponCodes( return CouponSetAddCouponCodesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addCouponCodes for couponSet with params. */ + public CompletableFuture addCouponCodesAsync( + String couponSetId, CouponSetAddCouponCodesParams params) { + String path = + buildPathWithParams( + "/coupon_sets/{coupon-set-id}/add_coupon_codes", "coupon-set-id", couponSetId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CouponSetAddCouponCodesResponse.fromJson(response.getBodyAsString(), response)); + } + public CouponSetAddCouponCodesResponse addCouponCodes(String couponSetId) throws ChargebeeException { Response response = addCouponCodesRaw(couponSetId); return CouponSetAddCouponCodesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addCouponCodes for couponSet without params. */ + public CompletableFuture addCouponCodesAsync( + String couponSetId) { + String path = + buildPathWithParams( + "/coupon_sets/{coupon-set-id}/add_coupon_codes", "coupon-set-id", couponSetId); + + return postAsync(path, null) + .thenApply( + response -> + CouponSetAddCouponCodesResponse.fromJson(response.getBodyAsString(), response)); + } + /** deleteUnusedCouponCodes a couponSet (executes immediately) - returns raw Response. */ Response deleteUnusedCouponCodesRaw(String couponSetId) throws ChargebeeException { String path = @@ -222,6 +303,22 @@ public CouponSetDeleteUnusedCouponCodesResponse deleteUnusedCouponCodes(String c return CouponSetDeleteUnusedCouponCodesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteUnusedCouponCodes for couponSet without params. */ + public CompletableFuture deleteUnusedCouponCodesAsync( + String couponSetId) { + String path = + buildPathWithParams( + "/coupon_sets/{coupon-set-id}/delete_unused_coupon_codes", + "coupon-set-id", + couponSetId); + + return postAsync(path, null) + .thenApply( + response -> + CouponSetDeleteUnusedCouponCodesResponse.fromJson( + response.getBodyAsString(), response)); + } + /** delete a couponSet (executes immediately) - returns raw Response. */ Response deleteRaw(String couponSetId) throws ChargebeeException { String path = @@ -234,4 +331,14 @@ public CouponSetDeleteResponse delete(String couponSetId) throws ChargebeeExcept Response response = deleteRaw(couponSetId); return CouponSetDeleteResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of delete for couponSet without params. */ + public CompletableFuture deleteAsync(String couponSetId) { + String path = + buildPathWithParams("/coupon_sets/{coupon-set-id}/delete", "coupon-set-id", couponSetId); + + return postAsync(path, null) + .thenApply( + response -> CouponSetDeleteResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CreditNoteService.java b/src/main/java/com/chargebee/v4/services/CreditNoteService.java index 73fa1868..2c58f577 100644 --- a/src/main/java/com/chargebee/v4/services/CreditNoteService.java +++ b/src/main/java/com/chargebee/v4/services/CreditNoteService.java @@ -11,6 +11,7 @@ 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.creditNote.params.CreditNoteRecordRefundParams; @@ -132,12 +133,36 @@ public CreditNoteRecordRefundResponse recordRefund( return CreditNoteRecordRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordRefund for creditNote with params. */ + public CompletableFuture recordRefundAsync( + String creditNoteId, CreditNoteRecordRefundParams params) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/record_refund", "credit-note-id", creditNoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CreditNoteRecordRefundResponse.fromJson(response.getBodyAsString(), response)); + } + public CreditNoteRecordRefundResponse recordRefund(String creditNoteId) throws ChargebeeException { Response response = recordRefundRaw(creditNoteId); return CreditNoteRecordRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordRefund for creditNote without params. */ + public CompletableFuture recordRefundAsync(String creditNoteId) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/record_refund", "credit-note-id", creditNoteId); + + return postAsync(path, null) + .thenApply( + response -> + CreditNoteRecordRefundResponse.fromJson(response.getBodyAsString(), response)); + } + /** * importCreditNote a creditNote using immutable params (executes immediately) - returns raw * Response. @@ -163,6 +188,16 @@ public ImportCreditNoteResponse importCreditNote(ImportCreditNoteParams params) return ImportCreditNoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importCreditNote for creditNote with params. */ + public CompletableFuture importCreditNoteAsync( + ImportCreditNoteParams params) { + + return postAsync( + "/credit_notes/import_credit_note", params != null ? params.toFormData() : null) + .thenApply( + response -> ImportCreditNoteResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a creditNote (executes immediately) - returns raw Response. */ Response deleteRaw(String creditNoteId) throws ChargebeeException { String path = @@ -194,11 +229,33 @@ public CreditNoteDeleteResponse delete(String creditNoteId, CreditNoteDeletePara return CreditNoteDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for creditNote with params. */ + public CompletableFuture deleteAsync( + String creditNoteId, CreditNoteDeleteParams params) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/delete", "credit-note-id", creditNoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CreditNoteDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + public CreditNoteDeleteResponse delete(String creditNoteId) throws ChargebeeException { Response response = deleteRaw(creditNoteId); return CreditNoteDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for creditNote without params. */ + public CompletableFuture deleteAsync(String creditNoteId) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/delete", "credit-note-id", creditNoteId); + + return postAsync(path, null) + .thenApply( + response -> CreditNoteDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * creditNotesForCustomer a creditNote using immutable params (executes immediately) - returns raw * Response. @@ -245,6 +302,30 @@ public CreditNotesForCustomerResponse creditNotesForCustomer(String customerId) response.getBodyAsString(), this, null, customerId, response); } + /** Async variant of creditNotesForCustomer for creditNote with params. */ + public CompletableFuture creditNotesForCustomerAsync( + String customerId, CreditNotesForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/credit_notes", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CreditNotesForCustomerResponse.fromJson( + response.getBodyAsString(), this, params, customerId, response)); + } + + /** Async variant of creditNotesForCustomer for creditNote without params. */ + public CompletableFuture creditNotesForCustomerAsync( + String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/credit_notes", "customer-id", customerId); + return getAsync(path, null) + .thenApply( + response -> + CreditNotesForCustomerResponse.fromJson( + response.getBodyAsString(), this, null, customerId, response)); + } + /** pdf a creditNote (executes immediately) - returns raw Response. */ Response pdfRaw(String creditNoteId) throws ChargebeeException { String path = @@ -273,11 +354,31 @@ public CreditNotePdfResponse pdf(String creditNoteId, CreditNotePdfParams params return CreditNotePdfResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pdf for creditNote with params. */ + public CompletableFuture pdfAsync( + String creditNoteId, CreditNotePdfParams params) { + String path = + buildPathWithParams("/credit_notes/{credit-note-id}/pdf", "credit-note-id", creditNoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CreditNotePdfResponse.fromJson(response.getBodyAsString(), response)); + } + public CreditNotePdfResponse pdf(String creditNoteId) throws ChargebeeException { Response response = pdfRaw(creditNoteId); return CreditNotePdfResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pdf for creditNote without params. */ + public CompletableFuture pdfAsync(String creditNoteId) { + String path = + buildPathWithParams("/credit_notes/{credit-note-id}/pdf", "credit-note-id", creditNoteId); + + return postAsync(path, null) + .thenApply( + response -> CreditNotePdfResponse.fromJson(response.getBodyAsString(), response)); + } + /** sendEinvoice a creditNote (executes immediately) - returns raw Response. */ Response sendEinvoiceRaw(String creditNoteId) throws ChargebeeException { String path = @@ -293,6 +394,18 @@ public CreditNoteSendEinvoiceResponse sendEinvoice(String creditNoteId) return CreditNoteSendEinvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of sendEinvoice for creditNote without params. */ + public CompletableFuture sendEinvoiceAsync(String creditNoteId) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/send_einvoice", "credit-note-id", creditNoteId); + + return postAsync(path, null) + .thenApply( + response -> + CreditNoteSendEinvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + /** voidCreditNote a creditNote (executes immediately) - returns raw Response. */ Response voidCreditNoteRaw(String creditNoteId) throws ChargebeeException { String path = @@ -328,11 +441,31 @@ public VoidCreditNoteResponse voidCreditNote(String creditNoteId, VoidCreditNote return VoidCreditNoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of voidCreditNote for creditNote with params. */ + public CompletableFuture voidCreditNoteAsync( + String creditNoteId, VoidCreditNoteParams params) { + String path = + buildPathWithParams("/credit_notes/{credit-note-id}/void", "credit-note-id", creditNoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> VoidCreditNoteResponse.fromJson(response.getBodyAsString(), response)); + } + public VoidCreditNoteResponse voidCreditNote(String creditNoteId) throws ChargebeeException { Response response = voidCreditNoteRaw(creditNoteId); return VoidCreditNoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of voidCreditNote for creditNote without params. */ + public CompletableFuture voidCreditNoteAsync(String creditNoteId) { + String path = + buildPathWithParams("/credit_notes/{credit-note-id}/void", "credit-note-id", creditNoteId); + + return postAsync(path, null) + .thenApply( + response -> VoidCreditNoteResponse.fromJson(response.getBodyAsString(), response)); + } + /** refund a creditNote (executes immediately) - returns raw Response. */ Response refundRaw(String creditNoteId) throws ChargebeeException { String path = @@ -364,11 +497,33 @@ public CreditNoteRefundResponse refund(String creditNoteId, CreditNoteRefundPara return CreditNoteRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of refund for creditNote with params. */ + public CompletableFuture refundAsync( + String creditNoteId, CreditNoteRefundParams params) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/refund", "credit-note-id", creditNoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CreditNoteRefundResponse.fromJson(response.getBodyAsString(), response)); + } + public CreditNoteRefundResponse refund(String creditNoteId) throws ChargebeeException { Response response = refundRaw(creditNoteId); return CreditNoteRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of refund for creditNote without params. */ + public CompletableFuture refundAsync(String creditNoteId) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/refund", "credit-note-id", creditNoteId); + + return postAsync(path, null) + .thenApply( + response -> CreditNoteRefundResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a creditNote using immutable params (executes immediately) - returns raw Response. */ Response listRaw(CreditNoteListParams params) throws ChargebeeException { @@ -393,12 +548,31 @@ public CreditNoteListResponse list(CreditNoteListParams params) throws Chargebee return CreditNoteListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for creditNote with params. */ + public CompletableFuture listAsync(CreditNoteListParams params) { + + return getAsync("/credit_notes", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CreditNoteListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public CreditNoteListResponse list() throws ChargebeeException { Response response = listRaw(); return CreditNoteListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for creditNote without params. */ + public CompletableFuture listAsync() { + + return getAsync("/credit_notes", null) + .thenApply( + response -> + CreditNoteListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a creditNote using immutable params (executes immediately) - returns raw Response. */ Response createRaw(CreditNoteCreateParams params) throws ChargebeeException { @@ -417,6 +591,14 @@ public CreditNoteCreateResponse create(CreditNoteCreateParams params) throws Cha return CreditNoteCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for creditNote with params. */ + public CompletableFuture createAsync(CreditNoteCreateParams params) { + + return postAsync("/credit_notes", params != null ? params.toFormData() : null) + .thenApply( + response -> CreditNoteCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** downloadEinvoice a creditNote (executes immediately) - returns raw Response. */ Response downloadEinvoiceRaw(String creditNoteId) throws ChargebeeException { String path = @@ -432,6 +614,19 @@ public CreditNoteDownloadEinvoiceResponse downloadEinvoice(String creditNoteId) return CreditNoteDownloadEinvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of downloadEinvoice for creditNote without params. */ + public CompletableFuture downloadEinvoiceAsync( + String creditNoteId) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/download_einvoice", "credit-note-id", creditNoteId); + + return getAsync(path, null) + .thenApply( + response -> + CreditNoteDownloadEinvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + /** resendEinvoice a creditNote (executes immediately) - returns raw Response. */ Response resendEinvoiceRaw(String creditNoteId) throws ChargebeeException { String path = @@ -447,6 +642,19 @@ public CreditNoteResendEinvoiceResponse resendEinvoice(String creditNoteId) return CreditNoteResendEinvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resendEinvoice for creditNote without params. */ + public CompletableFuture resendEinvoiceAsync( + String creditNoteId) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/resend_einvoice", "credit-note-id", creditNoteId); + + return postAsync(path, null) + .thenApply( + response -> + CreditNoteResendEinvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + /** removeTaxWithheldRefund a creditNote (executes immediately) - returns raw Response. */ Response removeTaxWithheldRefundRaw(String creditNoteId) throws ChargebeeException { String path = @@ -494,12 +702,43 @@ public CreditNoteRemoveTaxWithheldRefundResponse removeTaxWithheldRefund( return CreditNoteRemoveTaxWithheldRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeTaxWithheldRefund for creditNote with params. */ + public CompletableFuture removeTaxWithheldRefundAsync( + String creditNoteId, CreditNoteRemoveTaxWithheldRefundParams params) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/remove_tax_withheld_refund", + "credit-note-id", + creditNoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CreditNoteRemoveTaxWithheldRefundResponse.fromJson( + response.getBodyAsString(), response)); + } + public CreditNoteRemoveTaxWithheldRefundResponse removeTaxWithheldRefund(String creditNoteId) throws ChargebeeException { Response response = removeTaxWithheldRefundRaw(creditNoteId); return CreditNoteRemoveTaxWithheldRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeTaxWithheldRefund for creditNote without params. */ + public CompletableFuture removeTaxWithheldRefundAsync( + String creditNoteId) { + String path = + buildPathWithParams( + "/credit_notes/{credit-note-id}/remove_tax_withheld_refund", + "credit-note-id", + creditNoteId); + + return postAsync(path, null) + .thenApply( + response -> + CreditNoteRemoveTaxWithheldRefundResponse.fromJson( + response.getBodyAsString(), response)); + } + /** retrieve a creditNote (executes immediately) - returns raw Response. */ Response retrieveRaw(String creditNoteId) throws ChargebeeException { String path = @@ -522,8 +761,28 @@ public CreditNoteRetrieveResponse retrieve(String creditNoteId, CreditNoteRetrie return CreditNoteRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for creditNote with params. */ + public CompletableFuture retrieveAsync( + String creditNoteId, CreditNoteRetrieveParams params) { + String path = + buildPathWithParams("/credit_notes/{credit-note-id}", "credit-note-id", creditNoteId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> CreditNoteRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + public CreditNoteRetrieveResponse retrieve(String creditNoteId) throws ChargebeeException { Response response = retrieveRaw(creditNoteId); return CreditNoteRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for creditNote without params. */ + public CompletableFuture retrieveAsync(String creditNoteId) { + String path = + buildPathWithParams("/credit_notes/{credit-note-id}", "credit-note-id", creditNoteId); + + return getAsync(path, null) + .thenApply( + response -> CreditNoteRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CsvTaxRuleService.java b/src/main/java/com/chargebee/v4/services/CsvTaxRuleService.java index 0dd52a44..fba8beb3 100644 --- a/src/main/java/com/chargebee/v4/services/CsvTaxRuleService.java +++ b/src/main/java/com/chargebee/v4/services/CsvTaxRuleService.java @@ -11,6 +11,7 @@ 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.csvTaxRule.params.CsvTaxRuleCreateParams; @@ -67,4 +68,12 @@ public CsvTaxRuleCreateResponse create(CsvTaxRuleCreateParams params) throws Cha return CsvTaxRuleCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for csvTaxRule with params. */ + public CompletableFuture createAsync(CsvTaxRuleCreateParams params) { + + return postAsync("/csv_tax_rules", params != null ? params.toFormData() : null) + .thenApply( + response -> CsvTaxRuleCreateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CurrencyService.java b/src/main/java/com/chargebee/v4/services/CurrencyService.java index 50f4a218..47f2dc59 100644 --- a/src/main/java/com/chargebee/v4/services/CurrencyService.java +++ b/src/main/java/com/chargebee/v4/services/CurrencyService.java @@ -11,6 +11,7 @@ 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.currency.params.CurrencyAddScheduleParams; @@ -102,6 +103,17 @@ public CurrencyAddScheduleResponse addSchedule( return CurrencyAddScheduleResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addSchedule for currency with params. */ + public CompletableFuture addScheduleAsync( + String siteCurrencyId, CurrencyAddScheduleParams params) { + String path = + buildPathWithParams( + "/currencies/{site-currency-id}/add_schedule", "site-currency-id", siteCurrencyId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CurrencyAddScheduleResponse.fromJson(response.getBodyAsString(), response)); + } + /** create a currency using immutable params (executes immediately) - returns raw Response. */ Response createRaw(CurrencyCreateParams params) throws ChargebeeException { @@ -120,6 +132,14 @@ public CurrencyCreateResponse create(CurrencyCreateParams params) throws Chargeb return CurrencyCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for currency with params. */ + public CompletableFuture createAsync(CurrencyCreateParams params) { + + return postAsync("/currencies", params != null ? params.toFormData() : null) + .thenApply( + response -> CurrencyCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a currency (executes immediately) - returns raw Response. */ Response retrieveRaw(String siteCurrencyId) throws ChargebeeException { String path = @@ -133,6 +153,16 @@ public CurrencyRetrieveResponse retrieve(String siteCurrencyId) throws Chargebee return CurrencyRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for currency without params. */ + public CompletableFuture retrieveAsync(String siteCurrencyId) { + String path = + buildPathWithParams("/currencies/{site-currency-id}", "site-currency-id", siteCurrencyId); + + return getAsync(path, null) + .thenApply( + response -> CurrencyRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a currency (executes immediately) - returns raw Response. */ Response updateRaw(String siteCurrencyId) throws ChargebeeException { String path = @@ -161,6 +191,16 @@ public CurrencyUpdateResponse update(String siteCurrencyId, CurrencyUpdateParams return CurrencyUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for currency with params. */ + public CompletableFuture updateAsync( + String siteCurrencyId, CurrencyUpdateParams params) { + String path = + buildPathWithParams("/currencies/{site-currency-id}", "site-currency-id", siteCurrencyId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CurrencyUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** removeSchedule a currency (executes immediately) - returns raw Response. */ Response removeScheduleRaw(String siteCurrencyId) throws ChargebeeException { String path = @@ -176,6 +216,19 @@ public CurrencyRemoveScheduleResponse removeSchedule(String siteCurrencyId) return CurrencyRemoveScheduleResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeSchedule for currency without params. */ + public CompletableFuture removeScheduleAsync( + String siteCurrencyId) { + String path = + buildPathWithParams( + "/currencies/{site-currency-id}/remove_schedule", "site-currency-id", siteCurrencyId); + + return postAsync(path, null) + .thenApply( + response -> + CurrencyRemoveScheduleResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a currency using immutable params (executes immediately) - returns raw Response. */ Response listRaw(CurrencyListParams params) throws ChargebeeException { @@ -200,9 +253,27 @@ public CurrencyListResponse list(CurrencyListParams params) throws ChargebeeExce return CurrencyListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for currency with params. */ + public CompletableFuture listAsync(CurrencyListParams params) { + + return getAsync("/currencies/list", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CurrencyListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public CurrencyListResponse list() throws ChargebeeException { Response response = listRaw(); return CurrencyListResponse.fromJson(response.getBodyAsString(), this, null, response); } + + /** Async variant of list for currency without params. */ + public CompletableFuture listAsync() { + + return getAsync("/currencies/list", null) + .thenApply( + response -> + CurrencyListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CustomerEntitlementService.java b/src/main/java/com/chargebee/v4/services/CustomerEntitlementService.java index 22fcbe72..44d6369a 100644 --- a/src/main/java/com/chargebee/v4/services/CustomerEntitlementService.java +++ b/src/main/java/com/chargebee/v4/services/CustomerEntitlementService.java @@ -11,6 +11,7 @@ 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.customerEntitlement.params.CustomerEntitlementEntitlementsForCustomerParams; @@ -101,4 +102,31 @@ public CustomerEntitlementEntitlementsForCustomerResponse entitlementsForCustome return CustomerEntitlementEntitlementsForCustomerResponse.fromJson( response.getBodyAsString(), this, null, customerId, response); } + + /** Async variant of entitlementsForCustomer for customerEntitlement with params. */ + public CompletableFuture + entitlementsForCustomerAsync( + String customerId, CustomerEntitlementEntitlementsForCustomerParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/customer_entitlements", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CustomerEntitlementEntitlementsForCustomerResponse.fromJson( + response.getBodyAsString(), this, params, customerId, response)); + } + + /** Async variant of entitlementsForCustomer for customerEntitlement without params. */ + public CompletableFuture + entitlementsForCustomerAsync(String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/customer_entitlements", "customer-id", customerId); + return getAsync(path, null) + .thenApply( + response -> + CustomerEntitlementEntitlementsForCustomerResponse.fromJson( + response.getBodyAsString(), this, null, customerId, response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/CustomerService.java b/src/main/java/com/chargebee/v4/services/CustomerService.java index 30e53484..6522451d 100644 --- a/src/main/java/com/chargebee/v4/services/CustomerService.java +++ b/src/main/java/com/chargebee/v4/services/CustomerService.java @@ -11,6 +11,7 @@ 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.customer.params.CustomerDeleteParams; @@ -169,11 +170,29 @@ public CustomerDeleteResponse delete(String customerId, CustomerDeleteParams par return CustomerDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for customer with params. */ + public CompletableFuture deleteAsync( + String customerId, CustomerDeleteParams params) { + String path = buildPathWithParams("/customers/{customer-id}/delete", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CustomerDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerDeleteResponse delete(String customerId) throws ChargebeeException { Response response = deleteRaw(customerId); return CustomerDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for customer without params. */ + public CompletableFuture deleteAsync(String customerId) { + String path = buildPathWithParams("/customers/{customer-id}/delete", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> CustomerDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** addPromotionalCredits a customer (executes immediately) - returns raw Response. */ Response addPromotionalCreditsRaw(String customerId) throws ChargebeeException { String path = @@ -213,6 +232,19 @@ public CustomerAddPromotionalCreditsResponse addPromotionalCredits( return CustomerAddPromotionalCreditsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addPromotionalCredits for customer with params. */ + public CompletableFuture addPromotionalCreditsAsync( + String customerId, CustomerAddPromotionalCreditsParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/add_promotional_credits", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerAddPromotionalCreditsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** relationships a customer (executes immediately) - returns raw Response. */ Response relationshipsRaw(String customerId) throws ChargebeeException { String path = @@ -246,11 +278,33 @@ public CustomerRelationshipsResponse relationships( return CustomerRelationshipsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of relationships for customer with params. */ + public CompletableFuture relationshipsAsync( + String customerId, CustomerRelationshipsParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/relationships", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerRelationshipsResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerRelationshipsResponse relationships(String customerId) throws ChargebeeException { Response response = relationshipsRaw(customerId); return CustomerRelationshipsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of relationships for customer without params. */ + public CompletableFuture relationshipsAsync(String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/relationships", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerRelationshipsResponse.fromJson(response.getBodyAsString(), response)); + } + /** deleteRelationship a customer (executes immediately) - returns raw Response. */ Response deleteRelationshipRaw(String customerId) throws ChargebeeException { String path = @@ -266,6 +320,19 @@ public CustomerDeleteRelationshipResponse deleteRelationship(String customerId) return CustomerDeleteRelationshipResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteRelationship for customer without params. */ + public CompletableFuture deleteRelationshipAsync( + String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/delete_relationship", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerDeleteRelationshipResponse.fromJson(response.getBodyAsString(), response)); + } + /** deleteContact a customer (executes immediately) - returns raw Response. */ Response deleteContactRaw(String customerId) throws ChargebeeException { String path = @@ -299,11 +366,33 @@ public CustomerDeleteContactResponse deleteContact( return CustomerDeleteContactResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteContact for customer with params. */ + public CompletableFuture deleteContactAsync( + String customerId, CustomerDeleteContactParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/delete_contact", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerDeleteContactResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerDeleteContactResponse deleteContact(String customerId) throws ChargebeeException { Response response = deleteContactRaw(customerId); return CustomerDeleteContactResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteContact for customer without params. */ + public CompletableFuture deleteContactAsync(String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/delete_contact", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerDeleteContactResponse.fromJson(response.getBodyAsString(), response)); + } + /** assignPaymentRole a customer (executes immediately) - returns raw Response. */ Response assignPaymentRoleRaw(String customerId) throws ChargebeeException { String path = @@ -342,6 +431,18 @@ public CustomerAssignPaymentRoleResponse assignPaymentRole( return CustomerAssignPaymentRoleResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of assignPaymentRole for customer with params. */ + public CompletableFuture assignPaymentRoleAsync( + String customerId, CustomerAssignPaymentRoleParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/assign_payment_role", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerAssignPaymentRoleResponse.fromJson(response.getBodyAsString(), response)); + } + /** move a customer using immutable params (executes immediately) - returns raw Response. */ Response moveRaw(CustomerMoveParams params) throws ChargebeeException { @@ -360,6 +461,13 @@ public CustomerMoveResponse move(CustomerMoveParams params) throws ChargebeeExce return CustomerMoveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of move for customer with params. */ + public CompletableFuture moveAsync(CustomerMoveParams params) { + + return postAsync("/customers/move", params != null ? params.toFormData() : null) + .thenApply(response -> CustomerMoveResponse.fromJson(response.getBodyAsString(), response)); + } + /** hierarchy a customer (executes immediately) - returns raw Response. */ Response hierarchyRaw(String customerId) throws ChargebeeException { String path = @@ -382,11 +490,31 @@ public CustomerHierarchyResponse hierarchy(String customerId, CustomerHierarchyP return CustomerHierarchyResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of hierarchy for customer with params. */ + public CompletableFuture hierarchyAsync( + String customerId, CustomerHierarchyParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/hierarchy", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> CustomerHierarchyResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerHierarchyResponse hierarchy(String customerId) throws ChargebeeException { Response response = hierarchyRaw(customerId); return CustomerHierarchyResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of hierarchy for customer without params. */ + public CompletableFuture hierarchyAsync(String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/hierarchy", "customer-id", customerId); + + return getAsync(path, null) + .thenApply( + response -> CustomerHierarchyResponse.fromJson(response.getBodyAsString(), response)); + } + /** updatePaymentMethod a customer (executes immediately) - returns raw Response. */ Response updatePaymentMethodRaw(String customerId) throws ChargebeeException { String path = @@ -425,12 +553,37 @@ public CustomerUpdatePaymentMethodResponse updatePaymentMethod( return CustomerUpdatePaymentMethodResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updatePaymentMethod for customer with params. */ + public CompletableFuture updatePaymentMethodAsync( + String customerId, CustomerUpdatePaymentMethodParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/update_payment_method", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerUpdatePaymentMethodResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerUpdatePaymentMethodResponse updatePaymentMethod(String customerId) throws ChargebeeException { Response response = updatePaymentMethodRaw(customerId); return CustomerUpdatePaymentMethodResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updatePaymentMethod for customer without params. */ + public CompletableFuture updatePaymentMethodAsync( + String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/update_payment_method", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerUpdatePaymentMethodResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a customer (executes immediately) - returns raw Response. */ Response retrieveRaw(String customerId) throws ChargebeeException { String path = buildPathWithParams("/customers/{customer-id}", "customer-id", customerId); @@ -443,6 +596,15 @@ public CustomerRetrieveResponse retrieve(String customerId) throws ChargebeeExce return CustomerRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for customer without params. */ + public CompletableFuture retrieveAsync(String customerId) { + String path = buildPathWithParams("/customers/{customer-id}", "customer-id", customerId); + + return getAsync(path, null) + .thenApply( + response -> CustomerRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a customer (executes immediately) - returns raw Response. */ Response updateRaw(String customerId) throws ChargebeeException { String path = buildPathWithParams("/customers/{customer-id}", "customer-id", customerId); @@ -468,11 +630,29 @@ public CustomerUpdateResponse update(String customerId, CustomerUpdateParams par return CustomerUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for customer with params. */ + public CompletableFuture updateAsync( + String customerId, CustomerUpdateParams params) { + String path = buildPathWithParams("/customers/{customer-id}", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CustomerUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerUpdateResponse update(String customerId) throws ChargebeeException { Response response = updateRaw(customerId); return CustomerUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for customer without params. */ + public CompletableFuture updateAsync(String customerId) { + String path = buildPathWithParams("/customers/{customer-id}", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> CustomerUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * listHierarchyDetail a customer using immutable params (executes immediately) - returns raw * Response. @@ -517,6 +697,30 @@ public CustomerListHierarchyDetailResponse listHierarchyDetail(String customerId response.getBodyAsString(), this, null, customerId, response); } + /** Async variant of listHierarchyDetail for customer with params. */ + public CompletableFuture listHierarchyDetailAsync( + String customerId, CustomerListHierarchyDetailParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/hierarchy_detail", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CustomerListHierarchyDetailResponse.fromJson( + response.getBodyAsString(), this, params, customerId, response)); + } + + /** Async variant of listHierarchyDetail for customer without params. */ + public CompletableFuture listHierarchyDetailAsync( + String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/hierarchy_detail", "customer-id", customerId); + return getAsync(path, null) + .thenApply( + response -> + CustomerListHierarchyDetailResponse.fromJson( + response.getBodyAsString(), this, null, customerId, response)); + } + /** changeBillingDate a customer (executes immediately) - returns raw Response. */ Response changeBillingDateRaw(String customerId) throws ChargebeeException { String path = @@ -555,12 +759,37 @@ public CustomerChangeBillingDateResponse changeBillingDate( return CustomerChangeBillingDateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of changeBillingDate for customer with params. */ + public CompletableFuture changeBillingDateAsync( + String customerId, CustomerChangeBillingDateParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/change_billing_date", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerChangeBillingDateResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerChangeBillingDateResponse changeBillingDate(String customerId) throws ChargebeeException { Response response = changeBillingDateRaw(customerId); return CustomerChangeBillingDateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of changeBillingDate for customer without params. */ + public CompletableFuture changeBillingDateAsync( + String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/change_billing_date", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerChangeBillingDateResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a customer using immutable params (executes immediately) - returns raw Response. */ Response listRaw(CustomerListParams params) throws ChargebeeException { @@ -585,12 +814,30 @@ public CustomerListResponse list(CustomerListParams params) throws ChargebeeExce return CustomerListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for customer with params. */ + public CompletableFuture listAsync(CustomerListParams params) { + + return getAsync("/customers", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CustomerListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public CustomerListResponse list() throws ChargebeeException { Response response = listRaw(); return CustomerListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for customer without params. */ + public CompletableFuture listAsync() { + + return getAsync("/customers", null) + .thenApply( + response -> + CustomerListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a customer using immutable params (executes immediately) - returns raw Response. */ Response createRaw(CustomerCreateParams params) throws ChargebeeException { @@ -609,6 +856,14 @@ public CustomerCreateResponse create(CustomerCreateParams params) throws Chargeb return CustomerCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for customer with params. */ + public CompletableFuture createAsync(CustomerCreateParams params) { + + return postAsync("/customers", params != null ? params.toFormData() : null) + .thenApply( + response -> CustomerCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** addContact a customer (executes immediately) - returns raw Response. */ Response addContactRaw(String customerId) throws ChargebeeException { String path = @@ -638,11 +893,31 @@ public CustomerAddContactResponse addContact(String customerId, CustomerAddConta return CustomerAddContactResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addContact for customer with params. */ + public CompletableFuture addContactAsync( + String customerId, CustomerAddContactParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/add_contact", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> CustomerAddContactResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerAddContactResponse addContact(String customerId) throws ChargebeeException { Response response = addContactRaw(customerId); return CustomerAddContactResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addContact for customer without params. */ + public CompletableFuture addContactAsync(String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/add_contact", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> CustomerAddContactResponse.fromJson(response.getBodyAsString(), response)); + } + /** * contactsForCustomer a customer using immutable params (executes immediately) - returns raw * Response. @@ -687,6 +962,30 @@ public ContactsForCustomerResponse contactsForCustomer(String customerId) response.getBodyAsString(), this, null, customerId, response); } + /** Async variant of contactsForCustomer for customer with params. */ + public CompletableFuture contactsForCustomerAsync( + String customerId, ContactsForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/contacts", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ContactsForCustomerResponse.fromJson( + response.getBodyAsString(), this, params, customerId, response)); + } + + /** Async variant of contactsForCustomer for customer without params. */ + public CompletableFuture contactsForCustomerAsync( + String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/contacts", "customer-id", customerId); + return getAsync(path, null) + .thenApply( + response -> + ContactsForCustomerResponse.fromJson( + response.getBodyAsString(), this, null, customerId, response)); + } + /** deductPromotionalCredits a customer (executes immediately) - returns raw Response. */ Response deductPromotionalCreditsRaw(String customerId) throws ChargebeeException { String path = @@ -726,6 +1025,19 @@ public CustomerDeductPromotionalCreditsResponse deductPromotionalCredits( return CustomerDeductPromotionalCreditsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deductPromotionalCredits for customer with params. */ + public CompletableFuture deductPromotionalCreditsAsync( + String customerId, CustomerDeductPromotionalCreditsParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/deduct_promotional_credits", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerDeductPromotionalCreditsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** clearPersonalData a customer (executes immediately) - returns raw Response. */ Response clearPersonalDataRaw(String customerId) throws ChargebeeException { String path = @@ -741,6 +1053,19 @@ public CustomerClearPersonalDataResponse clearPersonalData(String customerId) return CustomerClearPersonalDataResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of clearPersonalData for customer without params. */ + public CompletableFuture clearPersonalDataAsync( + String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/clear_personal_data", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerClearPersonalDataResponse.fromJson(response.getBodyAsString(), response)); + } + /** merge a customer using immutable params (executes immediately) - returns raw Response. */ Response mergeRaw(CustomerMergeParams params) throws ChargebeeException { @@ -759,6 +1084,14 @@ public CustomerMergeResponse merge(CustomerMergeParams params) throws ChargebeeE return CustomerMergeResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of merge for customer with params. */ + public CompletableFuture mergeAsync(CustomerMergeParams params) { + + return postAsync("/customers/merge", params != null ? params.toFormData() : null) + .thenApply( + response -> CustomerMergeResponse.fromJson(response.getBodyAsString(), response)); + } + /** collectPayment a customer (executes immediately) - returns raw Response. */ Response collectPaymentRaw(String customerId) throws ChargebeeException { String path = @@ -792,12 +1125,34 @@ public CustomerCollectPaymentResponse collectPayment( return CustomerCollectPaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of collectPayment for customer with params. */ + public CompletableFuture collectPaymentAsync( + String customerId, CustomerCollectPaymentParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/collect_payment", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerCollectPaymentResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerCollectPaymentResponse collectPayment(String customerId) throws ChargebeeException { Response response = collectPaymentRaw(customerId); return CustomerCollectPaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of collectPayment for customer without params. */ + public CompletableFuture collectPaymentAsync(String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/collect_payment", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerCollectPaymentResponse.fromJson(response.getBodyAsString(), response)); + } + /** recordExcessPayment a customer (executes immediately) - returns raw Response. */ Response recordExcessPaymentRaw(String customerId) throws ChargebeeException { String path = @@ -836,12 +1191,37 @@ public CustomerRecordExcessPaymentResponse recordExcessPayment( return CustomerRecordExcessPaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordExcessPayment for customer with params. */ + public CompletableFuture recordExcessPaymentAsync( + String customerId, CustomerRecordExcessPaymentParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/record_excess_payment", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerRecordExcessPaymentResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerRecordExcessPaymentResponse recordExcessPayment(String customerId) throws ChargebeeException { Response response = recordExcessPaymentRaw(customerId); return CustomerRecordExcessPaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordExcessPayment for customer without params. */ + public CompletableFuture recordExcessPaymentAsync( + String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/record_excess_payment", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerRecordExcessPaymentResponse.fromJson(response.getBodyAsString(), response)); + } + /** setPromotionalCredits a customer (executes immediately) - returns raw Response. */ Response setPromotionalCreditsRaw(String customerId) throws ChargebeeException { String path = @@ -881,6 +1261,19 @@ public CustomerSetPromotionalCreditsResponse setPromotionalCredits( return CustomerSetPromotionalCreditsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of setPromotionalCredits for customer with params. */ + public CompletableFuture setPromotionalCreditsAsync( + String customerId, CustomerSetPromotionalCreditsParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/set_promotional_credits", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerSetPromotionalCreditsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** updateContact a customer (executes immediately) - returns raw Response. */ Response updateContactRaw(String customerId) throws ChargebeeException { String path = @@ -914,11 +1307,33 @@ public CustomerUpdateContactResponse updateContact( return CustomerUpdateContactResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateContact for customer with params. */ + public CompletableFuture updateContactAsync( + String customerId, CustomerUpdateContactParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/update_contact", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerUpdateContactResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerUpdateContactResponse updateContact(String customerId) throws ChargebeeException { Response response = updateContactRaw(customerId); return CustomerUpdateContactResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateContact for customer without params. */ + public CompletableFuture updateContactAsync(String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/update_contact", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerUpdateContactResponse.fromJson(response.getBodyAsString(), response)); + } + /** updateHierarchySettings a customer (executes immediately) - returns raw Response. */ Response updateHierarchySettingsRaw(String customerId) throws ChargebeeException { String path = @@ -958,12 +1373,39 @@ public CustomerUpdateHierarchySettingsResponse updateHierarchySettings( return CustomerUpdateHierarchySettingsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateHierarchySettings for customer with params. */ + public CompletableFuture updateHierarchySettingsAsync( + String customerId, CustomerUpdateHierarchySettingsParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/update_hierarchy_settings", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerUpdateHierarchySettingsResponse.fromJson( + response.getBodyAsString(), response)); + } + public CustomerUpdateHierarchySettingsResponse updateHierarchySettings(String customerId) throws ChargebeeException { Response response = updateHierarchySettingsRaw(customerId); return CustomerUpdateHierarchySettingsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateHierarchySettings for customer without params. */ + public CompletableFuture updateHierarchySettingsAsync( + String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/update_hierarchy_settings", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerUpdateHierarchySettingsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** updateBillingInfo a customer (executes immediately) - returns raw Response. */ Response updateBillingInfoRaw(String customerId) throws ChargebeeException { String path = @@ -1002,9 +1444,34 @@ public CustomerUpdateBillingInfoResponse updateBillingInfo( return CustomerUpdateBillingInfoResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateBillingInfo for customer with params. */ + public CompletableFuture updateBillingInfoAsync( + String customerId, CustomerUpdateBillingInfoParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/update_billing_info", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CustomerUpdateBillingInfoResponse.fromJson(response.getBodyAsString(), response)); + } + public CustomerUpdateBillingInfoResponse updateBillingInfo(String customerId) throws ChargebeeException { Response response = updateBillingInfoRaw(customerId); return CustomerUpdateBillingInfoResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of updateBillingInfo for customer without params. */ + public CompletableFuture updateBillingInfoAsync( + String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/update_billing_info", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CustomerUpdateBillingInfoResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/DifferentialPriceService.java b/src/main/java/com/chargebee/v4/services/DifferentialPriceService.java index 787751f6..d329924b 100644 --- a/src/main/java/com/chargebee/v4/services/DifferentialPriceService.java +++ b/src/main/java/com/chargebee/v4/services/DifferentialPriceService.java @@ -11,6 +11,7 @@ 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.differentialPrice.params.DifferentialPriceDeleteParams; @@ -111,6 +112,20 @@ public DifferentialPriceDeleteResponse delete( return DifferentialPriceDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for differentialPrice with params. */ + public CompletableFuture deleteAsync( + String differentialPriceId, DifferentialPriceDeleteParams params) { + String path = + buildPathWithParams( + "/differential_prices/{differential-price-id}/delete", + "differential-price-id", + differentialPriceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + DifferentialPriceDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** create a differentialPrice (executes immediately) - returns raw Response. */ Response createRaw(String itemPriceId) throws ChargebeeException { String path = @@ -149,6 +164,18 @@ public DifferentialPriceCreateResponse create( return DifferentialPriceCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for differentialPrice with params. */ + public CompletableFuture createAsync( + String itemPriceId, DifferentialPriceCreateParams params) { + String path = + buildPathWithParams( + "/item_prices/{item-price-id}/differential_prices", "item-price-id", itemPriceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + DifferentialPriceCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * list a differentialPrice using immutable params (executes immediately) - returns raw Response. */ @@ -179,12 +206,33 @@ public DifferentialPriceListResponse list(DifferentialPriceListParams params) response.getBodyAsString(), this, params, response); } + /** Async variant of list for differentialPrice with params. */ + public CompletableFuture listAsync( + DifferentialPriceListParams params) { + + return getAsync("/differential_prices", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + DifferentialPriceListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public DifferentialPriceListResponse list() throws ChargebeeException { Response response = listRaw(); return DifferentialPriceListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for differentialPrice without params. */ + public CompletableFuture listAsync() { + + return getAsync("/differential_prices", null) + .thenApply( + response -> + DifferentialPriceListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** retrieve a differentialPrice (executes immediately) - returns raw Response. */ Response retrieveRaw(String differentialPriceId) throws ChargebeeException { String path = @@ -217,12 +265,41 @@ public DifferentialPriceRetrieveResponse retrieve( return DifferentialPriceRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for differentialPrice with params. */ + public CompletableFuture retrieveAsync( + String differentialPriceId, DifferentialPriceRetrieveParams params) { + String path = + buildPathWithParams( + "/differential_prices/{differential-price-id}", + "differential-price-id", + differentialPriceId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + DifferentialPriceRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + public DifferentialPriceRetrieveResponse retrieve(String differentialPriceId) throws ChargebeeException { Response response = retrieveRaw(differentialPriceId); return DifferentialPriceRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for differentialPrice without params. */ + public CompletableFuture retrieveAsync( + String differentialPriceId) { + String path = + buildPathWithParams( + "/differential_prices/{differential-price-id}", + "differential-price-id", + differentialPriceId); + + return getAsync(path, null) + .thenApply( + response -> + DifferentialPriceRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a differentialPrice (executes immediately) - returns raw Response. */ Response updateRaw(String differentialPriceId) throws ChargebeeException { String path = @@ -266,4 +343,18 @@ public DifferentialPriceUpdateResponse update( Response response = updateRaw(differentialPriceId, params); return DifferentialPriceUpdateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of update for differentialPrice with params. */ + public CompletableFuture updateAsync( + String differentialPriceId, DifferentialPriceUpdateParams params) { + String path = + buildPathWithParams( + "/differential_prices/{differential-price-id}", + "differential-price-id", + differentialPriceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + DifferentialPriceUpdateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/EntitlementOverrideService.java b/src/main/java/com/chargebee/v4/services/EntitlementOverrideService.java index f5cae8c1..a614d9a1 100644 --- a/src/main/java/com/chargebee/v4/services/EntitlementOverrideService.java +++ b/src/main/java/com/chargebee/v4/services/EntitlementOverrideService.java @@ -11,6 +11,7 @@ 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.entitlementOverride.params.ListEntitlementOverrideForSubscriptionParams; @@ -113,6 +114,41 @@ public ListEntitlementOverrideForSubscriptionResponse listEntitlementOverrideFor response.getBodyAsString(), this, null, subscriptionId, response); } + /** + * Async variant of listEntitlementOverrideForSubscription for entitlementOverride with params. + */ + public CompletableFuture + listEntitlementOverrideForSubscriptionAsync( + String subscriptionId, ListEntitlementOverrideForSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/entitlement_overrides", + "subscription-id", + subscriptionId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ListEntitlementOverrideForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, params, subscriptionId, response)); + } + + /** + * Async variant of listEntitlementOverrideForSubscription for entitlementOverride without params. + */ + public CompletableFuture + listEntitlementOverrideForSubscriptionAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/entitlement_overrides", + "subscription-id", + subscriptionId); + return getAsync(path, null) + .thenApply( + response -> + ListEntitlementOverrideForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, null, subscriptionId, response)); + } + /** * addEntitlementOverrideForSubscription a entitlementOverride (executes immediately) - returns * raw Response. @@ -165,10 +201,44 @@ public AddEntitlementOverrideForSubscriptionResponse addEntitlementOverrideForSu response.getBodyAsString(), response); } + /** Async variant of addEntitlementOverrideForSubscription for entitlementOverride with params. */ + public CompletableFuture + addEntitlementOverrideForSubscriptionAsync( + String subscriptionId, AddEntitlementOverrideForSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/entitlement_overrides", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + AddEntitlementOverrideForSubscriptionResponse.fromJson( + response.getBodyAsString(), response)); + } + public AddEntitlementOverrideForSubscriptionResponse addEntitlementOverrideForSubscription( String subscriptionId) throws ChargebeeException { Response response = addEntitlementOverrideForSubscriptionRaw(subscriptionId); return AddEntitlementOverrideForSubscriptionResponse.fromJson( response.getBodyAsString(), response); } + + /** + * Async variant of addEntitlementOverrideForSubscription for entitlementOverride without params. + */ + public CompletableFuture + addEntitlementOverrideForSubscriptionAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/entitlement_overrides", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + AddEntitlementOverrideForSubscriptionResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/EntitlementService.java b/src/main/java/com/chargebee/v4/services/EntitlementService.java index 3ec7663f..661233c4 100644 --- a/src/main/java/com/chargebee/v4/services/EntitlementService.java +++ b/src/main/java/com/chargebee/v4/services/EntitlementService.java @@ -11,6 +11,7 @@ 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.entitlement.params.EntitlementListParams; @@ -78,12 +79,31 @@ public EntitlementListResponse list(EntitlementListParams params) throws Chargeb return EntitlementListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for entitlement with params. */ + public CompletableFuture listAsync(EntitlementListParams params) { + + return getAsync("/entitlements", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + EntitlementListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public EntitlementListResponse list() throws ChargebeeException { Response response = listRaw(); return EntitlementListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for entitlement without params. */ + public CompletableFuture listAsync() { + + return getAsync("/entitlements", null) + .thenApply( + response -> + EntitlementListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a entitlement using immutable params (executes immediately) - returns raw Response. */ Response createRaw(EntitlementCreateParams params) throws ChargebeeException { @@ -102,4 +122,12 @@ public EntitlementCreateResponse create(EntitlementCreateParams params) return EntitlementCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for entitlement with params. */ + public CompletableFuture createAsync(EntitlementCreateParams params) { + + return postAsync("/entitlements", params != null ? params.toFormData() : null) + .thenApply( + response -> EntitlementCreateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/EstimateService.java b/src/main/java/com/chargebee/v4/services/EstimateService.java index 2a0dd879..0e9039ec 100644 --- a/src/main/java/com/chargebee/v4/services/EstimateService.java +++ b/src/main/java/com/chargebee/v4/services/EstimateService.java @@ -11,6 +11,7 @@ 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.estimate.params.RenewalEstimateParams; @@ -151,11 +152,33 @@ public RenewalEstimateResponse renewalEstimate( return RenewalEstimateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of renewalEstimate for estimate with params. */ + public CompletableFuture renewalEstimateAsync( + String subscriptionId, RenewalEstimateParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/renewal_estimate", "subscription-id", subscriptionId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> RenewalEstimateResponse.fromJson(response.getBodyAsString(), response)); + } + public RenewalEstimateResponse renewalEstimate(String subscriptionId) throws ChargebeeException { Response response = renewalEstimateRaw(subscriptionId); return RenewalEstimateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of renewalEstimate for estimate without params. */ + public CompletableFuture renewalEstimateAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/renewal_estimate", "subscription-id", subscriptionId); + + return getAsync(path, null) + .thenApply( + response -> RenewalEstimateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createSubscriptionItemEstimate a estimate using immutable params (executes immediately) - * returns raw Response. @@ -183,6 +206,18 @@ public CreateSubscriptionItemEstimateResponse createSubscriptionItemEstimate( return CreateSubscriptionItemEstimateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createSubscriptionItemEstimate for estimate with params. */ + public CompletableFuture + createSubscriptionItemEstimateAsync(CreateSubscriptionItemEstimateParams params) { + + return postAsync( + "/estimates/create_subscription_for_items", params != null ? params.toFormData() : null) + .thenApply( + response -> + CreateSubscriptionItemEstimateResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * paymentSchedules a estimate using immutable params (executes immediately) - returns raw * Response. @@ -208,6 +243,16 @@ public EstimatePaymentSchedulesResponse paymentSchedules(EstimatePaymentSchedule return EstimatePaymentSchedulesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of paymentSchedules for estimate with params. */ + public CompletableFuture paymentSchedulesAsync( + EstimatePaymentSchedulesParams params) { + + return postAsync("/estimates/payment_schedules", params != null ? params.toFormData() : null) + .thenApply( + response -> + EstimatePaymentSchedulesResponse.fromJson(response.getBodyAsString(), response)); + } + /** cancelSubscriptionForItems a estimate (executes immediately) - returns raw Response. */ Response cancelSubscriptionForItemsRaw(String subscriptionId) throws ChargebeeException { String path = @@ -256,6 +301,22 @@ public EstimateCancelSubscriptionForItemsResponse cancelSubscriptionForItems( response.getBodyAsString(), response); } + /** Async variant of cancelSubscriptionForItems for estimate with params. */ + public CompletableFuture + cancelSubscriptionForItemsAsync( + String subscriptionId, EstimateCancelSubscriptionForItemsParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/cancel_subscription_for_items_estimate", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + EstimateCancelSubscriptionForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + public EstimateCancelSubscriptionForItemsResponse cancelSubscriptionForItems( String subscriptionId) throws ChargebeeException { Response response = cancelSubscriptionForItemsRaw(subscriptionId); @@ -263,6 +324,22 @@ public EstimateCancelSubscriptionForItemsResponse cancelSubscriptionForItems( response.getBodyAsString(), response); } + /** Async variant of cancelSubscriptionForItems for estimate without params. */ + public CompletableFuture + cancelSubscriptionForItemsAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/cancel_subscription_for_items_estimate", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + EstimateCancelSubscriptionForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** resumeSubscription a estimate (executes immediately) - returns raw Response. */ Response resumeSubscriptionRaw(String subscriptionId) throws ChargebeeException { String path = @@ -308,12 +385,41 @@ public EstimateResumeSubscriptionResponse resumeSubscription( return EstimateResumeSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resumeSubscription for estimate with params. */ + public CompletableFuture resumeSubscriptionAsync( + String subscriptionId, EstimateResumeSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/resume_subscription_estimate", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + EstimateResumeSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + public EstimateResumeSubscriptionResponse resumeSubscription(String subscriptionId) throws ChargebeeException { Response response = resumeSubscriptionRaw(subscriptionId); return EstimateResumeSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resumeSubscription for estimate without params. */ + public CompletableFuture resumeSubscriptionAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/resume_subscription_estimate", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + EstimateResumeSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createInvoiceForItems a estimate using immutable params (executes immediately) - returns raw * Response. @@ -340,6 +446,18 @@ public EstimateCreateInvoiceForItemsResponse createInvoiceForItems( return EstimateCreateInvoiceForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createInvoiceForItems for estimate with params. */ + public CompletableFuture createInvoiceForItemsAsync( + EstimateCreateInvoiceForItemsParams params) { + + return postAsync( + "/estimates/create_invoice_for_items", params != null ? params.toFormData() : null) + .thenApply( + response -> + EstimateCreateInvoiceForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * giftSubscriptionForItems a estimate using immutable params (executes immediately) - returns raw * Response. @@ -367,6 +485,18 @@ public EstimateGiftSubscriptionForItemsResponse giftSubscriptionForItems( return EstimateGiftSubscriptionForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of giftSubscriptionForItems for estimate with params. */ + public CompletableFuture giftSubscriptionForItemsAsync( + EstimateGiftSubscriptionForItemsParams params) { + + return postAsync( + "/estimates/gift_subscription_for_items", params != null ? params.toFormData() : null) + .thenApply( + response -> + EstimateGiftSubscriptionForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * updateSubscriptionForItems a estimate using immutable params (executes immediately) - returns * raw Response. @@ -395,6 +525,18 @@ public EstimateUpdateSubscriptionForItemsResponse updateSubscriptionForItems( response.getBodyAsString(), response); } + /** Async variant of updateSubscriptionForItems for estimate with params. */ + public CompletableFuture + updateSubscriptionForItemsAsync(EstimateUpdateSubscriptionForItemsParams params) { + + return postAsync( + "/estimates/update_subscription_for_items", params != null ? params.toFormData() : null) + .thenApply( + response -> + EstimateUpdateSubscriptionForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** upcomingInvoicesEstimate a estimate (executes immediately) - returns raw Response. */ Response upcomingInvoicesEstimateRaw(String customerId) throws ChargebeeException { String path = @@ -410,6 +552,19 @@ public UpcomingInvoicesEstimateResponse upcomingInvoicesEstimate(String customer return UpcomingInvoicesEstimateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of upcomingInvoicesEstimate for estimate without params. */ + public CompletableFuture upcomingInvoicesEstimateAsync( + String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/upcoming_invoices_estimate", "customer-id", customerId); + + return getAsync(path, null) + .thenApply( + response -> + UpcomingInvoicesEstimateResponse.fromJson(response.getBodyAsString(), response)); + } + /** regenerateInvoiceEstimate a estimate (executes immediately) - returns raw Response. */ Response regenerateInvoiceEstimateRaw(String subscriptionId) throws ChargebeeException { String path = @@ -455,12 +610,41 @@ public RegenerateInvoiceEstimateResponse regenerateInvoiceEstimate( return RegenerateInvoiceEstimateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of regenerateInvoiceEstimate for estimate with params. */ + public CompletableFuture regenerateInvoiceEstimateAsync( + String subscriptionId, RegenerateInvoiceEstimateParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/regenerate_invoice_estimate", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + RegenerateInvoiceEstimateResponse.fromJson(response.getBodyAsString(), response)); + } + public RegenerateInvoiceEstimateResponse regenerateInvoiceEstimate(String subscriptionId) throws ChargebeeException { Response response = regenerateInvoiceEstimateRaw(subscriptionId); return RegenerateInvoiceEstimateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of regenerateInvoiceEstimate for estimate without params. */ + public CompletableFuture regenerateInvoiceEstimateAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/regenerate_invoice_estimate", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + RegenerateInvoiceEstimateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createSubscriptionItemForCustomerEstimate a estimate (executes immediately) - returns raw * Response. @@ -514,6 +698,22 @@ Response createSubscriptionItemForCustomerEstimateRaw(String customerId, String response.getBodyAsString(), response); } + /** Async variant of createSubscriptionItemForCustomerEstimate for estimate with params. */ + public CompletableFuture + createSubscriptionItemForCustomerEstimateAsync( + String customerId, CreateSubscriptionItemForCustomerEstimateParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/create_subscription_for_items_estimate", + "customer-id", + customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CreateSubscriptionItemForCustomerEstimateResponse.fromJson( + response.getBodyAsString(), response)); + } + public CreateSubscriptionItemForCustomerEstimateResponse createSubscriptionItemForCustomerEstimate(String customerId) throws ChargebeeException { Response response = createSubscriptionItemForCustomerEstimateRaw(customerId); @@ -521,6 +721,22 @@ Response createSubscriptionItemForCustomerEstimateRaw(String customerId, String response.getBodyAsString(), response); } + /** Async variant of createSubscriptionItemForCustomerEstimate for estimate without params. */ + public CompletableFuture + createSubscriptionItemForCustomerEstimateAsync(String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/create_subscription_for_items_estimate", + "customer-id", + customerId); + + return postAsync(path, null) + .thenApply( + response -> + CreateSubscriptionItemForCustomerEstimateResponse.fromJson( + response.getBodyAsString(), response)); + } + /** changeTermEnd a estimate (executes immediately) - returns raw Response. */ Response changeTermEndRaw(String subscriptionId) throws ChargebeeException { String path = @@ -563,6 +779,20 @@ public EstimateChangeTermEndResponse changeTermEnd( return EstimateChangeTermEndResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of changeTermEnd for estimate with params. */ + public CompletableFuture changeTermEndAsync( + String subscriptionId, EstimateChangeTermEndParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/change_term_end_estimate", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + EstimateChangeTermEndResponse.fromJson(response.getBodyAsString(), response)); + } + /** pauseSubscription a estimate (executes immediately) - returns raw Response. */ Response pauseSubscriptionRaw(String subscriptionId) throws ChargebeeException { String path = @@ -608,12 +838,41 @@ public EstimatePauseSubscriptionResponse pauseSubscription( return EstimatePauseSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pauseSubscription for estimate with params. */ + public CompletableFuture pauseSubscriptionAsync( + String subscriptionId, EstimatePauseSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/pause_subscription_estimate", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + EstimatePauseSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + public EstimatePauseSubscriptionResponse pauseSubscription(String subscriptionId) throws ChargebeeException { Response response = pauseSubscriptionRaw(subscriptionId); return EstimatePauseSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pauseSubscription for estimate without params. */ + public CompletableFuture pauseSubscriptionAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/pause_subscription_estimate", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + EstimatePauseSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + /** advanceInvoiceEstimate a estimate (executes immediately) - returns raw Response. */ Response advanceInvoiceEstimateRaw(String subscriptionId) throws ChargebeeException { String path = @@ -659,12 +918,41 @@ public AdvanceInvoiceEstimateResponse advanceInvoiceEstimate( return AdvanceInvoiceEstimateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of advanceInvoiceEstimate for estimate with params. */ + public CompletableFuture advanceInvoiceEstimateAsync( + String subscriptionId, AdvanceInvoiceEstimateParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/advance_invoice_estimate", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + AdvanceInvoiceEstimateResponse.fromJson(response.getBodyAsString(), response)); + } + public AdvanceInvoiceEstimateResponse advanceInvoiceEstimate(String subscriptionId) throws ChargebeeException { Response response = advanceInvoiceEstimateRaw(subscriptionId); return AdvanceInvoiceEstimateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of advanceInvoiceEstimate for estimate without params. */ + public CompletableFuture advanceInvoiceEstimateAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/advance_invoice_estimate", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + AdvanceInvoiceEstimateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * updateSubscription a estimate using immutable params (executes immediately) - returns raw * Response. @@ -691,6 +979,16 @@ public EstimateUpdateSubscriptionResponse updateSubscription( return EstimateUpdateSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateSubscription for estimate with params. */ + public CompletableFuture updateSubscriptionAsync( + EstimateUpdateSubscriptionParams params) { + + return postAsync("/estimates/update_subscription", params != null ? params.toFormData() : null) + .thenApply( + response -> + EstimateUpdateSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + /** * giftSubscription a estimate using immutable params (executes immediately) - returns raw * Response. @@ -716,6 +1014,16 @@ public EstimateGiftSubscriptionResponse giftSubscription(EstimateGiftSubscriptio return EstimateGiftSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of giftSubscription for estimate with params. */ + public CompletableFuture giftSubscriptionAsync( + EstimateGiftSubscriptionParams params) { + + return postAsync("/estimates/gift_subscription", params != null ? params.toFormData() : null) + .thenApply( + response -> + EstimateGiftSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createSubscriptionForCustomerEstimate a estimate (executes immediately) - returns raw Response. */ @@ -748,6 +1056,20 @@ public CreateSubscriptionForCustomerEstimateResponse createSubscriptionForCustom response.getBodyAsString(), response); } + /** Async variant of createSubscriptionForCustomerEstimate for estimate with params. */ + public CompletableFuture + createSubscriptionForCustomerEstimateAsync( + String customerId, CreateSubscriptionForCustomerEstimateParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/create_subscription_estimate", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + CreateSubscriptionForCustomerEstimateResponse.fromJson( + response.getBodyAsString(), response)); + } + public CreateSubscriptionForCustomerEstimateResponse createSubscriptionForCustomerEstimate( String customerId) throws ChargebeeException { Response response = createSubscriptionForCustomerEstimateRaw(customerId); @@ -755,6 +1077,20 @@ public CreateSubscriptionForCustomerEstimateResponse createSubscriptionForCustom response.getBodyAsString(), response); } + /** Async variant of createSubscriptionForCustomerEstimate for estimate without params. */ + public CompletableFuture + createSubscriptionForCustomerEstimateAsync(String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/create_subscription_estimate", "customer-id", customerId); + + return getAsync(path, null) + .thenApply( + response -> + CreateSubscriptionForCustomerEstimateResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * createSubscription a estimate using immutable params (executes immediately) - returns raw * Response. @@ -781,6 +1117,16 @@ public EstimateCreateSubscriptionResponse createSubscription( return EstimateCreateSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createSubscription for estimate with params. */ + public CompletableFuture createSubscriptionAsync( + EstimateCreateSubscriptionParams params) { + + return postAsync("/estimates/create_subscription", params != null ? params.toFormData() : null) + .thenApply( + response -> + EstimateCreateSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createInvoice a estimate using immutable params (executes immediately) - returns raw Response. */ @@ -804,6 +1150,16 @@ public EstimateCreateInvoiceResponse createInvoice(EstimateCreateInvoiceParams p return EstimateCreateInvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createInvoice for estimate with params. */ + public CompletableFuture createInvoiceAsync( + EstimateCreateInvoiceParams params) { + + return postAsync("/estimates/create_invoice", params != null ? params.toFormData() : null) + .thenApply( + response -> + EstimateCreateInvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + /** cancelSubscription a estimate (executes immediately) - returns raw Response. */ Response cancelSubscriptionRaw(String subscriptionId) throws ChargebeeException { String path = @@ -849,9 +1205,38 @@ public EstimateCancelSubscriptionResponse cancelSubscription( return EstimateCancelSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of cancelSubscription for estimate with params. */ + public CompletableFuture cancelSubscriptionAsync( + String subscriptionId, EstimateCancelSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/cancel_subscription_estimate", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + EstimateCancelSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + public EstimateCancelSubscriptionResponse cancelSubscription(String subscriptionId) throws ChargebeeException { Response response = cancelSubscriptionRaw(subscriptionId); return EstimateCancelSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of cancelSubscription for estimate without params. */ + public CompletableFuture cancelSubscriptionAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/cancel_subscription_estimate", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + EstimateCancelSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/EventService.java b/src/main/java/com/chargebee/v4/services/EventService.java index aeefc022..4b2bf31d 100644 --- a/src/main/java/com/chargebee/v4/services/EventService.java +++ b/src/main/java/com/chargebee/v4/services/EventService.java @@ -11,6 +11,7 @@ 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.event.params.EventListParams; @@ -76,12 +77,30 @@ public EventListResponse list(EventListParams params) throws ChargebeeException return EventListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for event with params. */ + public CompletableFuture listAsync(EventListParams params) { + + return getAsync("/events", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + EventListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public EventListResponse list() throws ChargebeeException { Response response = listRaw(); return EventListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for event without params. */ + public CompletableFuture listAsync() { + + return getAsync("/events", null) + .thenApply( + response -> + EventListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** retrieve a event (executes immediately) - returns raw Response. */ Response retrieveRaw(String eventId) throws ChargebeeException { String path = buildPathWithParams("/events/{event-id}", "event-id", eventId); @@ -93,4 +112,13 @@ public EventRetrieveResponse retrieve(String eventId) throws ChargebeeException Response response = retrieveRaw(eventId); return EventRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for event without params. */ + public CompletableFuture retrieveAsync(String eventId) { + String path = buildPathWithParams("/events/{event-id}", "event-id", eventId); + + return getAsync(path, null) + .thenApply( + response -> EventRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ExportService.java b/src/main/java/com/chargebee/v4/services/ExportService.java index 6cd8f2f6..36d40f88 100644 --- a/src/main/java/com/chargebee/v4/services/ExportService.java +++ b/src/main/java/com/chargebee/v4/services/ExportService.java @@ -11,6 +11,7 @@ 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.export.params.ExportCustomersParams; @@ -134,6 +135,14 @@ public ExportCustomersResponse customers(ExportCustomersParams params) throws Ch return ExportCustomersResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of customers for export with params. */ + public CompletableFuture customersAsync(ExportCustomersParams params) { + + return postAsync("/exports/customers", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportCustomersResponse.fromJson(response.getBodyAsString(), response)); + } + /** * attachedItems a export using immutable params (executes immediately) - returns raw Response. */ @@ -157,6 +166,15 @@ public ExportAttachedItemsResponse attachedItems(ExportAttachedItemsParams param return ExportAttachedItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of attachedItems for export with params. */ + public CompletableFuture attachedItemsAsync( + ExportAttachedItemsParams params) { + + return postAsync("/exports/attached_items", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportAttachedItemsResponse.fromJson(response.getBodyAsString(), response)); + } + /** transactions a export using immutable params (executes immediately) - returns raw Response. */ Response transactionsRaw(ExportTransactionsParams params) throws ChargebeeException { @@ -176,6 +194,15 @@ public ExportTransactionsResponse transactions(ExportTransactionsParams params) return ExportTransactionsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of transactions for export with params. */ + public CompletableFuture transactionsAsync( + ExportTransactionsParams params) { + + return postAsync("/exports/transactions", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportTransactionsResponse.fromJson(response.getBodyAsString(), response)); + } + /** * differentialPrices a export using immutable params (executes immediately) - returns raw * Response. @@ -201,6 +228,16 @@ public ExportDifferentialPricesResponse differentialPrices(ExportDifferentialPri return ExportDifferentialPricesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of differentialPrices for export with params. */ + public CompletableFuture differentialPricesAsync( + ExportDifferentialPricesParams params) { + + return postAsync("/exports/differential_prices", params != null ? params.toFormData() : null) + .thenApply( + response -> + ExportDifferentialPricesResponse.fromJson(response.getBodyAsString(), response)); + } + /** itemFamilies a export using immutable params (executes immediately) - returns raw Response. */ Response itemFamiliesRaw(ExportItemFamiliesParams params) throws ChargebeeException { @@ -220,6 +257,15 @@ public ExportItemFamiliesResponse itemFamilies(ExportItemFamiliesParams params) return ExportItemFamiliesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of itemFamilies for export with params. */ + public CompletableFuture itemFamiliesAsync( + ExportItemFamiliesParams params) { + + return postAsync("/exports/item_families", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportItemFamiliesResponse.fromJson(response.getBodyAsString(), response)); + } + /** invoices a export using immutable params (executes immediately) - returns raw Response. */ Response invoicesRaw(ExportInvoicesParams params) throws ChargebeeException { @@ -238,6 +284,14 @@ public ExportInvoicesResponse invoices(ExportInvoicesParams params) throws Charg return ExportInvoicesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of invoices for export with params. */ + public CompletableFuture invoicesAsync(ExportInvoicesParams params) { + + return postAsync("/exports/invoices", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportInvoicesResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a export (executes immediately) - returns raw Response. */ Response retrieveRaw(String exportId) throws ChargebeeException { String path = buildPathWithParams("/exports/{export-id}", "export-id", exportId); @@ -250,6 +304,15 @@ public ExportRetrieveResponse retrieve(String exportId) throws ChargebeeExceptio return ExportRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for export without params. */ + public CompletableFuture retrieveAsync(String exportId) { + String path = buildPathWithParams("/exports/{export-id}", "export-id", exportId); + + return getAsync(path, null) + .thenApply( + response -> ExportRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * priceVariants a export using immutable params (executes immediately) - returns raw Response. */ @@ -273,6 +336,15 @@ public ExportPriceVariantsResponse priceVariants(ExportPriceVariantsParams param return ExportPriceVariantsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of priceVariants for export with params. */ + public CompletableFuture priceVariantsAsync( + ExportPriceVariantsParams params) { + + return postAsync("/exports/price_variants", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportPriceVariantsResponse.fromJson(response.getBodyAsString(), response)); + } + /** items a export using immutable params (executes immediately) - returns raw Response. */ Response itemsRaw(ExportItemsParams params) throws ChargebeeException { @@ -291,6 +363,13 @@ public ExportItemsResponse items(ExportItemsParams params) throws ChargebeeExcep return ExportItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of items for export with params. */ + public CompletableFuture itemsAsync(ExportItemsParams params) { + + return postAsync("/exports/items", params != null ? params.toFormData() : null) + .thenApply(response -> ExportItemsResponse.fromJson(response.getBodyAsString(), response)); + } + /** * deferredRevenue a export using immutable params (executes immediately) - returns raw Response. */ @@ -314,6 +393,16 @@ public ExportDeferredRevenueResponse deferredRevenue(ExportDeferredRevenueParams return ExportDeferredRevenueResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deferredRevenue for export with params. */ + public CompletableFuture deferredRevenueAsync( + ExportDeferredRevenueParams params) { + + return postAsync("/exports/deferred_revenue", params != null ? params.toFormData() : null) + .thenApply( + response -> + ExportDeferredRevenueResponse.fromJson(response.getBodyAsString(), response)); + } + /** * revenueRecognition a export using immutable params (executes immediately) - returns raw * Response. @@ -339,6 +428,16 @@ public ExportRevenueRecognitionResponse revenueRecognition(ExportRevenueRecognit return ExportRevenueRecognitionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of revenueRecognition for export with params. */ + public CompletableFuture revenueRecognitionAsync( + ExportRevenueRecognitionParams params) { + + return postAsync("/exports/revenue_recognition", params != null ? params.toFormData() : null) + .thenApply( + response -> + ExportRevenueRecognitionResponse.fromJson(response.getBodyAsString(), response)); + } + /** creditNotes a export using immutable params (executes immediately) - returns raw Response. */ Response creditNotesRaw(ExportCreditNotesParams params) throws ChargebeeException { @@ -358,6 +457,15 @@ public ExportCreditNotesResponse creditNotes(ExportCreditNotesParams params) return ExportCreditNotesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of creditNotes for export with params. */ + public CompletableFuture creditNotesAsync( + ExportCreditNotesParams params) { + + return postAsync("/exports/credit_notes", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportCreditNotesResponse.fromJson(response.getBodyAsString(), response)); + } + /** coupons a export using immutable params (executes immediately) - returns raw Response. */ Response couponsRaw(ExportCouponsParams params) throws ChargebeeException { @@ -376,6 +484,14 @@ public ExportCouponsResponse coupons(ExportCouponsParams params) throws Chargebe return ExportCouponsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of coupons for export with params. */ + public CompletableFuture couponsAsync(ExportCouponsParams params) { + + return postAsync("/exports/coupons", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportCouponsResponse.fromJson(response.getBodyAsString(), response)); + } + /** orders a export using immutable params (executes immediately) - returns raw Response. */ Response ordersRaw(ExportOrdersParams params) throws ChargebeeException { @@ -394,6 +510,13 @@ public ExportOrdersResponse orders(ExportOrdersParams params) throws ChargebeeEx return ExportOrdersResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of orders for export with params. */ + public CompletableFuture ordersAsync(ExportOrdersParams params) { + + return postAsync("/exports/orders", params != null ? params.toFormData() : null) + .thenApply(response -> ExportOrdersResponse.fromJson(response.getBodyAsString(), response)); + } + /** itemPrices a export using immutable params (executes immediately) - returns raw Response. */ Response itemPricesRaw(ExportItemPricesParams params) throws ChargebeeException { @@ -413,6 +536,15 @@ public ExportItemPricesResponse itemPrices(ExportItemPricesParams params) return ExportItemPricesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of itemPrices for export with params. */ + public CompletableFuture itemPricesAsync( + ExportItemPricesParams params) { + + return postAsync("/exports/item_prices", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportItemPricesResponse.fromJson(response.getBodyAsString(), response)); + } + /** * subscriptions a export using immutable params (executes immediately) - returns raw Response. */ @@ -436,6 +568,15 @@ public ExportSubscriptionsResponse subscriptions(ExportSubscriptionsParams param return ExportSubscriptionsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of subscriptions for export with params. */ + public CompletableFuture subscriptionsAsync( + ExportSubscriptionsParams params) { + + return postAsync("/exports/subscriptions", params != null ? params.toFormData() : null) + .thenApply( + response -> ExportSubscriptionsResponse.fromJson(response.getBodyAsString(), response)); + } + /** addons a export using immutable params (executes immediately) - returns raw Response. */ Response addonsRaw(ExportAddonsParams params) throws ChargebeeException { @@ -454,6 +595,13 @@ public ExportAddonsResponse addons(ExportAddonsParams params) throws ChargebeeEx return ExportAddonsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addons for export with params. */ + public CompletableFuture addonsAsync(ExportAddonsParams params) { + + return postAsync("/exports/addons", params != null ? params.toFormData() : null) + .thenApply(response -> ExportAddonsResponse.fromJson(response.getBodyAsString(), response)); + } + /** plans a export using immutable params (executes immediately) - returns raw Response. */ Response plansRaw(ExportPlansParams params) throws ChargebeeException { @@ -472,6 +620,13 @@ public ExportPlansResponse plans(ExportPlansParams params) throws ChargebeeExcep return ExportPlansResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of plans for export with params. */ + public CompletableFuture plansAsync(ExportPlansParams params) { + + return postAsync("/exports/plans", params != null ? params.toFormData() : null) + .thenApply(response -> ExportPlansResponse.fromJson(response.getBodyAsString(), response)); + } + // === Export Utility Methods === /** diff --git a/src/main/java/com/chargebee/v4/services/FeatureService.java b/src/main/java/com/chargebee/v4/services/FeatureService.java index 77f2bc5c..a9cfb33d 100644 --- a/src/main/java/com/chargebee/v4/services/FeatureService.java +++ b/src/main/java/com/chargebee/v4/services/FeatureService.java @@ -11,6 +11,7 @@ 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.feature.params.FeatureListParams; @@ -92,12 +93,30 @@ public FeatureListResponse list(FeatureListParams params) throws ChargebeeExcept return FeatureListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for feature with params. */ + public CompletableFuture listAsync(FeatureListParams params) { + + return getAsync("/features", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + FeatureListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public FeatureListResponse list() throws ChargebeeException { Response response = listRaw(); return FeatureListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for feature without params. */ + public CompletableFuture listAsync() { + + return getAsync("/features", null) + .thenApply( + response -> + FeatureListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a feature using immutable params (executes immediately) - returns raw Response. */ Response createRaw(FeatureCreateParams params) throws ChargebeeException { @@ -116,6 +135,14 @@ public FeatureCreateResponse create(FeatureCreateParams params) throws Chargebee return FeatureCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for feature with params. */ + public CompletableFuture createAsync(FeatureCreateParams params) { + + return postAsync("/features", params != null ? params.toFormData() : null) + .thenApply( + response -> FeatureCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a feature (executes immediately) - returns raw Response. */ Response deleteRaw(String featureId) throws ChargebeeException { String path = buildPathWithParams("/features/{feature-id}/delete", "feature-id", featureId); @@ -128,6 +155,15 @@ public FeatureDeleteResponse delete(String featureId) throws ChargebeeException return FeatureDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for feature without params. */ + public CompletableFuture deleteAsync(String featureId) { + String path = buildPathWithParams("/features/{feature-id}/delete", "feature-id", featureId); + + return postAsync(path, null) + .thenApply( + response -> FeatureDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a feature (executes immediately) - returns raw Response. */ Response retrieveRaw(String featureId) throws ChargebeeException { String path = buildPathWithParams("/features/{feature-id}", "feature-id", featureId); @@ -140,6 +176,15 @@ public FeatureRetrieveResponse retrieve(String featureId) throws ChargebeeExcept return FeatureRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for feature without params. */ + public CompletableFuture retrieveAsync(String featureId) { + String path = buildPathWithParams("/features/{feature-id}", "feature-id", featureId); + + return getAsync(path, null) + .thenApply( + response -> FeatureRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a feature (executes immediately) - returns raw Response. */ Response updateRaw(String featureId) throws ChargebeeException { String path = buildPathWithParams("/features/{feature-id}", "feature-id", featureId); @@ -165,11 +210,29 @@ public FeatureUpdateResponse update(String featureId, FeatureUpdateParams params return FeatureUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for feature with params. */ + public CompletableFuture updateAsync( + String featureId, FeatureUpdateParams params) { + String path = buildPathWithParams("/features/{feature-id}", "feature-id", featureId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> FeatureUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public FeatureUpdateResponse update(String featureId) throws ChargebeeException { Response response = updateRaw(featureId); return FeatureUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for feature without params. */ + public CompletableFuture updateAsync(String featureId) { + String path = buildPathWithParams("/features/{feature-id}", "feature-id", featureId); + + return postAsync(path, null) + .thenApply( + response -> FeatureUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** archive a feature (executes immediately) - returns raw Response. */ Response archiveRaw(String featureId) throws ChargebeeException { String path = @@ -183,6 +246,16 @@ public FeatureArchiveResponse archive(String featureId) throws ChargebeeExceptio return FeatureArchiveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of archive for feature without params. */ + public CompletableFuture archiveAsync(String featureId) { + String path = + buildPathWithParams("/features/{feature-id}/archive_command", "feature-id", featureId); + + return postAsync(path, null) + .thenApply( + response -> FeatureArchiveResponse.fromJson(response.getBodyAsString(), response)); + } + /** activate a feature (executes immediately) - returns raw Response. */ Response activateRaw(String featureId) throws ChargebeeException { String path = @@ -196,6 +269,16 @@ public FeatureActivateResponse activate(String featureId) throws ChargebeeExcept return FeatureActivateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of activate for feature without params. */ + public CompletableFuture activateAsync(String featureId) { + String path = + buildPathWithParams("/features/{feature-id}/activate_command", "feature-id", featureId); + + return postAsync(path, null) + .thenApply( + response -> FeatureActivateResponse.fromJson(response.getBodyAsString(), response)); + } + /** reactivate a feature (executes immediately) - returns raw Response. */ Response reactivateRaw(String featureId) throws ChargebeeException { String path = @@ -208,4 +291,14 @@ public FeatureReactivateResponse reactivate(String featureId) throws ChargebeeEx Response response = reactivateRaw(featureId); return FeatureReactivateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of reactivate for feature without params. */ + public CompletableFuture reactivateAsync(String featureId) { + String path = + buildPathWithParams("/features/{feature-id}/reactivate_command", "feature-id", featureId); + + return postAsync(path, null) + .thenApply( + response -> FeatureReactivateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/FullExportService.java b/src/main/java/com/chargebee/v4/services/FullExportService.java index 9ec7159f..52b245db 100644 --- a/src/main/java/com/chargebee/v4/services/FullExportService.java +++ b/src/main/java/com/chargebee/v4/services/FullExportService.java @@ -11,6 +11,7 @@ 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.fullExport.params.FullExportStatusParams; @@ -67,4 +68,12 @@ public FullExportStatusResponse status(FullExportStatusParams params) throws Cha return FullExportStatusResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of status for fullExport with params. */ + public CompletableFuture statusAsync(FullExportStatusParams params) { + + return getAsync("/full_exports/status", params != null ? params.toQueryParams() : null) + .thenApply( + response -> FullExportStatusResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/GiftService.java b/src/main/java/com/chargebee/v4/services/GiftService.java index f166d853..47c1f3cc 100644 --- a/src/main/java/com/chargebee/v4/services/GiftService.java +++ b/src/main/java/com/chargebee/v4/services/GiftService.java @@ -11,6 +11,7 @@ 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.gift.params.GiftCreateForItemsParams; @@ -87,6 +88,15 @@ public GiftCreateForItemsResponse createForItems(GiftCreateForItemsParams params return GiftCreateForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createForItems for gift with params. */ + public CompletableFuture createForItemsAsync( + GiftCreateForItemsParams params) { + + return postAsync("/gifts/create_for_items", params != null ? params.toFormData() : null) + .thenApply( + response -> GiftCreateForItemsResponse.fromJson(response.getBodyAsString(), response)); + } + /** cancel a gift (executes immediately) - returns raw Response. */ Response cancelRaw(String giftId) throws ChargebeeException { String path = buildPathWithParams("/gifts/{gift-id}/cancel", "gift-id", giftId); @@ -99,6 +109,14 @@ public GiftCancelResponse cancel(String giftId) throws ChargebeeException { return GiftCancelResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of cancel for gift without params. */ + public CompletableFuture cancelAsync(String giftId) { + String path = buildPathWithParams("/gifts/{gift-id}/cancel", "gift-id", giftId); + + return postAsync(path, null) + .thenApply(response -> GiftCancelResponse.fromJson(response.getBodyAsString(), response)); + } + /** updateGift a gift (executes immediately) - returns raw Response. */ Response updateGiftRaw(String giftId) throws ChargebeeException { String path = buildPathWithParams("/gifts/{gift-id}/update_gift", "gift-id", giftId); @@ -124,6 +142,14 @@ public UpdateGiftResponse updateGift(String giftId, UpdateGiftParams params) return UpdateGiftResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateGift for gift with params. */ + public CompletableFuture updateGiftAsync( + String giftId, UpdateGiftParams params) { + String path = buildPathWithParams("/gifts/{gift-id}/update_gift", "gift-id", giftId); + return postAsync(path, params.toFormData()) + .thenApply(response -> UpdateGiftResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a gift using immutable params (executes immediately) - returns raw Response. */ Response listRaw(GiftListParams params) throws ChargebeeException { @@ -148,12 +174,30 @@ public GiftListResponse list(GiftListParams params) throws ChargebeeException { return GiftListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for gift with params. */ + public CompletableFuture listAsync(GiftListParams params) { + + return getAsync("/gifts", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + GiftListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public GiftListResponse list() throws ChargebeeException { Response response = listRaw(); return GiftListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for gift without params. */ + public CompletableFuture listAsync() { + + return getAsync("/gifts", null) + .thenApply( + response -> + GiftListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a gift using immutable params (executes immediately) - returns raw Response. */ Response createRaw(GiftCreateParams params) throws ChargebeeException { @@ -172,6 +216,13 @@ public GiftCreateResponse create(GiftCreateParams params) throws ChargebeeExcept return GiftCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for gift with params. */ + public CompletableFuture createAsync(GiftCreateParams params) { + + return postAsync("/gifts", params != null ? params.toFormData() : null) + .thenApply(response -> GiftCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a gift (executes immediately) - returns raw Response. */ Response retrieveRaw(String giftId) throws ChargebeeException { String path = buildPathWithParams("/gifts/{gift-id}", "gift-id", giftId); @@ -184,6 +235,14 @@ public GiftRetrieveResponse retrieve(String giftId) throws ChargebeeException { return GiftRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for gift without params. */ + public CompletableFuture retrieveAsync(String giftId) { + String path = buildPathWithParams("/gifts/{gift-id}", "gift-id", giftId); + + return getAsync(path, null) + .thenApply(response -> GiftRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** claim a gift (executes immediately) - returns raw Response. */ Response claimRaw(String giftId) throws ChargebeeException { String path = buildPathWithParams("/gifts/{gift-id}/claim", "gift-id", giftId); @@ -195,4 +254,12 @@ public GiftClaimResponse claim(String giftId) throws ChargebeeException { Response response = claimRaw(giftId); return GiftClaimResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of claim for gift without params. */ + public CompletableFuture claimAsync(String giftId) { + String path = buildPathWithParams("/gifts/{gift-id}/claim", "gift-id", giftId); + + return postAsync(path, null) + .thenApply(response -> GiftClaimResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/HostedPageService.java b/src/main/java/com/chargebee/v4/services/HostedPageService.java index ebbac288..a0276403 100644 --- a/src/main/java/com/chargebee/v4/services/HostedPageService.java +++ b/src/main/java/com/chargebee/v4/services/HostedPageService.java @@ -11,6 +11,7 @@ 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.hostedPage.params.HostedPageCheckoutOneTimeForItemsParams; @@ -157,6 +158,19 @@ public HostedPageCheckoutOneTimeForItemsResponse checkoutOneTimeForItems( return HostedPageCheckoutOneTimeForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of checkoutOneTimeForItems for hostedPage with params. */ + public CompletableFuture checkoutOneTimeForItemsAsync( + HostedPageCheckoutOneTimeForItemsParams params) { + + return postAsync( + "/hosted_pages/checkout_one_time_for_items", + params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageCheckoutOneTimeForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * updatePaymentMethod a hostedPage using immutable params (executes immediately) - returns raw * Response. @@ -183,6 +197,18 @@ public HostedPageUpdatePaymentMethodResponse updatePaymentMethod( return HostedPageUpdatePaymentMethodResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updatePaymentMethod for hostedPage with params. */ + public CompletableFuture updatePaymentMethodAsync( + HostedPageUpdatePaymentMethodParams params) { + + return postAsync( + "/hosted_pages/update_payment_method", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageUpdatePaymentMethodResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * updateCard a hostedPage using immutable params (executes immediately) - returns raw Response. */ @@ -206,6 +232,16 @@ public HostedPageUpdateCardResponse updateCard(HostedPageUpdateCardParams params return HostedPageUpdateCardResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateCard for hostedPage with params. */ + public CompletableFuture updateCardAsync( + HostedPageUpdateCardParams params) { + + return postAsync("/hosted_pages/update_card", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageUpdateCardResponse.fromJson(response.getBodyAsString(), response)); + } + /** * extendSubscription a hostedPage using immutable params (executes immediately) - returns raw * Response. @@ -232,6 +268,18 @@ public HostedPageExtendSubscriptionResponse extendSubscription( return HostedPageExtendSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of extendSubscription for hostedPage with params. */ + public CompletableFuture extendSubscriptionAsync( + HostedPageExtendSubscriptionParams params) { + + return postAsync( + "/hosted_pages/extend_subscription", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageExtendSubscriptionResponse.fromJson( + response.getBodyAsString(), response)); + } + /** events a hostedPage using immutable params (executes immediately) - returns raw Response. */ Response eventsRaw(HostedPageEventsParams params) throws ChargebeeException { @@ -250,6 +298,14 @@ public HostedPageEventsResponse events(HostedPageEventsParams params) throws Cha return HostedPageEventsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of events for hostedPage with params. */ + public CompletableFuture eventsAsync(HostedPageEventsParams params) { + + return postAsync("/hosted_pages/events", params != null ? params.toFormData() : null) + .thenApply( + response -> HostedPageEventsResponse.fromJson(response.getBodyAsString(), response)); + } + /** * checkoutGiftForItems a hostedPage using immutable params (executes immediately) - returns raw * Response. @@ -277,6 +333,18 @@ public HostedPageCheckoutGiftForItemsResponse checkoutGiftForItems( return HostedPageCheckoutGiftForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of checkoutGiftForItems for hostedPage with params. */ + public CompletableFuture checkoutGiftForItemsAsync( + HostedPageCheckoutGiftForItemsParams params) { + + return postAsync( + "/hosted_pages/checkout_gift_for_items", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageCheckoutGiftForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** list a hostedPage using immutable params (executes immediately) - returns raw Response. */ Response listRaw(HostedPageListParams params) throws ChargebeeException { @@ -301,12 +369,31 @@ public HostedPageListResponse list(HostedPageListParams params) throws Chargebee return HostedPageListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for hostedPage with params. */ + public CompletableFuture listAsync(HostedPageListParams params) { + + return getAsync("/hosted_pages", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + HostedPageListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public HostedPageListResponse list() throws ChargebeeException { Response response = listRaw(); return HostedPageListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for hostedPage without params. */ + public CompletableFuture listAsync() { + + return getAsync("/hosted_pages", null) + .thenApply( + response -> + HostedPageListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** * viewVoucher a hostedPage using immutable params (executes immediately) - returns raw Response. */ @@ -330,6 +417,16 @@ public HostedPageViewVoucherResponse viewVoucher(HostedPageViewVoucherParams par return HostedPageViewVoucherResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of viewVoucher for hostedPage with params. */ + public CompletableFuture viewVoucherAsync( + HostedPageViewVoucherParams params) { + + return postAsync("/hosted_pages/view_voucher", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageViewVoucherResponse.fromJson(response.getBodyAsString(), response)); + } + /** * collectNow a hostedPage using immutable params (executes immediately) - returns raw Response. */ @@ -353,6 +450,16 @@ public HostedPageCollectNowResponse collectNow(HostedPageCollectNowParams params return HostedPageCollectNowResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of collectNow for hostedPage with params. */ + public CompletableFuture collectNowAsync( + HostedPageCollectNowParams params) { + + return postAsync("/hosted_pages/collect_now", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageCollectNowResponse.fromJson(response.getBodyAsString(), response)); + } + /** * acceptQuote a hostedPage using immutable params (executes immediately) - returns raw Response. */ @@ -376,6 +483,16 @@ public HostedPageAcceptQuoteResponse acceptQuote(HostedPageAcceptQuoteParams par return HostedPageAcceptQuoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of acceptQuote for hostedPage with params. */ + public CompletableFuture acceptQuoteAsync( + HostedPageAcceptQuoteParams params) { + + return postAsync("/hosted_pages/accept_quote", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageAcceptQuoteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * checkoutNewForItems a hostedPage using immutable params (executes immediately) - returns raw * Response. @@ -403,6 +520,18 @@ public HostedPageCheckoutNewForItemsResponse checkoutNewForItems( return HostedPageCheckoutNewForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of checkoutNewForItems for hostedPage with params. */ + public CompletableFuture checkoutNewForItemsAsync( + HostedPageCheckoutNewForItemsParams params) { + + return postAsync( + "/hosted_pages/checkout_new_for_items", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageCheckoutNewForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * claimGift a hostedPage using immutable params (executes immediately) - returns raw Response. */ @@ -426,6 +555,15 @@ public HostedPageClaimGiftResponse claimGift(HostedPageClaimGiftParams params) return HostedPageClaimGiftResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of claimGift for hostedPage with params. */ + public CompletableFuture claimGiftAsync( + HostedPageClaimGiftParams params) { + + return postAsync("/hosted_pages/claim_gift", params != null ? params.toFormData() : null) + .thenApply( + response -> HostedPageClaimGiftResponse.fromJson(response.getBodyAsString(), response)); + } + /** * checkoutExistingForItems a hostedPage using immutable params (executes immediately) - returns * raw Response. @@ -454,6 +592,19 @@ public HostedPageCheckoutExistingForItemsResponse checkoutExistingForItems( response.getBodyAsString(), response); } + /** Async variant of checkoutExistingForItems for hostedPage with params. */ + public CompletableFuture + checkoutExistingForItemsAsync(HostedPageCheckoutExistingForItemsParams params) { + + return postAsync( + "/hosted_pages/checkout_existing_for_items", + params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageCheckoutExistingForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * preCancel a hostedPage using immutable params (executes immediately) - returns raw Response. */ @@ -477,6 +628,15 @@ public HostedPagePreCancelResponse preCancel(HostedPagePreCancelParams params) return HostedPagePreCancelResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of preCancel for hostedPage with params. */ + public CompletableFuture preCancelAsync( + HostedPagePreCancelParams params) { + + return postAsync("/hosted_pages/pre_cancel", params != null ? params.toFormData() : null) + .thenApply( + response -> HostedPagePreCancelResponse.fromJson(response.getBodyAsString(), response)); + } + /** acknowledge a hostedPage (executes immediately) - returns raw Response. */ Response acknowledgeRaw(String hostedPageId) throws ChargebeeException { String path = @@ -491,6 +651,18 @@ public HostedPageAcknowledgeResponse acknowledge(String hostedPageId) throws Cha return HostedPageAcknowledgeResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of acknowledge for hostedPage without params. */ + public CompletableFuture acknowledgeAsync(String hostedPageId) { + String path = + buildPathWithParams( + "/hosted_pages/{hosted-page-id}/acknowledge", "hosted-page-id", hostedPageId); + + return postAsync(path, null) + .thenApply( + response -> + HostedPageAcknowledgeResponse.fromJson(response.getBodyAsString(), response)); + } + /** * retrieveAgreementPdf a hostedPage using immutable params (executes immediately) - returns raw * Response. @@ -518,6 +690,18 @@ public HostedPageRetrieveAgreementPdfResponse retrieveAgreementPdf( return HostedPageRetrieveAgreementPdfResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieveAgreementPdf for hostedPage with params. */ + public CompletableFuture retrieveAgreementPdfAsync( + HostedPageRetrieveAgreementPdfParams params) { + + return postAsync( + "/hosted_pages/retrieve_agreement_pdf", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageRetrieveAgreementPdfResponse.fromJson( + response.getBodyAsString(), response)); + } + /** retrieve a hostedPage (executes immediately) - returns raw Response. */ Response retrieveRaw(String hostedPageId) throws ChargebeeException { String path = @@ -531,6 +715,16 @@ public HostedPageRetrieveResponse retrieve(String hostedPageId) throws Chargebee return HostedPageRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for hostedPage without params. */ + public CompletableFuture retrieveAsync(String hostedPageId) { + String path = + buildPathWithParams("/hosted_pages/{hosted-page-id}", "hosted-page-id", hostedPageId); + + return getAsync(path, null) + .thenApply( + response -> HostedPageRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * managePaymentSources a hostedPage using immutable params (executes immediately) - returns raw * Response. @@ -558,6 +752,18 @@ public HostedPageManagePaymentSourcesResponse managePaymentSources( return HostedPageManagePaymentSourcesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of managePaymentSources for hostedPage with params. */ + public CompletableFuture managePaymentSourcesAsync( + HostedPageManagePaymentSourcesParams params) { + + return postAsync( + "/hosted_pages/manage_payment_sources", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageManagePaymentSourcesResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * checkoutOneTime a hostedPage using immutable params (executes immediately) - returns raw * Response. @@ -583,6 +789,16 @@ public HostedPageCheckoutOneTimeResponse checkoutOneTime(HostedPageCheckoutOneTi return HostedPageCheckoutOneTimeResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of checkoutOneTime for hostedPage with params. */ + public CompletableFuture checkoutOneTimeAsync( + HostedPageCheckoutOneTimeParams params) { + + return postAsync("/hosted_pages/checkout_one_time", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageCheckoutOneTimeResponse.fromJson(response.getBodyAsString(), response)); + } + /** * checkoutNew a hostedPage using immutable params (executes immediately) - returns raw Response. */ @@ -606,6 +822,16 @@ public HostedPageCheckoutNewResponse checkoutNew(HostedPageCheckoutNewParams par return HostedPageCheckoutNewResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of checkoutNew for hostedPage with params. */ + public CompletableFuture checkoutNewAsync( + HostedPageCheckoutNewParams params) { + + return postAsync("/hosted_pages/checkout_new", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageCheckoutNewResponse.fromJson(response.getBodyAsString(), response)); + } + /** * checkoutGift a hostedPage using immutable params (executes immediately) - returns raw Response. */ @@ -629,6 +855,16 @@ public HostedPageCheckoutGiftResponse checkoutGift(HostedPageCheckoutGiftParams return HostedPageCheckoutGiftResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of checkoutGift for hostedPage with params. */ + public CompletableFuture checkoutGiftAsync( + HostedPageCheckoutGiftParams params) { + + return postAsync("/hosted_pages/checkout_gift", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageCheckoutGiftResponse.fromJson(response.getBodyAsString(), response)); + } + /** * checkoutExisting a hostedPage using immutable params (executes immediately) - returns raw * Response. @@ -653,4 +889,14 @@ public HostedPageCheckoutExistingResponse checkoutExisting( return HostedPageCheckoutExistingResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of checkoutExisting for hostedPage with params. */ + public CompletableFuture checkoutExistingAsync( + HostedPageCheckoutExistingParams params) { + + return postAsync("/hosted_pages/checkout_existing", params != null ? params.toFormData() : null) + .thenApply( + response -> + HostedPageCheckoutExistingResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/InAppSubscriptionService.java b/src/main/java/com/chargebee/v4/services/InAppSubscriptionService.java index 9f770447..2c34f416 100644 --- a/src/main/java/com/chargebee/v4/services/InAppSubscriptionService.java +++ b/src/main/java/com/chargebee/v4/services/InAppSubscriptionService.java @@ -11,6 +11,7 @@ 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.inAppSubscription.params.InAppSubscriptionRetrieveStoreSubscriptionsParams; @@ -113,6 +114,22 @@ public InAppSubscriptionRetrieveStoreSubscriptionsResponse retrieveStoreSubscrip response.getBodyAsString(), response); } + /** Async variant of retrieveStoreSubscriptions for inAppSubscription with params. */ + public CompletableFuture + retrieveStoreSubscriptionsAsync( + String inAppSubscriptionAppId, InAppSubscriptionRetrieveStoreSubscriptionsParams params) { + String path = + buildPathWithParams( + "/in_app_subscriptions/{in-app-subscription-app-id}/retrieve", + "in-app-subscription-app-id", + inAppSubscriptionAppId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InAppSubscriptionRetrieveStoreSubscriptionsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** importReceipt a inAppSubscription (executes immediately) - returns raw Response. */ Response importReceiptRaw(String inAppSubscriptionAppId) throws ChargebeeException { String path = @@ -160,6 +177,21 @@ public InAppSubscriptionImportReceiptResponse importReceipt( return InAppSubscriptionImportReceiptResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importReceipt for inAppSubscription with params. */ + public CompletableFuture importReceiptAsync( + String inAppSubscriptionAppId, InAppSubscriptionImportReceiptParams params) { + String path = + buildPathWithParams( + "/in_app_subscriptions/{in-app-subscription-app-id}/import_receipt", + "in-app-subscription-app-id", + inAppSubscriptionAppId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InAppSubscriptionImportReceiptResponse.fromJson( + response.getBodyAsString(), response)); + } + /** importSubscription a inAppSubscription (executes immediately) - returns raw Response. */ Response importSubscriptionRaw(String inAppSubscriptionAppId) throws ChargebeeException { String path = @@ -208,6 +240,21 @@ public InAppSubscriptionImportSubscriptionResponse importSubscription( response.getBodyAsString(), response); } + /** Async variant of importSubscription for inAppSubscription with params. */ + public CompletableFuture importSubscriptionAsync( + String inAppSubscriptionAppId, InAppSubscriptionImportSubscriptionParams params) { + String path = + buildPathWithParams( + "/in_app_subscriptions/{in-app-subscription-app-id}/import_subscription", + "in-app-subscription-app-id", + inAppSubscriptionAppId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InAppSubscriptionImportSubscriptionResponse.fromJson( + response.getBodyAsString(), response)); + } + public InAppSubscriptionImportSubscriptionResponse importSubscription( String inAppSubscriptionAppId) throws ChargebeeException { Response response = importSubscriptionRaw(inAppSubscriptionAppId); @@ -215,6 +262,22 @@ public InAppSubscriptionImportSubscriptionResponse importSubscription( response.getBodyAsString(), response); } + /** Async variant of importSubscription for inAppSubscription without params. */ + public CompletableFuture importSubscriptionAsync( + String inAppSubscriptionAppId) { + String path = + buildPathWithParams( + "/in_app_subscriptions/{in-app-subscription-app-id}/import_subscription", + "in-app-subscription-app-id", + inAppSubscriptionAppId); + + return postAsync(path, null) + .thenApply( + response -> + InAppSubscriptionImportSubscriptionResponse.fromJson( + response.getBodyAsString(), response)); + } + /** processReceipt a inAppSubscription (executes immediately) - returns raw Response. */ Response processReceiptRaw(String inAppSubscriptionAppId) throws ChargebeeException { String path = @@ -261,4 +324,19 @@ public InAppSubscriptionProcessReceiptResponse processReceipt( Response response = processReceiptRaw(inAppSubscriptionAppId, params); return InAppSubscriptionProcessReceiptResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of processReceipt for inAppSubscription with params. */ + public CompletableFuture processReceiptAsync( + String inAppSubscriptionAppId, InAppSubscriptionProcessReceiptParams params) { + String path = + buildPathWithParams( + "/in_app_subscriptions/{in-app-subscription-app-id}/process_purchase_command", + "in-app-subscription-app-id", + inAppSubscriptionAppId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InAppSubscriptionProcessReceiptResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/InvoiceService.java b/src/main/java/com/chargebee/v4/services/InvoiceService.java index 877c0cbf..7f09dc8d 100644 --- a/src/main/java/com/chargebee/v4/services/InvoiceService.java +++ b/src/main/java/com/chargebee/v4/services/InvoiceService.java @@ -11,6 +11,7 @@ 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.invoice.params.InvoiceDeleteLineItemsParams; @@ -233,12 +234,34 @@ public InvoiceDeleteLineItemsResponse deleteLineItems( return InvoiceDeleteLineItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteLineItems for invoice with params. */ + public CompletableFuture deleteLineItemsAsync( + String invoiceId, InvoiceDeleteLineItemsParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/delete_line_items", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceDeleteLineItemsResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceDeleteLineItemsResponse deleteLineItems(String invoiceId) throws ChargebeeException { Response response = deleteLineItemsRaw(invoiceId); return InvoiceDeleteLineItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteLineItems for invoice without params. */ + public CompletableFuture deleteLineItemsAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/delete_line_items", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceDeleteLineItemsResponse.fromJson(response.getBodyAsString(), response)); + } + /** removeCreditNote a invoice (executes immediately) - returns raw Response. */ Response removeCreditNoteRaw(String invoiceId) throws ChargebeeException { String path = @@ -274,12 +297,35 @@ public InvoiceRemoveCreditNoteResponse removeCreditNote( return InvoiceRemoveCreditNoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeCreditNote for invoice with params. */ + public CompletableFuture removeCreditNoteAsync( + String invoiceId, InvoiceRemoveCreditNoteParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/remove_credit_note", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceRemoveCreditNoteResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceRemoveCreditNoteResponse removeCreditNote(String invoiceId) throws ChargebeeException { Response response = removeCreditNoteRaw(invoiceId); return InvoiceRemoveCreditNoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeCreditNote for invoice without params. */ + public CompletableFuture removeCreditNoteAsync( + String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/remove_credit_note", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceRemoveCreditNoteResponse.fromJson(response.getBodyAsString(), response)); + } + /** removePayment a invoice (executes immediately) - returns raw Response. */ Response removePaymentRaw(String invoiceId) throws ChargebeeException { String path = @@ -313,11 +359,33 @@ public InvoiceRemovePaymentResponse removePayment( return InvoiceRemovePaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removePayment for invoice with params. */ + public CompletableFuture removePaymentAsync( + String invoiceId, InvoiceRemovePaymentParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/remove_payment", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceRemovePaymentResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceRemovePaymentResponse removePayment(String invoiceId) throws ChargebeeException { Response response = removePaymentRaw(invoiceId); return InvoiceRemovePaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removePayment for invoice without params. */ + public CompletableFuture removePaymentAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/remove_payment", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceRemovePaymentResponse.fromJson(response.getBodyAsString(), response)); + } + /** stopDunning a invoice (executes immediately) - returns raw Response. */ Response stopDunningRaw(String invoiceId) throws ChargebeeException { String path = @@ -347,11 +415,31 @@ public InvoiceStopDunningResponse stopDunning(String invoiceId, InvoiceStopDunni return InvoiceStopDunningResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of stopDunning for invoice with params. */ + public CompletableFuture stopDunningAsync( + String invoiceId, InvoiceStopDunningParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/stop_dunning", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> InvoiceStopDunningResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceStopDunningResponse stopDunning(String invoiceId) throws ChargebeeException { Response response = stopDunningRaw(invoiceId); return InvoiceStopDunningResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of stopDunning for invoice without params. */ + public CompletableFuture stopDunningAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/stop_dunning", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> InvoiceStopDunningResponse.fromJson(response.getBodyAsString(), response)); + } + /** applyPayments a invoice (executes immediately) - returns raw Response. */ Response applyPaymentsRaw(String invoiceId) throws ChargebeeException { String path = @@ -385,11 +473,33 @@ public InvoiceApplyPaymentsResponse applyPayments( return InvoiceApplyPaymentsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of applyPayments for invoice with params. */ + public CompletableFuture applyPaymentsAsync( + String invoiceId, InvoiceApplyPaymentsParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/apply_payments", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceApplyPaymentsResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceApplyPaymentsResponse applyPayments(String invoiceId) throws ChargebeeException { Response response = applyPaymentsRaw(invoiceId); return InvoiceApplyPaymentsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of applyPayments for invoice without params. */ + public CompletableFuture applyPaymentsAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/apply_payments", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceApplyPaymentsResponse.fromJson(response.getBodyAsString(), response)); + } + /** applyPaymentScheduleScheme a invoice (executes immediately) - returns raw Response. */ Response applyPaymentScheduleSchemeRaw(String invoiceId) throws ChargebeeException { String path = @@ -429,6 +539,20 @@ public InvoiceApplyPaymentScheduleSchemeResponse applyPaymentScheduleScheme( return InvoiceApplyPaymentScheduleSchemeResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of applyPaymentScheduleScheme for invoice with params. */ + public CompletableFuture + applyPaymentScheduleSchemeAsync( + String invoiceId, InvoiceApplyPaymentScheduleSchemeParams params) { + String path = + buildPathWithParams( + "/invoices/{invoice-id}/apply_payment_schedule_scheme", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceApplyPaymentScheduleSchemeResponse.fromJson( + response.getBodyAsString(), response)); + } + /** voidInvoice a invoice (executes immediately) - returns raw Response. */ Response voidInvoiceRaw(String invoiceId) throws ChargebeeException { String path = buildPathWithParams("/invoices/{invoice-id}/void", "invoice-id", invoiceId); @@ -454,11 +578,27 @@ public VoidInvoiceResponse voidInvoice(String invoiceId, VoidInvoiceParams param return VoidInvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of voidInvoice for invoice with params. */ + public CompletableFuture voidInvoiceAsync( + String invoiceId, VoidInvoiceParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}/void", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply(response -> VoidInvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + public VoidInvoiceResponse voidInvoice(String invoiceId) throws ChargebeeException { Response response = voidInvoiceRaw(invoiceId); return VoidInvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of voidInvoice for invoice without params. */ + public CompletableFuture voidInvoiceAsync(String invoiceId) { + String path = buildPathWithParams("/invoices/{invoice-id}/void", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply(response -> VoidInvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + /** addCharge a invoice (executes immediately) - returns raw Response. */ Response addChargeRaw(String invoiceId) throws ChargebeeException { String path = buildPathWithParams("/invoices/{invoice-id}/add_charge", "invoice-id", invoiceId); @@ -484,6 +624,15 @@ public InvoiceAddChargeResponse addCharge(String invoiceId, InvoiceAddChargePara return InvoiceAddChargeResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addCharge for invoice with params. */ + public CompletableFuture addChargeAsync( + String invoiceId, InvoiceAddChargeParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}/add_charge", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> InvoiceAddChargeResponse.fromJson(response.getBodyAsString(), response)); + } + /** sendEinvoice a invoice (executes immediately) - returns raw Response. */ Response sendEinvoiceRaw(String invoiceId) throws ChargebeeException { String path = @@ -497,6 +646,15 @@ public SendEinvoiceResponse sendEinvoice(String invoiceId) throws ChargebeeExcep return SendEinvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of sendEinvoice for invoice without params. */ + public CompletableFuture sendEinvoiceAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/send_einvoice", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply(response -> SendEinvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + /** paymentSchedules a invoice (executes immediately) - returns raw Response. */ Response paymentSchedulesRaw(String invoiceId) throws ChargebeeException { String path = @@ -511,6 +669,18 @@ public InvoicePaymentSchedulesResponse paymentSchedules(String invoiceId) return InvoicePaymentSchedulesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of paymentSchedules for invoice without params. */ + public CompletableFuture paymentSchedulesAsync( + String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/payment_schedules", "invoice-id", invoiceId); + + return getAsync(path, null) + .thenApply( + response -> + InvoicePaymentSchedulesResponse.fromJson(response.getBodyAsString(), response)); + } + /** writeOff a invoice (executes immediately) - returns raw Response. */ Response writeOffRaw(String invoiceId) throws ChargebeeException { String path = buildPathWithParams("/invoices/{invoice-id}/write_off", "invoice-id", invoiceId); @@ -536,11 +706,29 @@ public InvoiceWriteOffResponse writeOff(String invoiceId, InvoiceWriteOffParams return InvoiceWriteOffResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of writeOff for invoice with params. */ + public CompletableFuture writeOffAsync( + String invoiceId, InvoiceWriteOffParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}/write_off", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> InvoiceWriteOffResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceWriteOffResponse writeOff(String invoiceId) throws ChargebeeException { Response response = writeOffRaw(invoiceId); return InvoiceWriteOffResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of writeOff for invoice without params. */ + public CompletableFuture writeOffAsync(String invoiceId) { + String path = buildPathWithParams("/invoices/{invoice-id}/write_off", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> InvoiceWriteOffResponse.fromJson(response.getBodyAsString(), response)); + } + /** addChargeItem a invoice (executes immediately) - returns raw Response. */ Response addChargeItemRaw(String invoiceId) throws ChargebeeException { String path = @@ -574,11 +762,33 @@ public InvoiceAddChargeItemResponse addChargeItem( return InvoiceAddChargeItemResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addChargeItem for invoice with params. */ + public CompletableFuture addChargeItemAsync( + String invoiceId, InvoiceAddChargeItemParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/add_charge_item", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceAddChargeItemResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceAddChargeItemResponse addChargeItem(String invoiceId) throws ChargebeeException { Response response = addChargeItemRaw(invoiceId); return InvoiceAddChargeItemResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addChargeItem for invoice without params. */ + public CompletableFuture addChargeItemAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/add_charge_item", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceAddChargeItemResponse.fromJson(response.getBodyAsString(), response)); + } + /** pauseDunning a invoice (executes immediately) - returns raw Response. */ Response pauseDunningRaw(String invoiceId) throws ChargebeeException { String path = @@ -612,6 +822,16 @@ public InvoicePauseDunningResponse pauseDunning( return InvoicePauseDunningResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pauseDunning for invoice with params. */ + public CompletableFuture pauseDunningAsync( + String invoiceId, InvoicePauseDunningParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/pause_dunning", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> InvoicePauseDunningResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a invoice using immutable params (executes immediately) - returns raw Response. */ Response listRaw(InvoiceListParams params) throws ChargebeeException { @@ -636,12 +856,30 @@ public InvoiceListResponse list(InvoiceListParams params) throws ChargebeeExcept return InvoiceListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for invoice with params. */ + public CompletableFuture listAsync(InvoiceListParams params) { + + return getAsync("/invoices", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + InvoiceListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public InvoiceListResponse list() throws ChargebeeException { Response response = listRaw(); return InvoiceListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for invoice without params. */ + public CompletableFuture listAsync() { + + return getAsync("/invoices", null) + .thenApply( + response -> + InvoiceListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a invoice using immutable params (executes immediately) - returns raw Response. */ Response createRaw(InvoiceCreateParams params) throws ChargebeeException { @@ -660,6 +898,14 @@ public InvoiceCreateResponse create(InvoiceCreateParams params) throws Chargebee return InvoiceCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for invoice with params. */ + public CompletableFuture createAsync(InvoiceCreateParams params) { + + return postAsync("/invoices", params != null ? params.toFormData() : null) + .thenApply( + response -> InvoiceCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** close a invoice (executes immediately) - returns raw Response. */ Response closeRaw(String invoiceId) throws ChargebeeException { String path = buildPathWithParams("/invoices/{invoice-id}/close", "invoice-id", invoiceId); @@ -685,11 +931,27 @@ public InvoiceCloseResponse close(String invoiceId, InvoiceCloseParams params) return InvoiceCloseResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of close for invoice with params. */ + public CompletableFuture closeAsync( + String invoiceId, InvoiceCloseParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}/close", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply(response -> InvoiceCloseResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceCloseResponse close(String invoiceId) throws ChargebeeException { Response response = closeRaw(invoiceId); return InvoiceCloseResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of close for invoice without params. */ + public CompletableFuture closeAsync(String invoiceId) { + String path = buildPathWithParams("/invoices/{invoice-id}/close", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply(response -> InvoiceCloseResponse.fromJson(response.getBodyAsString(), response)); + } + /** applyCredits a invoice (executes immediately) - returns raw Response. */ Response applyCreditsRaw(String invoiceId) throws ChargebeeException { String path = @@ -723,11 +985,31 @@ public InvoiceApplyCreditsResponse applyCredits( return InvoiceApplyCreditsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of applyCredits for invoice with params. */ + public CompletableFuture applyCreditsAsync( + String invoiceId, InvoiceApplyCreditsParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/apply_credits", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> InvoiceApplyCreditsResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceApplyCreditsResponse applyCredits(String invoiceId) throws ChargebeeException { Response response = applyCreditsRaw(invoiceId); return InvoiceApplyCreditsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of applyCredits for invoice without params. */ + public CompletableFuture applyCreditsAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/apply_credits", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> InvoiceApplyCreditsResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a invoice (executes immediately) - returns raw Response. */ Response retrieveRaw(String invoiceId) throws ChargebeeException { String path = buildPathWithParams("/invoices/{invoice-id}", "invoice-id", invoiceId); @@ -747,11 +1029,29 @@ public InvoiceRetrieveResponse retrieve(String invoiceId, InvoiceRetrieveParams return InvoiceRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for invoice with params. */ + public CompletableFuture retrieveAsync( + String invoiceId, InvoiceRetrieveParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}", "invoice-id", invoiceId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> InvoiceRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceRetrieveResponse retrieve(String invoiceId) throws ChargebeeException { Response response = retrieveRaw(invoiceId); return InvoiceRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for invoice without params. */ + public CompletableFuture retrieveAsync(String invoiceId) { + String path = buildPathWithParams("/invoices/{invoice-id}", "invoice-id", invoiceId); + + return getAsync(path, null) + .thenApply( + response -> InvoiceRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createForChargeItem a invoice using immutable params (executes immediately) - returns raw * Response. @@ -778,6 +1078,17 @@ public InvoiceCreateForChargeItemResponse createForChargeItem( return InvoiceCreateForChargeItemResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createForChargeItem for invoice with params. */ + public CompletableFuture createForChargeItemAsync( + InvoiceCreateForChargeItemParams params) { + + return postAsync( + "/invoices/create_for_charge_item", params != null ? params.toFormData() : null) + .thenApply( + response -> + InvoiceCreateForChargeItemResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createForChargeItemsAndCharges a invoice using immutable params (executes immediately) - * returns raw Response. @@ -807,6 +1118,19 @@ public InvoiceCreateForChargeItemsAndChargesResponse createForChargeItemsAndChar response.getBodyAsString(), response); } + /** Async variant of createForChargeItemsAndCharges for invoice with params. */ + public CompletableFuture + createForChargeItemsAndChargesAsync(InvoiceCreateForChargeItemsAndChargesParams params) { + + return postAsync( + "/invoices/create_for_charge_items_and_charges", + params != null ? params.toFormData() : null) + .thenApply( + response -> + InvoiceCreateForChargeItemsAndChargesResponse.fromJson( + response.getBodyAsString(), response)); + } + /** deleteImported a invoice (executes immediately) - returns raw Response. */ Response deleteImportedRaw(String invoiceId) throws ChargebeeException { String path = @@ -840,11 +1164,33 @@ public InvoiceDeleteImportedResponse deleteImported( return InvoiceDeleteImportedResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteImported for invoice with params. */ + public CompletableFuture deleteImportedAsync( + String invoiceId, InvoiceDeleteImportedParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/delete_imported", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceDeleteImportedResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceDeleteImportedResponse deleteImported(String invoiceId) throws ChargebeeException { Response response = deleteImportedRaw(invoiceId); return InvoiceDeleteImportedResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteImported for invoice without params. */ + public CompletableFuture deleteImportedAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/delete_imported", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceDeleteImportedResponse.fromJson(response.getBodyAsString(), response)); + } + /** updateDetails a invoice (executes immediately) - returns raw Response. */ Response updateDetailsRaw(String invoiceId) throws ChargebeeException { String path = @@ -878,11 +1224,33 @@ public InvoiceUpdateDetailsResponse updateDetails( return InvoiceUpdateDetailsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateDetails for invoice with params. */ + public CompletableFuture updateDetailsAsync( + String invoiceId, InvoiceUpdateDetailsParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/update_details", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceUpdateDetailsResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceUpdateDetailsResponse updateDetails(String invoiceId) throws ChargebeeException { Response response = updateDetailsRaw(invoiceId); return InvoiceUpdateDetailsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateDetails for invoice without params. */ + public CompletableFuture updateDetailsAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/update_details", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceUpdateDetailsResponse.fromJson(response.getBodyAsString(), response)); + } + /** * invoicesForCustomer a invoice using immutable params (executes immediately) - returns raw * Response. @@ -925,6 +1293,30 @@ public InvoicesForCustomerResponse invoicesForCustomer(String customerId) response.getBodyAsString(), this, null, customerId, response); } + /** Async variant of invoicesForCustomer for invoice with params. */ + public CompletableFuture invoicesForCustomerAsync( + String customerId, InvoicesForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/invoices", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + InvoicesForCustomerResponse.fromJson( + response.getBodyAsString(), this, params, customerId, response)); + } + + /** Async variant of invoicesForCustomer for invoice without params. */ + public CompletableFuture invoicesForCustomerAsync( + String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/invoices", "customer-id", customerId); + return getAsync(path, null) + .thenApply( + response -> + InvoicesForCustomerResponse.fromJson( + response.getBodyAsString(), this, null, customerId, response)); + } + /** recordPayment a invoice (executes immediately) - returns raw Response. */ Response recordPaymentRaw(String invoiceId) throws ChargebeeException { String path = @@ -958,11 +1350,33 @@ public InvoiceRecordPaymentResponse recordPayment( return InvoiceRecordPaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordPayment for invoice with params. */ + public CompletableFuture recordPaymentAsync( + String invoiceId, InvoiceRecordPaymentParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/record_payment", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceRecordPaymentResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceRecordPaymentResponse recordPayment(String invoiceId) throws ChargebeeException { Response response = recordPaymentRaw(invoiceId); return InvoiceRecordPaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordPayment for invoice without params. */ + public CompletableFuture recordPaymentAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/record_payment", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceRecordPaymentResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a invoice (executes immediately) - returns raw Response. */ Response deleteRaw(String invoiceId) throws ChargebeeException { String path = buildPathWithParams("/invoices/{invoice-id}/delete", "invoice-id", invoiceId); @@ -988,11 +1402,29 @@ public InvoiceDeleteResponse delete(String invoiceId, InvoiceDeleteParams params return InvoiceDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for invoice with params. */ + public CompletableFuture deleteAsync( + String invoiceId, InvoiceDeleteParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}/delete", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> InvoiceDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceDeleteResponse delete(String invoiceId) throws ChargebeeException { Response response = deleteRaw(invoiceId); return InvoiceDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for invoice without params. */ + public CompletableFuture deleteAsync(String invoiceId) { + String path = buildPathWithParams("/invoices/{invoice-id}/delete", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> InvoiceDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * importInvoice a invoice using immutable params (executes immediately) - returns raw Response. */ @@ -1015,6 +1447,14 @@ public ImportInvoiceResponse importInvoice(ImportInvoiceParams params) throws Ch return ImportInvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importInvoice for invoice with params. */ + public CompletableFuture importInvoiceAsync(ImportInvoiceParams params) { + + return postAsync("/invoices/import_invoice", params != null ? params.toFormData() : null) + .thenApply( + response -> ImportInvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + /** resumeDunning a invoice (executes immediately) - returns raw Response. */ Response resumeDunningRaw(String invoiceId) throws ChargebeeException { String path = @@ -1048,11 +1488,33 @@ public InvoiceResumeDunningResponse resumeDunning( return InvoiceResumeDunningResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resumeDunning for invoice with params. */ + public CompletableFuture resumeDunningAsync( + String invoiceId, InvoiceResumeDunningParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/resume_dunning", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceResumeDunningResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceResumeDunningResponse resumeDunning(String invoiceId) throws ChargebeeException { Response response = resumeDunningRaw(invoiceId); return InvoiceResumeDunningResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resumeDunning for invoice without params. */ + public CompletableFuture resumeDunningAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/resume_dunning", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceResumeDunningResponse.fromJson(response.getBodyAsString(), response)); + } + /** recordTaxWithheld a invoice (executes immediately) - returns raw Response. */ Response recordTaxWithheldRaw(String invoiceId) throws ChargebeeException { String path = @@ -1088,12 +1550,35 @@ public InvoiceRecordTaxWithheldResponse recordTaxWithheld( return InvoiceRecordTaxWithheldResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordTaxWithheld for invoice with params. */ + public CompletableFuture recordTaxWithheldAsync( + String invoiceId, InvoiceRecordTaxWithheldParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/record_tax_withheld", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceRecordTaxWithheldResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceRecordTaxWithheldResponse recordTaxWithheld(String invoiceId) throws ChargebeeException { Response response = recordTaxWithheldRaw(invoiceId); return InvoiceRecordTaxWithheldResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordTaxWithheld for invoice without params. */ + public CompletableFuture recordTaxWithheldAsync( + String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/record_tax_withheld", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceRecordTaxWithheldResponse.fromJson(response.getBodyAsString(), response)); + } + /** resendEinvoice a invoice (executes immediately) - returns raw Response. */ Response resendEinvoiceRaw(String invoiceId) throws ChargebeeException { String path = @@ -1107,6 +1592,16 @@ public ResendEinvoiceResponse resendEinvoice(String invoiceId) throws ChargebeeE return ResendEinvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resendEinvoice for invoice without params. */ + public CompletableFuture resendEinvoiceAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/resend_einvoice", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> ResendEinvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + /** removeTaxWithheld a invoice (executes immediately) - returns raw Response. */ Response removeTaxWithheldRaw(String invoiceId) throws ChargebeeException { String path = @@ -1142,12 +1637,35 @@ public InvoiceRemoveTaxWithheldResponse removeTaxWithheld( return InvoiceRemoveTaxWithheldResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeTaxWithheld for invoice with params. */ + public CompletableFuture removeTaxWithheldAsync( + String invoiceId, InvoiceRemoveTaxWithheldParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/remove_tax_withheld", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceRemoveTaxWithheldResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceRemoveTaxWithheldResponse removeTaxWithheld(String invoiceId) throws ChargebeeException { Response response = removeTaxWithheldRaw(invoiceId); return InvoiceRemoveTaxWithheldResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeTaxWithheld for invoice without params. */ + public CompletableFuture removeTaxWithheldAsync( + String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/remove_tax_withheld", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceRemoveTaxWithheldResponse.fromJson(response.getBodyAsString(), response)); + } + /** * listPaymentReferenceNumbers a invoice using immutable params (executes immediately) - returns * raw Response. @@ -1185,6 +1703,18 @@ public InvoiceListPaymentReferenceNumbersResponse listPaymentReferenceNumbers( response.getBodyAsString(), this, params, response); } + /** Async variant of listPaymentReferenceNumbers for invoice with params. */ + public CompletableFuture + listPaymentReferenceNumbersAsync(InvoiceListPaymentReferenceNumbersParams params) { + + return getAsync( + "/invoices/payment_reference_numbers", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + InvoiceListPaymentReferenceNumbersResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public InvoiceListPaymentReferenceNumbersResponse listPaymentReferenceNumbers() throws ChargebeeException { Response response = listPaymentReferenceNumbersRaw(); @@ -1193,6 +1723,17 @@ public InvoiceListPaymentReferenceNumbersResponse listPaymentReferenceNumbers() response.getBodyAsString(), this, null, response); } + /** Async variant of listPaymentReferenceNumbers for invoice without params. */ + public CompletableFuture + listPaymentReferenceNumbersAsync() { + + return getAsync("/invoices/payment_reference_numbers", null) + .thenApply( + response -> + InvoiceListPaymentReferenceNumbersResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** collectPayment a invoice (executes immediately) - returns raw Response. */ Response collectPaymentRaw(String invoiceId) throws ChargebeeException { String path = @@ -1226,11 +1767,33 @@ public InvoiceCollectPaymentResponse collectPayment( return InvoiceCollectPaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of collectPayment for invoice with params. */ + public CompletableFuture collectPaymentAsync( + String invoiceId, InvoiceCollectPaymentParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/collect_payment", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceCollectPaymentResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceCollectPaymentResponse collectPayment(String invoiceId) throws ChargebeeException { Response response = collectPaymentRaw(invoiceId); return InvoiceCollectPaymentResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of collectPayment for invoice without params. */ + public CompletableFuture collectPaymentAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/collect_payment", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> + InvoiceCollectPaymentResponse.fromJson(response.getBodyAsString(), response)); + } + /** syncUsages a invoice (executes immediately) - returns raw Response. */ Response syncUsagesRaw(String invoiceId) throws ChargebeeException { String path = @@ -1244,6 +1807,16 @@ public InvoiceSyncUsagesResponse syncUsages(String invoiceId) throws ChargebeeEx return InvoiceSyncUsagesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of syncUsages for invoice without params. */ + public CompletableFuture syncUsagesAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/sync_usages", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> InvoiceSyncUsagesResponse.fromJson(response.getBodyAsString(), response)); + } + /** refund a invoice (executes immediately) - returns raw Response. */ Response refundRaw(String invoiceId) throws ChargebeeException { String path = buildPathWithParams("/invoices/{invoice-id}/refund", "invoice-id", invoiceId); @@ -1269,11 +1842,29 @@ public InvoiceRefundResponse refund(String invoiceId, InvoiceRefundParams params return InvoiceRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of refund for invoice with params. */ + public CompletableFuture refundAsync( + String invoiceId, InvoiceRefundParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}/refund", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> InvoiceRefundResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceRefundResponse refund(String invoiceId) throws ChargebeeException { Response response = refundRaw(invoiceId); return InvoiceRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of refund for invoice without params. */ + public CompletableFuture refundAsync(String invoiceId) { + String path = buildPathWithParams("/invoices/{invoice-id}/refund", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> InvoiceRefundResponse.fromJson(response.getBodyAsString(), response)); + } + /** recordRefund a invoice (executes immediately) - returns raw Response. */ Response recordRefundRaw(String invoiceId) throws ChargebeeException { String path = @@ -1307,11 +1898,31 @@ public InvoiceRecordRefundResponse recordRefund( return InvoiceRecordRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordRefund for invoice with params. */ + public CompletableFuture recordRefundAsync( + String invoiceId, InvoiceRecordRefundParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/record_refund", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> InvoiceRecordRefundResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoiceRecordRefundResponse recordRefund(String invoiceId) throws ChargebeeException { Response response = recordRefundRaw(invoiceId); return InvoiceRecordRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordRefund for invoice without params. */ + public CompletableFuture recordRefundAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/record_refund", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply( + response -> InvoiceRecordRefundResponse.fromJson(response.getBodyAsString(), response)); + } + /** pdf a invoice (executes immediately) - returns raw Response. */ Response pdfRaw(String invoiceId) throws ChargebeeException { String path = buildPathWithParams("/invoices/{invoice-id}/pdf", "invoice-id", invoiceId); @@ -1337,11 +1948,26 @@ public InvoicePdfResponse pdf(String invoiceId, InvoicePdfParams params) return InvoicePdfResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pdf for invoice with params. */ + public CompletableFuture pdfAsync(String invoiceId, InvoicePdfParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}/pdf", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply(response -> InvoicePdfResponse.fromJson(response.getBodyAsString(), response)); + } + public InvoicePdfResponse pdf(String invoiceId) throws ChargebeeException { Response response = pdfRaw(invoiceId); return InvoicePdfResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pdf for invoice without params. */ + public CompletableFuture pdfAsync(String invoiceId) { + String path = buildPathWithParams("/invoices/{invoice-id}/pdf", "invoice-id", invoiceId); + + return postAsync(path, null) + .thenApply(response -> InvoicePdfResponse.fromJson(response.getBodyAsString(), response)); + } + /** * invoicesForSubscription a invoice using immutable params (executes immediately) - returns raw * Response. @@ -1390,6 +2016,32 @@ public InvoicesForSubscriptionResponse invoicesForSubscription(String subscripti response.getBodyAsString(), this, null, subscriptionId, response); } + /** Async variant of invoicesForSubscription for invoice with params. */ + public CompletableFuture invoicesForSubscriptionAsync( + String subscriptionId, InvoicesForSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/invoices", "subscription-id", subscriptionId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + InvoicesForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, params, subscriptionId, response)); + } + + /** Async variant of invoicesForSubscription for invoice without params. */ + public CompletableFuture invoicesForSubscriptionAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/invoices", "subscription-id", subscriptionId); + return getAsync(path, null) + .thenApply( + response -> + InvoicesForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, null, subscriptionId, response)); + } + /** downloadEinvoice a invoice (executes immediately) - returns raw Response. */ Response downloadEinvoiceRaw(String invoiceId) throws ChargebeeException { String path = @@ -1403,6 +2055,16 @@ public DownloadEinvoiceResponse downloadEinvoice(String invoiceId) throws Charge return DownloadEinvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of downloadEinvoice for invoice without params. */ + public CompletableFuture downloadEinvoiceAsync(String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/download_einvoice", "invoice-id", invoiceId); + + return getAsync(path, null) + .thenApply( + response -> DownloadEinvoiceResponse.fromJson(response.getBodyAsString(), response)); + } + /** chargeAddon a invoice using immutable params (executes immediately) - returns raw Response. */ Response chargeAddonRaw(InvoiceChargeAddonParams params) throws ChargebeeException { @@ -1422,6 +2084,15 @@ public InvoiceChargeAddonResponse chargeAddon(InvoiceChargeAddonParams params) return InvoiceChargeAddonResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of chargeAddon for invoice with params. */ + public CompletableFuture chargeAddonAsync( + InvoiceChargeAddonParams params) { + + return postAsync("/invoices/charge_addon", params != null ? params.toFormData() : null) + .thenApply( + response -> InvoiceChargeAddonResponse.fromJson(response.getBodyAsString(), response)); + } + /** addAddonCharge a invoice (executes immediately) - returns raw Response. */ Response addAddonChargeRaw(String invoiceId) throws ChargebeeException { String path = @@ -1455,6 +2126,17 @@ public InvoiceAddAddonChargeResponse addAddonCharge( return InvoiceAddAddonChargeResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addAddonCharge for invoice with params. */ + public CompletableFuture addAddonChargeAsync( + String invoiceId, InvoiceAddAddonChargeParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/add_addon_charge", "invoice-id", invoiceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + InvoiceAddAddonChargeResponse.fromJson(response.getBodyAsString(), response)); + } + /** charge a invoice using immutable params (executes immediately) - returns raw Response. */ Response chargeRaw(InvoiceChargeParams params) throws ChargebeeException { @@ -1472,4 +2154,12 @@ public InvoiceChargeResponse charge(InvoiceChargeParams params) throws Chargebee return InvoiceChargeResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of charge for invoice with params. */ + public CompletableFuture chargeAsync(InvoiceChargeParams params) { + + return postAsync("/invoices/charge", params != null ? params.toFormData() : null) + .thenApply( + response -> InvoiceChargeResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ItemEntitlementService.java b/src/main/java/com/chargebee/v4/services/ItemEntitlementService.java index c832d093..aba621e5 100644 --- a/src/main/java/com/chargebee/v4/services/ItemEntitlementService.java +++ b/src/main/java/com/chargebee/v4/services/ItemEntitlementService.java @@ -11,6 +11,7 @@ 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.itemEntitlement.params.ItemEntitlementsForFeatureParams; @@ -109,6 +110,30 @@ public ItemEntitlementsForFeatureResponse itemEntitlementsForFeature(String feat response.getBodyAsString(), this, null, featureId, response); } + /** Async variant of itemEntitlementsForFeature for itemEntitlement with params. */ + public CompletableFuture itemEntitlementsForFeatureAsync( + String featureId, ItemEntitlementsForFeatureParams params) { + String path = + buildPathWithParams("/features/{feature-id}/item_entitlements", "feature-id", featureId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ItemEntitlementsForFeatureResponse.fromJson( + response.getBodyAsString(), this, params, featureId, response)); + } + + /** Async variant of itemEntitlementsForFeature for itemEntitlement without params. */ + public CompletableFuture itemEntitlementsForFeatureAsync( + String featureId) { + String path = + buildPathWithParams("/features/{feature-id}/item_entitlements", "feature-id", featureId); + return getAsync(path, null) + .thenApply( + response -> + ItemEntitlementsForFeatureResponse.fromJson( + response.getBodyAsString(), this, null, featureId, response)); + } + /** addItemEntitlements a itemEntitlement (executes immediately) - returns raw Response. */ Response addItemEntitlementsRaw(String featureId) throws ChargebeeException { String path = @@ -144,6 +169,16 @@ public AddItemEntitlementsResponse addItemEntitlements( return AddItemEntitlementsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addItemEntitlements for itemEntitlement with params. */ + public CompletableFuture addItemEntitlementsAsync( + String featureId, AddItemEntitlementsParams params) { + String path = + buildPathWithParams("/features/{feature-id}/item_entitlements", "feature-id", featureId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> AddItemEntitlementsResponse.fromJson(response.getBodyAsString(), response)); + } + /** * itemEntitlementsForItem a itemEntitlement using immutable params (executes immediately) - * returns raw Response. @@ -186,6 +221,28 @@ public ItemEntitlementsForItemResponse itemEntitlementsForItem(String itemId) response.getBodyAsString(), this, null, itemId, response); } + /** Async variant of itemEntitlementsForItem for itemEntitlement with params. */ + public CompletableFuture itemEntitlementsForItemAsync( + String itemId, ItemEntitlementsForItemParams params) { + String path = buildPathWithParams("/items/{item-id}/item_entitlements", "item-id", itemId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ItemEntitlementsForItemResponse.fromJson( + response.getBodyAsString(), this, params, itemId, response)); + } + + /** Async variant of itemEntitlementsForItem for itemEntitlement without params. */ + public CompletableFuture itemEntitlementsForItemAsync( + String itemId) { + String path = buildPathWithParams("/items/{item-id}/item_entitlements", "item-id", itemId); + return getAsync(path, null) + .thenApply( + response -> + ItemEntitlementsForItemResponse.fromJson( + response.getBodyAsString(), this, null, itemId, response)); + } + /** * upsertOrRemoveItemEntitlementsForItem a itemEntitlement (executes immediately) - returns raw * Response. @@ -222,4 +279,16 @@ public UpsertOrRemoveItemEntitlementsForItemResponse upsertOrRemoveItemEntitleme return UpsertOrRemoveItemEntitlementsForItemResponse.fromJson( response.getBodyAsString(), response); } + + /** Async variant of upsertOrRemoveItemEntitlementsForItem for itemEntitlement with params. */ + public CompletableFuture + upsertOrRemoveItemEntitlementsForItemAsync( + String itemId, UpsertOrRemoveItemEntitlementsForItemParams params) { + String path = buildPathWithParams("/items/{item-id}/item_entitlements", "item-id", itemId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + UpsertOrRemoveItemEntitlementsForItemResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ItemFamilyService.java b/src/main/java/com/chargebee/v4/services/ItemFamilyService.java index 3e93d286..9a31f2f2 100644 --- a/src/main/java/com/chargebee/v4/services/ItemFamilyService.java +++ b/src/main/java/com/chargebee/v4/services/ItemFamilyService.java @@ -11,6 +11,7 @@ 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.itemFamily.params.ItemFamilyListParams; @@ -76,6 +77,17 @@ public ItemFamilyDeleteResponse delete(String itemFamilyId) throws ChargebeeExce return ItemFamilyDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for itemFamily without params. */ + public CompletableFuture deleteAsync(String itemFamilyId) { + String path = + buildPathWithParams( + "/item_families/{item-family-id}/delete", "item-family-id", itemFamilyId); + + return postAsync(path, null) + .thenApply( + response -> ItemFamilyDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a itemFamily using immutable params (executes immediately) - returns raw Response. */ Response listRaw(ItemFamilyListParams params) throws ChargebeeException { @@ -100,12 +112,31 @@ public ItemFamilyListResponse list(ItemFamilyListParams params) throws Chargebee return ItemFamilyListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for itemFamily with params. */ + public CompletableFuture listAsync(ItemFamilyListParams params) { + + return getAsync("/item_families", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ItemFamilyListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public ItemFamilyListResponse list() throws ChargebeeException { Response response = listRaw(); return ItemFamilyListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for itemFamily without params. */ + public CompletableFuture listAsync() { + + return getAsync("/item_families", null) + .thenApply( + response -> + ItemFamilyListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a itemFamily using immutable params (executes immediately) - returns raw Response. */ Response createRaw(ItemFamilyCreateParams params) throws ChargebeeException { @@ -124,6 +155,14 @@ public ItemFamilyCreateResponse create(ItemFamilyCreateParams params) throws Cha return ItemFamilyCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for itemFamily with params. */ + public CompletableFuture createAsync(ItemFamilyCreateParams params) { + + return postAsync("/item_families", params != null ? params.toFormData() : null) + .thenApply( + response -> ItemFamilyCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a itemFamily (executes immediately) - returns raw Response. */ Response retrieveRaw(String itemFamilyId) throws ChargebeeException { String path = @@ -137,6 +176,16 @@ public ItemFamilyRetrieveResponse retrieve(String itemFamilyId) throws Chargebee return ItemFamilyRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for itemFamily without params. */ + public CompletableFuture retrieveAsync(String itemFamilyId) { + String path = + buildPathWithParams("/item_families/{item-family-id}", "item-family-id", itemFamilyId); + + return getAsync(path, null) + .thenApply( + response -> ItemFamilyRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a itemFamily (executes immediately) - returns raw Response. */ Response updateRaw(String itemFamilyId) throws ChargebeeException { String path = @@ -165,8 +214,28 @@ public ItemFamilyUpdateResponse update(String itemFamilyId, ItemFamilyUpdatePara return ItemFamilyUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for itemFamily with params. */ + public CompletableFuture updateAsync( + String itemFamilyId, ItemFamilyUpdateParams params) { + String path = + buildPathWithParams("/item_families/{item-family-id}", "item-family-id", itemFamilyId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> ItemFamilyUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public ItemFamilyUpdateResponse update(String itemFamilyId) throws ChargebeeException { Response response = updateRaw(itemFamilyId); return ItemFamilyUpdateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of update for itemFamily without params. */ + public CompletableFuture updateAsync(String itemFamilyId) { + String path = + buildPathWithParams("/item_families/{item-family-id}", "item-family-id", itemFamilyId); + + return postAsync(path, null) + .thenApply( + response -> ItemFamilyUpdateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ItemPriceService.java b/src/main/java/com/chargebee/v4/services/ItemPriceService.java index 5940deb8..018e6bad 100644 --- a/src/main/java/com/chargebee/v4/services/ItemPriceService.java +++ b/src/main/java/com/chargebee/v4/services/ItemPriceService.java @@ -11,6 +11,7 @@ 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.itemPrice.params.ItemPriceUpdateParams; @@ -82,6 +83,15 @@ public ItemPriceRetrieveResponse retrieve(String itemPriceId) throws ChargebeeEx return ItemPriceRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for itemPrice without params. */ + public CompletableFuture retrieveAsync(String itemPriceId) { + String path = buildPathWithParams("/item_prices/{item-price-id}", "item-price-id", itemPriceId); + + return getAsync(path, null) + .thenApply( + response -> ItemPriceRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a itemPrice (executes immediately) - returns raw Response. */ Response updateRaw(String itemPriceId) throws ChargebeeException { String path = buildPathWithParams("/item_prices/{item-price-id}", "item-price-id", itemPriceId); @@ -107,11 +117,29 @@ public ItemPriceUpdateResponse update(String itemPriceId, ItemPriceUpdateParams return ItemPriceUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for itemPrice with params. */ + public CompletableFuture updateAsync( + String itemPriceId, ItemPriceUpdateParams params) { + String path = buildPathWithParams("/item_prices/{item-price-id}", "item-price-id", itemPriceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> ItemPriceUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public ItemPriceUpdateResponse update(String itemPriceId) throws ChargebeeException { Response response = updateRaw(itemPriceId); return ItemPriceUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for itemPrice without params. */ + public CompletableFuture updateAsync(String itemPriceId) { + String path = buildPathWithParams("/item_prices/{item-price-id}", "item-price-id", itemPriceId); + + return postAsync(path, null) + .thenApply( + response -> ItemPriceUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a itemPrice (executes immediately) - returns raw Response. */ Response deleteRaw(String itemPriceId) throws ChargebeeException { String path = @@ -125,6 +153,16 @@ public ItemPriceDeleteResponse delete(String itemPriceId) throws ChargebeeExcept return ItemPriceDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for itemPrice without params. */ + public CompletableFuture deleteAsync(String itemPriceId) { + String path = + buildPathWithParams("/item_prices/{item-price-id}/delete", "item-price-id", itemPriceId); + + return postAsync(path, null) + .thenApply( + response -> ItemPriceDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * findApplicableItemPrices a itemPrice using immutable params (executes immediately) - returns * raw Response. @@ -174,6 +212,32 @@ public FindApplicableItemPricesResponse findApplicableItemPrices(String itemPric response.getBodyAsString(), this, null, itemPriceId, response); } + /** Async variant of findApplicableItemPrices for itemPrice with params. */ + public CompletableFuture findApplicableItemPricesAsync( + String itemPriceId, FindApplicableItemPricesParams params) { + String path = + buildPathWithParams( + "/item_prices/{item-price-id}/applicable_item_prices", "item-price-id", itemPriceId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + FindApplicableItemPricesResponse.fromJson( + response.getBodyAsString(), this, params, itemPriceId, response)); + } + + /** Async variant of findApplicableItemPrices for itemPrice without params. */ + public CompletableFuture findApplicableItemPricesAsync( + String itemPriceId) { + String path = + buildPathWithParams( + "/item_prices/{item-price-id}/applicable_item_prices", "item-price-id", itemPriceId); + return getAsync(path, null) + .thenApply( + response -> + FindApplicableItemPricesResponse.fromJson( + response.getBodyAsString(), this, null, itemPriceId, response)); + } + /** * findApplicableItems a itemPrice using immutable params (executes immediately) - returns raw * Response. @@ -222,6 +286,32 @@ public ItemPriceFindApplicableItemsResponse findApplicableItems(String itemPrice response.getBodyAsString(), this, null, itemPriceId, response); } + /** Async variant of findApplicableItems for itemPrice with params. */ + public CompletableFuture findApplicableItemsAsync( + String itemPriceId, ItemPriceFindApplicableItemsParams params) { + String path = + buildPathWithParams( + "/item_prices/{item-price-id}/applicable_items", "item-price-id", itemPriceId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ItemPriceFindApplicableItemsResponse.fromJson( + response.getBodyAsString(), this, params, itemPriceId, response)); + } + + /** Async variant of findApplicableItems for itemPrice without params. */ + public CompletableFuture findApplicableItemsAsync( + String itemPriceId) { + String path = + buildPathWithParams( + "/item_prices/{item-price-id}/applicable_items", "item-price-id", itemPriceId); + return getAsync(path, null) + .thenApply( + response -> + ItemPriceFindApplicableItemsResponse.fromJson( + response.getBodyAsString(), this, null, itemPriceId, response)); + } + /** list a itemPrice using immutable params (executes immediately) - returns raw Response. */ Response listRaw(ItemPriceListParams params) throws ChargebeeException { @@ -246,12 +336,30 @@ public ItemPriceListResponse list(ItemPriceListParams params) throws ChargebeeEx return ItemPriceListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for itemPrice with params. */ + public CompletableFuture listAsync(ItemPriceListParams params) { + + return getAsync("/item_prices", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ItemPriceListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public ItemPriceListResponse list() throws ChargebeeException { Response response = listRaw(); return ItemPriceListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for itemPrice without params. */ + public CompletableFuture listAsync() { + + return getAsync("/item_prices", null) + .thenApply( + response -> + ItemPriceListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a itemPrice using immutable params (executes immediately) - returns raw Response. */ Response createRaw(ItemPriceCreateParams params) throws ChargebeeException { @@ -269,4 +377,12 @@ public ItemPriceCreateResponse create(ItemPriceCreateParams params) throws Charg return ItemPriceCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for itemPrice with params. */ + public CompletableFuture createAsync(ItemPriceCreateParams params) { + + return postAsync("/item_prices", params != null ? params.toFormData() : null) + .thenApply( + response -> ItemPriceCreateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ItemService.java b/src/main/java/com/chargebee/v4/services/ItemService.java index 45725a44..ac3be22d 100644 --- a/src/main/java/com/chargebee/v4/services/ItemService.java +++ b/src/main/java/com/chargebee/v4/services/ItemService.java @@ -11,6 +11,7 @@ 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.item.params.ItemListParams; @@ -86,12 +87,30 @@ public ItemListResponse list(ItemListParams params) throws ChargebeeException { return ItemListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for item with params. */ + public CompletableFuture listAsync(ItemListParams params) { + + return getAsync("/items", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ItemListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public ItemListResponse list() throws ChargebeeException { Response response = listRaw(); return ItemListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for item without params. */ + public CompletableFuture listAsync() { + + return getAsync("/items", null) + .thenApply( + response -> + ItemListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a item using immutable params (executes immediately) - returns raw Response. */ Response createRaw(ItemCreateParams params) throws ChargebeeException { @@ -110,6 +129,13 @@ public ItemCreateResponse create(ItemCreateParams params) throws ChargebeeExcept return ItemCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for item with params. */ + public CompletableFuture createAsync(ItemCreateParams params) { + + return postAsync("/items", params != null ? params.toFormData() : null) + .thenApply(response -> ItemCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a item (executes immediately) - returns raw Response. */ Response deleteRaw(String itemId) throws ChargebeeException { String path = buildPathWithParams("/items/{item-id}/delete", "item-id", itemId); @@ -122,6 +148,14 @@ public ItemDeleteResponse delete(String itemId) throws ChargebeeException { return ItemDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for item without params. */ + public CompletableFuture deleteAsync(String itemId) { + String path = buildPathWithParams("/items/{item-id}/delete", "item-id", itemId); + + return postAsync(path, null) + .thenApply(response -> ItemDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a item (executes immediately) - returns raw Response. */ Response retrieveRaw(String itemId) throws ChargebeeException { String path = buildPathWithParams("/items/{item-id}", "item-id", itemId); @@ -134,6 +168,14 @@ public ItemRetrieveResponse retrieve(String itemId) throws ChargebeeException { return ItemRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for item without params. */ + public CompletableFuture retrieveAsync(String itemId) { + String path = buildPathWithParams("/items/{item-id}", "item-id", itemId); + + return getAsync(path, null) + .thenApply(response -> ItemRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a item (executes immediately) - returns raw Response. */ Response updateRaw(String itemId) throws ChargebeeException { String path = buildPathWithParams("/items/{item-id}", "item-id", itemId); @@ -159,8 +201,23 @@ public ItemUpdateResponse update(String itemId, ItemUpdateParams params) return ItemUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for item with params. */ + public CompletableFuture updateAsync(String itemId, ItemUpdateParams params) { + String path = buildPathWithParams("/items/{item-id}", "item-id", itemId); + return postAsync(path, params.toFormData()) + .thenApply(response -> ItemUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public ItemUpdateResponse update(String itemId) throws ChargebeeException { Response response = updateRaw(itemId); return ItemUpdateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of update for item without params. */ + public CompletableFuture updateAsync(String itemId) { + String path = buildPathWithParams("/items/{item-id}", "item-id", itemId); + + return postAsync(path, null) + .thenApply(response -> ItemUpdateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/MediaService.java b/src/main/java/com/chargebee/v4/services/MediaService.java index f990ff60..0ce35467 100644 --- a/src/main/java/com/chargebee/v4/services/MediaService.java +++ b/src/main/java/com/chargebee/v4/services/MediaService.java @@ -11,6 +11,7 @@ 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.media.params.CreateMediaAndAttachToItemParams; @@ -82,4 +83,14 @@ public CreateMediaAndAttachToItemResponse createMediaAndAttachToItem( Response response = createMediaAndAttachToItemRaw(itemId, params); return CreateMediaAndAttachToItemResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of createMediaAndAttachToItem for media with params. */ + public CompletableFuture createMediaAndAttachToItemAsync( + String itemId, CreateMediaAndAttachToItemParams params) { + String path = buildPathWithParams("/items/{item-id}/media", "item-id", itemId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CreateMediaAndAttachToItemResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/NonSubscriptionService.java b/src/main/java/com/chargebee/v4/services/NonSubscriptionService.java index 693e9454..dbd3e6f2 100644 --- a/src/main/java/com/chargebee/v4/services/NonSubscriptionService.java +++ b/src/main/java/com/chargebee/v4/services/NonSubscriptionService.java @@ -11,6 +11,7 @@ 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.nonSubscription.params.NonSubscriptionProcessReceiptParams; @@ -97,4 +98,19 @@ public NonSubscriptionProcessReceiptResponse processReceipt( Response response = processReceiptRaw(nonSubscriptionAppId, params); return NonSubscriptionProcessReceiptResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of processReceipt for nonSubscription with params. */ + public CompletableFuture processReceiptAsync( + String nonSubscriptionAppId, NonSubscriptionProcessReceiptParams params) { + String path = + buildPathWithParams( + "/non_subscriptions/{non-subscription-app-id}/one_time_purchase", + "non-subscription-app-id", + nonSubscriptionAppId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + NonSubscriptionProcessReceiptResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/OfferEventService.java b/src/main/java/com/chargebee/v4/services/OfferEventService.java index 9db3e9d3..f4c75ba0 100644 --- a/src/main/java/com/chargebee/v4/services/OfferEventService.java +++ b/src/main/java/com/chargebee/v4/services/OfferEventService.java @@ -11,6 +11,7 @@ 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.offerEvent.params.OfferEventsParams; @@ -74,4 +75,14 @@ public OfferEventsResponse offerEvents(OfferEventsParams params) throws Chargebe return OfferEventsResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of offerEvents for offerEvent with params. */ + public CompletableFuture offerEventsAsync(OfferEventsParams params) { + + return postJsonWithSubDomainAsync( + "/offer_events", + SubDomain.GROW.getValue(), + params != null ? params.toJsonString() : null) + .thenApply(response -> OfferEventsResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/OfferFulfillmentService.java b/src/main/java/com/chargebee/v4/services/OfferFulfillmentService.java index 9a81da7b..40fbbe94 100644 --- a/src/main/java/com/chargebee/v4/services/OfferFulfillmentService.java +++ b/src/main/java/com/chargebee/v4/services/OfferFulfillmentService.java @@ -11,6 +11,7 @@ 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.offerFulfillment.params.OfferFulfillmentsParams; @@ -87,6 +88,18 @@ public OfferFulfillmentsResponse offerFulfillments(OfferFulfillmentsParams param return OfferFulfillmentsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of offerFulfillments for offerFulfillment with params. */ + public CompletableFuture offerFulfillmentsAsync( + OfferFulfillmentsParams params) { + + return postJsonWithSubDomainAsync( + "/offer_fulfillments", + SubDomain.GROW.getValue(), + params != null ? params.toJsonString() : null) + .thenApply( + response -> OfferFulfillmentsResponse.fromJson(response.getBodyAsString(), response)); + } + /** offerFulfillmentsGet a offerFulfillment (executes immediately) - returns raw Response. */ Response offerFulfillmentsGetRaw(String offerFulfillmentId) throws ChargebeeException { String path = @@ -104,6 +117,21 @@ public OfferFulfillmentsGetResponse offerFulfillmentsGet(String offerFulfillment return OfferFulfillmentsGetResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of offerFulfillmentsGet for offerFulfillment without params. */ + public CompletableFuture offerFulfillmentsGetAsync( + String offerFulfillmentId) { + String path = + buildPathWithParams( + "/offer_fulfillments/{offer-fulfillment-id}", + "offer-fulfillment-id", + offerFulfillmentId); + + return getWithSubDomainAsync(path, SubDomain.GROW.getValue(), null) + .thenApply( + response -> + OfferFulfillmentsGetResponse.fromJson(response.getBodyAsString(), response)); + } + /** offerFulfillmentsUpdate a offerFulfillment (executes immediately) - returns raw Response. */ Response offerFulfillmentsUpdateRaw(String offerFulfillmentId) throws ChargebeeException { String path = @@ -149,4 +177,19 @@ public OfferFulfillmentsUpdateResponse offerFulfillmentsUpdate( Response response = offerFulfillmentsUpdateRaw(offerFulfillmentId, params); return OfferFulfillmentsUpdateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of offerFulfillmentsUpdate for offerFulfillment with params. */ + public CompletableFuture offerFulfillmentsUpdateAsync( + String offerFulfillmentId, OfferFulfillmentsUpdateParams params) { + String path = + buildPathWithParams( + "/offer_fulfillments/{offer-fulfillment-id}", + "offer-fulfillment-id", + offerFulfillmentId); + return postJsonWithSubDomainAsync( + path, SubDomain.GROW.getValue(), params != null ? params.toJsonString() : null) + .thenApply( + response -> + OfferFulfillmentsUpdateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/OmnichannelOneTimeOrderService.java b/src/main/java/com/chargebee/v4/services/OmnichannelOneTimeOrderService.java index cde68971..c7fef5af 100644 --- a/src/main/java/com/chargebee/v4/services/OmnichannelOneTimeOrderService.java +++ b/src/main/java/com/chargebee/v4/services/OmnichannelOneTimeOrderService.java @@ -11,6 +11,7 @@ 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.omnichannelOneTimeOrder.params.OmnichannelOneTimeOrderListParams; @@ -88,6 +89,17 @@ public OmnichannelOneTimeOrderListResponse list(OmnichannelOneTimeOrderListParam response.getBodyAsString(), this, params, response); } + /** Async variant of list for omnichannelOneTimeOrder with params. */ + public CompletableFuture listAsync( + OmnichannelOneTimeOrderListParams params) { + + return getAsync("/omnichannel_one_time_orders", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + OmnichannelOneTimeOrderListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public OmnichannelOneTimeOrderListResponse list() throws ChargebeeException { Response response = listRaw(); @@ -95,6 +107,16 @@ public OmnichannelOneTimeOrderListResponse list() throws ChargebeeException { response.getBodyAsString(), this, null, response); } + /** Async variant of list for omnichannelOneTimeOrder without params. */ + public CompletableFuture listAsync() { + + return getAsync("/omnichannel_one_time_orders", null) + .thenApply( + response -> + OmnichannelOneTimeOrderListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** retrieve a omnichannelOneTimeOrder (executes immediately) - returns raw Response. */ Response retrieveRaw(String omnichannelOneTimeOrderId) throws ChargebeeException { String path = @@ -111,4 +133,20 @@ public OmnichannelOneTimeOrderRetrieveResponse retrieve(String omnichannelOneTim Response response = retrieveRaw(omnichannelOneTimeOrderId); return OmnichannelOneTimeOrderRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for omnichannelOneTimeOrder without params. */ + public CompletableFuture retrieveAsync( + String omnichannelOneTimeOrderId) { + String path = + buildPathWithParams( + "/omnichannel_one_time_orders/{omnichannel-one-time-order-id}", + "omnichannel-one-time-order-id", + omnichannelOneTimeOrderId); + + return getAsync(path, null) + .thenApply( + response -> + OmnichannelOneTimeOrderRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/OmnichannelSubscriptionItemService.java b/src/main/java/com/chargebee/v4/services/OmnichannelSubscriptionItemService.java index 3b5d9929..2db0c4e7 100644 --- a/src/main/java/com/chargebee/v4/services/OmnichannelSubscriptionItemService.java +++ b/src/main/java/com/chargebee/v4/services/OmnichannelSubscriptionItemService.java @@ -11,6 +11,7 @@ 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.omnichannelSubscriptionItem.params.OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesParams; @@ -114,4 +115,52 @@ Response listOmniSubscriptionItemScheduleChangesRaw( return OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse.fromJson( response.getBodyAsString(), this, null, omnichannelSubscriptionItemId, response); } + + /** + * Async variant of listOmniSubscriptionItemScheduleChanges for omnichannelSubscriptionItem with + * params. + */ + public CompletableFuture< + OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse> + listOmniSubscriptionItemScheduleChangesAsync( + String omnichannelSubscriptionItemId, + OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesParams params) { + String path = + buildPathWithParams( + "/omnichannel_subscription_items/{omnichannel-subscription-item-id}/scheduled_changes", + "omnichannel-subscription-item-id", + omnichannelSubscriptionItemId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse.fromJson( + response.getBodyAsString(), + this, + params, + omnichannelSubscriptionItemId, + response)); + } + + /** + * Async variant of listOmniSubscriptionItemScheduleChanges for omnichannelSubscriptionItem + * without params. + */ + public CompletableFuture< + OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse> + listOmniSubscriptionItemScheduleChangesAsync(String omnichannelSubscriptionItemId) { + String path = + buildPathWithParams( + "/omnichannel_subscription_items/{omnichannel-subscription-item-id}/scheduled_changes", + "omnichannel-subscription-item-id", + omnichannelSubscriptionItemId); + return getAsync(path, null) + .thenApply( + response -> + OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse.fromJson( + response.getBodyAsString(), + this, + null, + omnichannelSubscriptionItemId, + response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/OmnichannelSubscriptionService.java b/src/main/java/com/chargebee/v4/services/OmnichannelSubscriptionService.java index 88dfba8c..37e63871 100644 --- a/src/main/java/com/chargebee/v4/services/OmnichannelSubscriptionService.java +++ b/src/main/java/com/chargebee/v4/services/OmnichannelSubscriptionService.java @@ -11,6 +11,7 @@ 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.omnichannelSubscription.params.OmnichannelSubscriptionMoveParams; @@ -107,6 +108,20 @@ public OmnichannelSubscriptionMoveResponse move( return OmnichannelSubscriptionMoveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of move for omnichannelSubscription with params. */ + public CompletableFuture moveAsync( + String omnichannelSubscriptionId, OmnichannelSubscriptionMoveParams params) { + String path = + buildPathWithParams( + "/omnichannel_subscriptions/{omnichannel-subscription-id}/move", + "omnichannel-subscription-id", + omnichannelSubscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + OmnichannelSubscriptionMoveResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a omnichannelSubscription (executes immediately) - returns raw Response. */ Response retrieveRaw(String omnichannelSubscriptionId) throws ChargebeeException { String path = @@ -124,6 +139,22 @@ public OmnichannelSubscriptionRetrieveResponse retrieve(String omnichannelSubscr return OmnichannelSubscriptionRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for omnichannelSubscription without params. */ + public CompletableFuture retrieveAsync( + String omnichannelSubscriptionId) { + String path = + buildPathWithParams( + "/omnichannel_subscriptions/{omnichannel-subscription-id}", + "omnichannel-subscription-id", + omnichannelSubscriptionId); + + return getAsync(path, null) + .thenApply( + response -> + OmnichannelSubscriptionRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * omnichannelTransactionsForOmnichannelSubscription a omnichannelSubscription using immutable * params (executes immediately) - returns raw Response. @@ -188,6 +219,44 @@ Response omnichannelTransactionsForOmnichannelSubscriptionRaw( response.getBodyAsString(), this, null, omnichannelSubscriptionId, response); } + /** + * Async variant of omnichannelTransactionsForOmnichannelSubscription for omnichannelSubscription + * with params. + */ + public CompletableFuture + omnichannelTransactionsForOmnichannelSubscriptionAsync( + String omnichannelSubscriptionId, + OmnichannelTransactionsForOmnichannelSubscriptionParams params) { + String path = + buildPathWithParams( + "/omnichannel_subscriptions/{omnichannel-subscription-id}/omnichannel_transactions", + "omnichannel-subscription-id", + omnichannelSubscriptionId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + OmnichannelTransactionsForOmnichannelSubscriptionResponse.fromJson( + response.getBodyAsString(), this, params, omnichannelSubscriptionId, response)); + } + + /** + * Async variant of omnichannelTransactionsForOmnichannelSubscription for omnichannelSubscription + * without params. + */ + public CompletableFuture + omnichannelTransactionsForOmnichannelSubscriptionAsync(String omnichannelSubscriptionId) { + String path = + buildPathWithParams( + "/omnichannel_subscriptions/{omnichannel-subscription-id}/omnichannel_transactions", + "omnichannel-subscription-id", + omnichannelSubscriptionId); + return getAsync(path, null) + .thenApply( + response -> + OmnichannelTransactionsForOmnichannelSubscriptionResponse.fromJson( + response.getBodyAsString(), this, null, omnichannelSubscriptionId, response)); + } + /** * list a omnichannelSubscription using immutable params (executes immediately) - returns raw * Response. @@ -222,10 +291,31 @@ public OmnichannelSubscriptionListResponse list(OmnichannelSubscriptionListParam response.getBodyAsString(), this, params, response); } + /** Async variant of list for omnichannelSubscription with params. */ + public CompletableFuture listAsync( + OmnichannelSubscriptionListParams params) { + + return getAsync("/omnichannel_subscriptions", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + OmnichannelSubscriptionListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public OmnichannelSubscriptionListResponse list() throws ChargebeeException { Response response = listRaw(); return OmnichannelSubscriptionListResponse.fromJson( response.getBodyAsString(), this, null, response); } + + /** Async variant of list for omnichannelSubscription without params. */ + public CompletableFuture listAsync() { + + return getAsync("/omnichannel_subscriptions", null) + .thenApply( + response -> + OmnichannelSubscriptionListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/OrderService.java b/src/main/java/com/chargebee/v4/services/OrderService.java index 4f78c1d7..8d16fe94 100644 --- a/src/main/java/com/chargebee/v4/services/OrderService.java +++ b/src/main/java/com/chargebee/v4/services/OrderService.java @@ -11,6 +11,7 @@ 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.order.params.OrderListParams; @@ -112,12 +113,30 @@ public OrderListResponse list(OrderListParams params) throws ChargebeeException return OrderListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for order with params. */ + public CompletableFuture listAsync(OrderListParams params) { + + return getAsync("/orders", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + OrderListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public OrderListResponse list() throws ChargebeeException { Response response = listRaw(); return OrderListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for order without params. */ + public CompletableFuture listAsync() { + + return getAsync("/orders", null) + .thenApply( + response -> + OrderListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a order using immutable params (executes immediately) - returns raw Response. */ Response createRaw(OrderCreateParams params) throws ChargebeeException { @@ -136,6 +155,13 @@ public OrderCreateResponse create(OrderCreateParams params) throws ChargebeeExce return OrderCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for order with params. */ + public CompletableFuture createAsync(OrderCreateParams params) { + + return postAsync("/orders", params != null ? params.toFormData() : null) + .thenApply(response -> OrderCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** importOrder a order using immutable params (executes immediately) - returns raw Response. */ Response importOrderRaw(ImportOrderParams params) throws ChargebeeException { @@ -154,6 +180,13 @@ public ImportOrderResponse importOrder(ImportOrderParams params) throws Chargebe return ImportOrderResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importOrder for order with params. */ + public CompletableFuture importOrderAsync(ImportOrderParams params) { + + return postAsync("/orders/import_order", params != null ? params.toFormData() : null) + .thenApply(response -> ImportOrderResponse.fromJson(response.getBodyAsString(), response)); + } + /** assignOrderNumber a order (executes immediately) - returns raw Response. */ Response assignOrderNumberRaw(String orderId) throws ChargebeeException { String path = @@ -167,6 +200,16 @@ public AssignOrderNumberResponse assignOrderNumber(String orderId) throws Charge return AssignOrderNumberResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of assignOrderNumber for order without params. */ + public CompletableFuture assignOrderNumberAsync(String orderId) { + String path = + buildPathWithParams("/orders/{order-id}/assign_order_number", "order-id", orderId); + + return postAsync(path, null) + .thenApply( + response -> AssignOrderNumberResponse.fromJson(response.getBodyAsString(), response)); + } + /** resend a order (executes immediately) - returns raw Response. */ Response resendRaw(String orderId) throws ChargebeeException { String path = buildPathWithParams("/orders/{order-id}/resend", "order-id", orderId); @@ -192,11 +235,27 @@ public OrderResendResponse resend(String orderId, OrderResendParams params) return OrderResendResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resend for order with params. */ + public CompletableFuture resendAsync( + String orderId, OrderResendParams params) { + String path = buildPathWithParams("/orders/{order-id}/resend", "order-id", orderId); + return postAsync(path, params.toFormData()) + .thenApply(response -> OrderResendResponse.fromJson(response.getBodyAsString(), response)); + } + public OrderResendResponse resend(String orderId) throws ChargebeeException { Response response = resendRaw(orderId); return OrderResendResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resend for order without params. */ + public CompletableFuture resendAsync(String orderId) { + String path = buildPathWithParams("/orders/{order-id}/resend", "order-id", orderId); + + return postAsync(path, null) + .thenApply(response -> OrderResendResponse.fromJson(response.getBodyAsString(), response)); + } + /** reopen a order (executes immediately) - returns raw Response. */ Response reopenRaw(String orderId) throws ChargebeeException { String path = buildPathWithParams("/orders/{order-id}/reopen", "order-id", orderId); @@ -222,11 +281,27 @@ public OrderReopenResponse reopen(String orderId, OrderReopenParams params) return OrderReopenResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of reopen for order with params. */ + public CompletableFuture reopenAsync( + String orderId, OrderReopenParams params) { + String path = buildPathWithParams("/orders/{order-id}/reopen", "order-id", orderId); + return postAsync(path, params.toFormData()) + .thenApply(response -> OrderReopenResponse.fromJson(response.getBodyAsString(), response)); + } + public OrderReopenResponse reopen(String orderId) throws ChargebeeException { Response response = reopenRaw(orderId); return OrderReopenResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of reopen for order without params. */ + public CompletableFuture reopenAsync(String orderId) { + String path = buildPathWithParams("/orders/{order-id}/reopen", "order-id", orderId); + + return postAsync(path, null) + .thenApply(response -> OrderReopenResponse.fromJson(response.getBodyAsString(), response)); + } + /** * ordersForInvoice a order using immutable params (executes immediately) - returns raw Response. */ @@ -263,6 +338,27 @@ public OrdersForInvoiceResponse ordersForInvoice(String invoiceId) throws Charge response.getBodyAsString(), this, null, invoiceId, response); } + /** Async variant of ordersForInvoice for order with params. */ + public CompletableFuture ordersForInvoiceAsync( + String invoiceId, OrdersForInvoiceParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}/orders", "invoice-id", invoiceId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + OrdersForInvoiceResponse.fromJson( + response.getBodyAsString(), this, params, invoiceId, response)); + } + + /** Async variant of ordersForInvoice for order without params. */ + public CompletableFuture ordersForInvoiceAsync(String invoiceId) { + String path = buildPathWithParams("/invoices/{invoice-id}/orders", "invoice-id", invoiceId); + return getAsync(path, null) + .thenApply( + response -> + OrdersForInvoiceResponse.fromJson( + response.getBodyAsString(), this, null, invoiceId, response)); + } + /** cancel a order (executes immediately) - returns raw Response. */ Response cancelRaw(String orderId) throws ChargebeeException { String path = buildPathWithParams("/orders/{order-id}/cancel", "order-id", orderId); @@ -288,6 +384,14 @@ public OrderCancelResponse cancel(String orderId, OrderCancelParams params) return OrderCancelResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of cancel for order with params. */ + public CompletableFuture cancelAsync( + String orderId, OrderCancelParams params) { + String path = buildPathWithParams("/orders/{order-id}/cancel", "order-id", orderId); + return postAsync(path, params.toFormData()) + .thenApply(response -> OrderCancelResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a order (executes immediately) - returns raw Response. */ Response retrieveRaw(String orderId) throws ChargebeeException { String path = buildPathWithParams("/orders/{order-id}", "order-id", orderId); @@ -300,6 +404,15 @@ public OrderRetrieveResponse retrieve(String orderId) throws ChargebeeException return OrderRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for order without params. */ + public CompletableFuture retrieveAsync(String orderId) { + String path = buildPathWithParams("/orders/{order-id}", "order-id", orderId); + + return getAsync(path, null) + .thenApply( + response -> OrderRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a order (executes immediately) - returns raw Response. */ Response updateRaw(String orderId) throws ChargebeeException { String path = buildPathWithParams("/orders/{order-id}", "order-id", orderId); @@ -325,11 +438,27 @@ public OrderUpdateResponse update(String orderId, OrderUpdateParams params) return OrderUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for order with params. */ + public CompletableFuture updateAsync( + String orderId, OrderUpdateParams params) { + String path = buildPathWithParams("/orders/{order-id}", "order-id", orderId); + return postAsync(path, params.toFormData()) + .thenApply(response -> OrderUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public OrderUpdateResponse update(String orderId) throws ChargebeeException { Response response = updateRaw(orderId); return OrderUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for order without params. */ + public CompletableFuture updateAsync(String orderId) { + String path = buildPathWithParams("/orders/{order-id}", "order-id", orderId); + + return postAsync(path, null) + .thenApply(response -> OrderUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a order (executes immediately) - returns raw Response. */ Response deleteRaw(String orderId) throws ChargebeeException { String path = buildPathWithParams("/orders/{order-id}/delete", "order-id", orderId); @@ -342,6 +471,14 @@ public OrderDeleteResponse delete(String orderId) throws ChargebeeException { return OrderDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for order without params. */ + public CompletableFuture deleteAsync(String orderId) { + String path = buildPathWithParams("/orders/{order-id}/delete", "order-id", orderId); + + return postAsync(path, null) + .thenApply(response -> OrderDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** createRefundableCreditNote a order (executes immediately) - returns raw Response. */ Response createRefundableCreditNoteRaw(String orderId) throws ChargebeeException { String path = @@ -381,9 +518,36 @@ public OrderCreateRefundableCreditNoteResponse createRefundableCreditNote( return OrderCreateRefundableCreditNoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createRefundableCreditNote for order with params. */ + public CompletableFuture createRefundableCreditNoteAsync( + String orderId, OrderCreateRefundableCreditNoteParams params) { + String path = + buildPathWithParams( + "/orders/{order-id}/create_refundable_credit_note", "order-id", orderId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + OrderCreateRefundableCreditNoteResponse.fromJson( + response.getBodyAsString(), response)); + } + public OrderCreateRefundableCreditNoteResponse createRefundableCreditNote(String orderId) throws ChargebeeException { Response response = createRefundableCreditNoteRaw(orderId); return OrderCreateRefundableCreditNoteResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of createRefundableCreditNote for order without params. */ + public CompletableFuture createRefundableCreditNoteAsync( + String orderId) { + String path = + buildPathWithParams( + "/orders/{order-id}/create_refundable_credit_note", "order-id", orderId); + + return postAsync(path, null) + .thenApply( + response -> + OrderCreateRefundableCreditNoteResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PaymentIntentService.java b/src/main/java/com/chargebee/v4/services/PaymentIntentService.java index c905fc4e..6f753e29 100644 --- a/src/main/java/com/chargebee/v4/services/PaymentIntentService.java +++ b/src/main/java/com/chargebee/v4/services/PaymentIntentService.java @@ -11,6 +11,7 @@ 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.paymentIntent.params.PaymentIntentUpdateParams; @@ -71,6 +72,18 @@ public PaymentIntentRetrieveResponse retrieve(String paymentIntentId) throws Cha return PaymentIntentRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for paymentIntent without params. */ + public CompletableFuture retrieveAsync(String paymentIntentId) { + String path = + buildPathWithParams( + "/payment_intents/{payment-intent-id}", "payment-intent-id", paymentIntentId); + + return getAsync(path, null) + .thenApply( + response -> + PaymentIntentRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a paymentIntent (executes immediately) - returns raw Response. */ Response updateRaw(String paymentIntentId) throws ChargebeeException { String path = @@ -107,11 +120,33 @@ public PaymentIntentUpdateResponse update( return PaymentIntentUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for paymentIntent with params. */ + public CompletableFuture updateAsync( + String paymentIntentId, PaymentIntentUpdateParams params) { + String path = + buildPathWithParams( + "/payment_intents/{payment-intent-id}", "payment-intent-id", paymentIntentId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> PaymentIntentUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public PaymentIntentUpdateResponse update(String paymentIntentId) throws ChargebeeException { Response response = updateRaw(paymentIntentId); return PaymentIntentUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for paymentIntent without params. */ + public CompletableFuture updateAsync(String paymentIntentId) { + String path = + buildPathWithParams( + "/payment_intents/{payment-intent-id}", "payment-intent-id", paymentIntentId); + + return postAsync(path, null) + .thenApply( + response -> PaymentIntentUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * create a paymentIntent using immutable params (executes immediately) - returns raw Response. */ @@ -134,4 +169,13 @@ public PaymentIntentCreateResponse create(PaymentIntentCreateParams params) return PaymentIntentCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for paymentIntent with params. */ + public CompletableFuture createAsync( + PaymentIntentCreateParams params) { + + return postAsync("/payment_intents", params != null ? params.toFormData() : null) + .thenApply( + response -> PaymentIntentCreateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PaymentScheduleSchemeService.java b/src/main/java/com/chargebee/v4/services/PaymentScheduleSchemeService.java index a69eea11..72908e1f 100644 --- a/src/main/java/com/chargebee/v4/services/PaymentScheduleSchemeService.java +++ b/src/main/java/com/chargebee/v4/services/PaymentScheduleSchemeService.java @@ -11,6 +11,7 @@ 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.paymentScheduleScheme.params.PaymentScheduleSchemeCreateParams; @@ -72,6 +73,22 @@ public PaymentScheduleSchemeRetrieveResponse retrieve(String paymentScheduleSche return PaymentScheduleSchemeRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for paymentScheduleScheme without params. */ + public CompletableFuture retrieveAsync( + String paymentScheduleSchemeId) { + String path = + buildPathWithParams( + "/payment_schedule_schemes/{payment-schedule-scheme-id}", + "payment-schedule-scheme-id", + paymentScheduleSchemeId); + + return getAsync(path, null) + .thenApply( + response -> + PaymentScheduleSchemeRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * create a paymentScheduleScheme using immutable params (executes immediately) - returns raw * Response. @@ -97,6 +114,16 @@ public PaymentScheduleSchemeCreateResponse create(PaymentScheduleSchemeCreatePar return PaymentScheduleSchemeCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for paymentScheduleScheme with params. */ + public CompletableFuture createAsync( + PaymentScheduleSchemeCreateParams params) { + + return postAsync("/payment_schedule_schemes", params != null ? params.toFormData() : null) + .thenApply( + response -> + PaymentScheduleSchemeCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a paymentScheduleScheme (executes immediately) - returns raw Response. */ Response deleteRaw(String paymentScheduleSchemeId) throws ChargebeeException { String path = @@ -113,4 +140,19 @@ public PaymentScheduleSchemeDeleteResponse delete(String paymentScheduleSchemeId Response response = deleteRaw(paymentScheduleSchemeId); return PaymentScheduleSchemeDeleteResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of delete for paymentScheduleScheme without params. */ + public CompletableFuture deleteAsync( + String paymentScheduleSchemeId) { + String path = + buildPathWithParams( + "/payment_schedule_schemes/{payment-schedule-scheme-id}/delete", + "payment-schedule-scheme-id", + paymentScheduleSchemeId); + + return postAsync(path, null) + .thenApply( + response -> + PaymentScheduleSchemeDeleteResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PaymentSourceService.java b/src/main/java/com/chargebee/v4/services/PaymentSourceService.java index 2da648e0..d131a3f4 100644 --- a/src/main/java/com/chargebee/v4/services/PaymentSourceService.java +++ b/src/main/java/com/chargebee/v4/services/PaymentSourceService.java @@ -11,6 +11,7 @@ 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.paymentSource.params.PaymentSourceCreateUsingPermanentTokenParams; @@ -136,6 +137,19 @@ public PaymentSourceCreateUsingPermanentTokenResponse createUsingPermanentToken( response.getBodyAsString(), response); } + /** Async variant of createUsingPermanentToken for paymentSource with params. */ + public CompletableFuture + createUsingPermanentTokenAsync(PaymentSourceCreateUsingPermanentTokenParams params) { + + return postAsync( + "/payment_sources/create_using_permanent_token", + params != null ? params.toFormData() : null) + .thenApply( + response -> + PaymentSourceCreateUsingPermanentTokenResponse.fromJson( + response.getBodyAsString(), response)); + } + /** delete a paymentSource (executes immediately) - returns raw Response. */ Response deleteRaw(String custPaymentSourceId) throws ChargebeeException { String path = @@ -152,6 +166,19 @@ public PaymentSourceDeleteResponse delete(String custPaymentSourceId) throws Cha return PaymentSourceDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for paymentSource without params. */ + public CompletableFuture deleteAsync(String custPaymentSourceId) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/delete", + "cust-payment-source-id", + custPaymentSourceId); + + return postAsync(path, null) + .thenApply( + response -> PaymentSourceDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createCard a paymentSource using immutable params (executes immediately) - returns raw * Response. @@ -177,6 +204,16 @@ public PaymentSourceCreateCardResponse createCard(PaymentSourceCreateCardParams return PaymentSourceCreateCardResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createCard for paymentSource with params. */ + public CompletableFuture createCardAsync( + PaymentSourceCreateCardParams params) { + + return postAsync("/payment_sources/create_card", params != null ? params.toFormData() : null) + .thenApply( + response -> + PaymentSourceCreateCardResponse.fromJson(response.getBodyAsString(), response)); + } + /** verifyBankAccount a paymentSource (executes immediately) - returns raw Response. */ Response verifyBankAccountRaw(String custPaymentSourceId) throws ChargebeeException { String path = @@ -224,6 +261,21 @@ public PaymentSourceVerifyBankAccountResponse verifyBankAccount( return PaymentSourceVerifyBankAccountResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of verifyBankAccount for paymentSource with params. */ + public CompletableFuture verifyBankAccountAsync( + String custPaymentSourceId, PaymentSourceVerifyBankAccountParams params) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/verify_bank_account", + "cust-payment-source-id", + custPaymentSourceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + PaymentSourceVerifyBankAccountResponse.fromJson( + response.getBodyAsString(), response)); + } + /** list a paymentSource using immutable params (executes immediately) - returns raw Response. */ Response listRaw(PaymentSourceListParams params) throws ChargebeeException { @@ -248,12 +300,32 @@ public PaymentSourceListResponse list(PaymentSourceListParams params) throws Cha return PaymentSourceListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for paymentSource with params. */ + public CompletableFuture listAsync(PaymentSourceListParams params) { + + return getAsync("/payment_sources", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + PaymentSourceListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public PaymentSourceListResponse list() throws ChargebeeException { Response response = listRaw(); return PaymentSourceListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for paymentSource without params. */ + public CompletableFuture listAsync() { + + return getAsync("/payment_sources", null) + .thenApply( + response -> + PaymentSourceListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** exportPaymentSource a paymentSource (executes immediately) - returns raw Response. */ Response exportPaymentSourceRaw(String custPaymentSourceId) throws ChargebeeException { String path = @@ -299,6 +371,19 @@ public ExportPaymentSourceResponse exportPaymentSource( return ExportPaymentSourceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of exportPaymentSource for paymentSource with params. */ + public CompletableFuture exportPaymentSourceAsync( + String custPaymentSourceId, ExportPaymentSourceParams params) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/export_payment_source", + "cust-payment-source-id", + custPaymentSourceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> ExportPaymentSourceResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createUsingPaymentIntent a paymentSource using immutable params (executes immediately) - * returns raw Response. @@ -328,6 +413,19 @@ public PaymentSourceCreateUsingPaymentIntentResponse createUsingPaymentIntent( response.getBodyAsString(), response); } + /** Async variant of createUsingPaymentIntent for paymentSource with params. */ + public CompletableFuture + createUsingPaymentIntentAsync(PaymentSourceCreateUsingPaymentIntentParams params) { + + return postAsync( + "/payment_sources/create_using_payment_intent", + params != null ? params.toFormData() : null) + .thenApply( + response -> + PaymentSourceCreateUsingPaymentIntentResponse.fromJson( + response.getBodyAsString(), response)); + } + /** agreementPdf a paymentSource (executes immediately) - returns raw Response. */ Response agreementPdfRaw(String custPaymentSourceId) throws ChargebeeException { String path = @@ -345,6 +443,21 @@ public PaymentSourceAgreementPdfResponse agreementPdf(String custPaymentSourceId return PaymentSourceAgreementPdfResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of agreementPdf for paymentSource without params. */ + public CompletableFuture agreementPdfAsync( + String custPaymentSourceId) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/agreement_pdf", + "cust-payment-source-id", + custPaymentSourceId); + + return postAsync(path, null) + .thenApply( + response -> + PaymentSourceAgreementPdfResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a paymentSource (executes immediately) - returns raw Response. */ Response retrieveRaw(String custPaymentSourceId) throws ChargebeeException { String path = @@ -362,6 +475,21 @@ public PaymentSourceRetrieveResponse retrieve(String custPaymentSourceId) return PaymentSourceRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for paymentSource without params. */ + public CompletableFuture retrieveAsync( + String custPaymentSourceId) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}", + "cust-payment-source-id", + custPaymentSourceId); + + return getAsync(path, null) + .thenApply( + response -> + PaymentSourceRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createVoucherPaymentSource a paymentSource using immutable params (executes immediately) - * returns raw Response. @@ -390,6 +518,18 @@ public CreateVoucherPaymentSourceResponse createVoucherPaymentSource( return CreateVoucherPaymentSourceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createVoucherPaymentSource for paymentSource with params. */ + public CompletableFuture createVoucherPaymentSourceAsync( + CreateVoucherPaymentSourceParams params) { + + return postAsync( + "/payment_sources/create_voucher_payment_source", + params != null ? params.toFormData() : null) + .thenApply( + response -> + CreateVoucherPaymentSourceResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createUsingTempToken a paymentSource using immutable params (executes immediately) - returns * raw Response. @@ -417,6 +557,18 @@ public PaymentSourceCreateUsingTempTokenResponse createUsingTempToken( return PaymentSourceCreateUsingTempTokenResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createUsingTempToken for paymentSource with params. */ + public CompletableFuture createUsingTempTokenAsync( + PaymentSourceCreateUsingTempTokenParams params) { + + return postAsync( + "/payment_sources/create_using_temp_token", params != null ? params.toFormData() : null) + .thenApply( + response -> + PaymentSourceCreateUsingTempTokenResponse.fromJson( + response.getBodyAsString(), response)); + } + /** updateCard a paymentSource (executes immediately) - returns raw Response. */ Response updateCardRaw(String custPaymentSourceId) throws ChargebeeException { String path = @@ -461,12 +613,41 @@ public PaymentSourceUpdateCardResponse updateCard( return PaymentSourceUpdateCardResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateCard for paymentSource with params. */ + public CompletableFuture updateCardAsync( + String custPaymentSourceId, PaymentSourceUpdateCardParams params) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/update_card", + "cust-payment-source-id", + custPaymentSourceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + PaymentSourceUpdateCardResponse.fromJson(response.getBodyAsString(), response)); + } + public PaymentSourceUpdateCardResponse updateCard(String custPaymentSourceId) throws ChargebeeException { Response response = updateCardRaw(custPaymentSourceId); return PaymentSourceUpdateCardResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateCard for paymentSource without params. */ + public CompletableFuture updateCardAsync( + String custPaymentSourceId) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/update_card", + "cust-payment-source-id", + custPaymentSourceId); + + return postAsync(path, null) + .thenApply( + response -> + PaymentSourceUpdateCardResponse.fromJson(response.getBodyAsString(), response)); + } + /** switchGatewayAccount a paymentSource (executes immediately) - returns raw Response. */ Response switchGatewayAccountRaw(String custPaymentSourceId) throws ChargebeeException { String path = @@ -514,6 +695,21 @@ public PaymentSourceSwitchGatewayAccountResponse switchGatewayAccount( return PaymentSourceSwitchGatewayAccountResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of switchGatewayAccount for paymentSource with params. */ + public CompletableFuture switchGatewayAccountAsync( + String custPaymentSourceId, PaymentSourceSwitchGatewayAccountParams params) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/switch_gateway_account", + "cust-payment-source-id", + custPaymentSourceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + PaymentSourceSwitchGatewayAccountResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * createUsingToken a paymentSource using immutable params (executes immediately) - returns raw * Response. @@ -540,6 +736,18 @@ public PaymentSourceCreateUsingTokenResponse createUsingToken( return PaymentSourceCreateUsingTokenResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createUsingToken for paymentSource with params. */ + public CompletableFuture createUsingTokenAsync( + PaymentSourceCreateUsingTokenParams params) { + + return postAsync( + "/payment_sources/create_using_token", params != null ? params.toFormData() : null) + .thenApply( + response -> + PaymentSourceCreateUsingTokenResponse.fromJson( + response.getBodyAsString(), response)); + } + /** deleteLocal a paymentSource (executes immediately) - returns raw Response. */ Response deleteLocalRaw(String custPaymentSourceId) throws ChargebeeException { String path = @@ -557,6 +765,21 @@ public PaymentSourceDeleteLocalResponse deleteLocal(String custPaymentSourceId) return PaymentSourceDeleteLocalResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteLocal for paymentSource without params. */ + public CompletableFuture deleteLocalAsync( + String custPaymentSourceId) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/delete_local", + "cust-payment-source-id", + custPaymentSourceId); + + return postAsync(path, null) + .thenApply( + response -> + PaymentSourceDeleteLocalResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createBankAccount a paymentSource using immutable params (executes immediately) - returns raw * Response. @@ -584,6 +807,18 @@ public PaymentSourceCreateBankAccountResponse createBankAccount( return PaymentSourceCreateBankAccountResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createBankAccount for paymentSource with params. */ + public CompletableFuture createBankAccountAsync( + PaymentSourceCreateBankAccountParams params) { + + return postAsync( + "/payment_sources/create_bank_account", params != null ? params.toFormData() : null) + .thenApply( + response -> + PaymentSourceCreateBankAccountResponse.fromJson( + response.getBodyAsString(), response)); + } + /** updateBankAccount a paymentSource (executes immediately) - returns raw Response. */ Response updateBankAccountRaw(String custPaymentSourceId) throws ChargebeeException { String path = @@ -631,9 +866,40 @@ public PaymentSourceUpdateBankAccountResponse updateBankAccount( return PaymentSourceUpdateBankAccountResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateBankAccount for paymentSource with params. */ + public CompletableFuture updateBankAccountAsync( + String custPaymentSourceId, PaymentSourceUpdateBankAccountParams params) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/update_bank_account", + "cust-payment-source-id", + custPaymentSourceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + PaymentSourceUpdateBankAccountResponse.fromJson( + response.getBodyAsString(), response)); + } + public PaymentSourceUpdateBankAccountResponse updateBankAccount(String custPaymentSourceId) throws ChargebeeException { Response response = updateBankAccountRaw(custPaymentSourceId); return PaymentSourceUpdateBankAccountResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of updateBankAccount for paymentSource without params. */ + public CompletableFuture updateBankAccountAsync( + String custPaymentSourceId) { + String path = + buildPathWithParams( + "/payment_sources/{cust-payment-source-id}/update_bank_account", + "cust-payment-source-id", + custPaymentSourceId); + + return postAsync(path, null) + .thenApply( + response -> + PaymentSourceUpdateBankAccountResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PaymentVoucherService.java b/src/main/java/com/chargebee/v4/services/PaymentVoucherService.java index 066c3287..eeb9e764 100644 --- a/src/main/java/com/chargebee/v4/services/PaymentVoucherService.java +++ b/src/main/java/com/chargebee/v4/services/PaymentVoucherService.java @@ -11,6 +11,7 @@ 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.paymentVoucher.params.PaymentVouchersForCustomerParams; @@ -107,6 +108,30 @@ public PaymentVouchersForCustomerResponse paymentVouchersForCustomer(String cust response.getBodyAsString(), this, null, customerId, response); } + /** Async variant of paymentVouchersForCustomer for paymentVoucher with params. */ + public CompletableFuture paymentVouchersForCustomerAsync( + String customerId, PaymentVouchersForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/payment_vouchers", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + PaymentVouchersForCustomerResponse.fromJson( + response.getBodyAsString(), this, params, customerId, response)); + } + + /** Async variant of paymentVouchersForCustomer for paymentVoucher without params. */ + public CompletableFuture paymentVouchersForCustomerAsync( + String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/payment_vouchers", "customer-id", customerId); + return getAsync(path, null) + .thenApply( + response -> + PaymentVouchersForCustomerResponse.fromJson( + response.getBodyAsString(), this, null, customerId, response)); + } + /** * paymentVouchersForInvoice a paymentVoucher using immutable params (executes immediately) - * returns raw Response. @@ -153,6 +178,30 @@ public PaymentVouchersForInvoiceResponse paymentVouchersForInvoice(String invoic response.getBodyAsString(), this, null, invoiceId, response); } + /** Async variant of paymentVouchersForInvoice for paymentVoucher with params. */ + public CompletableFuture paymentVouchersForInvoiceAsync( + String invoiceId, PaymentVouchersForInvoiceParams params) { + String path = + buildPathWithParams("/invoices/{invoice-id}/payment_vouchers", "invoice-id", invoiceId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + PaymentVouchersForInvoiceResponse.fromJson( + response.getBodyAsString(), this, params, invoiceId, response)); + } + + /** Async variant of paymentVouchersForInvoice for paymentVoucher without params. */ + public CompletableFuture paymentVouchersForInvoiceAsync( + String invoiceId) { + String path = + buildPathWithParams("/invoices/{invoice-id}/payment_vouchers", "invoice-id", invoiceId); + return getAsync(path, null) + .thenApply( + response -> + PaymentVouchersForInvoiceResponse.fromJson( + response.getBodyAsString(), this, null, invoiceId, response)); + } + /** retrieve a paymentVoucher (executes immediately) - returns raw Response. */ Response retrieveRaw(String paymentVoucherId) throws ChargebeeException { String path = @@ -168,6 +217,18 @@ public PaymentVoucherRetrieveResponse retrieve(String paymentVoucherId) return PaymentVoucherRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for paymentVoucher without params. */ + public CompletableFuture retrieveAsync(String paymentVoucherId) { + String path = + buildPathWithParams( + "/payment_vouchers/{payment-voucher-id}", "payment-voucher-id", paymentVoucherId); + + return getAsync(path, null) + .thenApply( + response -> + PaymentVoucherRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * create a paymentVoucher using immutable params (executes immediately) - returns raw Response. */ @@ -190,4 +251,14 @@ public PaymentVoucherCreateResponse create(PaymentVoucherCreateParams params) return PaymentVoucherCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for paymentVoucher with params. */ + public CompletableFuture createAsync( + PaymentVoucherCreateParams params) { + + return postAsync("/payment_vouchers", params != null ? params.toFormData() : null) + .thenApply( + response -> + PaymentVoucherCreateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/Pc2MigrationItemFamilyService.java b/src/main/java/com/chargebee/v4/services/Pc2MigrationItemFamilyService.java index e083de2f..b6def44f 100644 --- a/src/main/java/com/chargebee/v4/services/Pc2MigrationItemFamilyService.java +++ b/src/main/java/com/chargebee/v4/services/Pc2MigrationItemFamilyService.java @@ -11,6 +11,7 @@ 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.pc2MigrationItemFamily.params.Pc2MigrationItemFamilyUpdateParams; @@ -81,6 +82,22 @@ public Pc2MigrationItemFamilyDeleteResponse delete(String pc2MigrationItemFamily return Pc2MigrationItemFamilyDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for pc2MigrationItemFamily without params. */ + public CompletableFuture deleteAsync( + String pc2MigrationItemFamilyId) { + String path = + buildPathWithParams( + "/pc2_migration_item_families/{pc2-migration-item-family-id}/delete", + "pc2-migration-item-family-id", + pc2MigrationItemFamilyId); + + return postAsync(path, null) + .thenApply( + response -> + Pc2MigrationItemFamilyDeleteResponse.fromJson( + response.getBodyAsString(), response)); + } + /** retrieve a pc2MigrationItemFamily (executes immediately) - returns raw Response. */ Response retrieveRaw(String pc2MigrationItemFamilyId) throws ChargebeeException { String path = @@ -98,6 +115,22 @@ public Pc2MigrationItemFamilyRetrieveResponse retrieve(String pc2MigrationItemFa return Pc2MigrationItemFamilyRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for pc2MigrationItemFamily without params. */ + public CompletableFuture retrieveAsync( + String pc2MigrationItemFamilyId) { + String path = + buildPathWithParams( + "/pc2_migration_item_families/{pc2-migration-item-family-id}", + "pc2-migration-item-family-id", + pc2MigrationItemFamilyId); + + return getAsync(path, null) + .thenApply( + response -> + Pc2MigrationItemFamilyRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } + /** update a pc2MigrationItemFamily (executes immediately) - returns raw Response. */ Response updateRaw(String pc2MigrationItemFamilyId) throws ChargebeeException { String path = @@ -144,12 +177,43 @@ public Pc2MigrationItemFamilyUpdateResponse update( return Pc2MigrationItemFamilyUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for pc2MigrationItemFamily with params. */ + public CompletableFuture updateAsync( + String pc2MigrationItemFamilyId, Pc2MigrationItemFamilyUpdateParams params) { + String path = + buildPathWithParams( + "/pc2_migration_item_families/{pc2-migration-item-family-id}", + "pc2-migration-item-family-id", + pc2MigrationItemFamilyId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + Pc2MigrationItemFamilyUpdateResponse.fromJson( + response.getBodyAsString(), response)); + } + public Pc2MigrationItemFamilyUpdateResponse update(String pc2MigrationItemFamilyId) throws ChargebeeException { Response response = updateRaw(pc2MigrationItemFamilyId); return Pc2MigrationItemFamilyUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for pc2MigrationItemFamily without params. */ + public CompletableFuture updateAsync( + String pc2MigrationItemFamilyId) { + String path = + buildPathWithParams( + "/pc2_migration_item_families/{pc2-migration-item-family-id}", + "pc2-migration-item-family-id", + pc2MigrationItemFamilyId); + + return postAsync(path, null) + .thenApply( + response -> + Pc2MigrationItemFamilyUpdateResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * list a pc2MigrationItemFamily using immutable params (executes immediately) - returns raw * Response. @@ -182,6 +246,17 @@ public Pc2MigrationItemFamilyListResponse list(Pc2MigrationItemFamilyListParams response.getBodyAsString(), this, params, response); } + /** Async variant of list for pc2MigrationItemFamily with params. */ + public CompletableFuture listAsync( + Pc2MigrationItemFamilyListParams params) { + + return getAsync("/pc2_migration_item_families", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + Pc2MigrationItemFamilyListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public Pc2MigrationItemFamilyListResponse list() throws ChargebeeException { Response response = listRaw(); @@ -189,6 +264,16 @@ public Pc2MigrationItemFamilyListResponse list() throws ChargebeeException { response.getBodyAsString(), this, null, response); } + /** Async variant of list for pc2MigrationItemFamily without params. */ + public CompletableFuture listAsync() { + + return getAsync("/pc2_migration_item_families", null) + .thenApply( + response -> + Pc2MigrationItemFamilyListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** * create a pc2MigrationItemFamily using immutable params (executes immediately) - returns raw * Response. @@ -213,4 +298,15 @@ public Pc2MigrationItemFamilyCreateResponse create(Pc2MigrationItemFamilyCreateP return Pc2MigrationItemFamilyCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for pc2MigrationItemFamily with params. */ + public CompletableFuture createAsync( + Pc2MigrationItemFamilyCreateParams params) { + + return postAsync("/pc2_migration_item_families", params != null ? params.toFormData() : null) + .thenApply( + response -> + Pc2MigrationItemFamilyCreateResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/Pc2MigrationItemPriceService.java b/src/main/java/com/chargebee/v4/services/Pc2MigrationItemPriceService.java index 570d6ac4..6e1e3a7f 100644 --- a/src/main/java/com/chargebee/v4/services/Pc2MigrationItemPriceService.java +++ b/src/main/java/com/chargebee/v4/services/Pc2MigrationItemPriceService.java @@ -11,6 +11,7 @@ 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.pc2MigrationItemPrice.params.Pc2MigrationItemPriceListParams; @@ -91,6 +92,17 @@ public Pc2MigrationItemPriceListResponse list(Pc2MigrationItemPriceListParams pa response.getBodyAsString(), this, params, response); } + /** Async variant of list for pc2MigrationItemPrice with params. */ + public CompletableFuture listAsync( + Pc2MigrationItemPriceListParams params) { + + return getAsync("/pc2_migration_item_prices", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + Pc2MigrationItemPriceListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public Pc2MigrationItemPriceListResponse list() throws ChargebeeException { Response response = listRaw(); @@ -98,6 +110,16 @@ public Pc2MigrationItemPriceListResponse list() throws ChargebeeException { response.getBodyAsString(), this, null, response); } + /** Async variant of list for pc2MigrationItemPrice without params. */ + public CompletableFuture listAsync() { + + return getAsync("/pc2_migration_item_prices", null) + .thenApply( + response -> + Pc2MigrationItemPriceListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** delete a pc2MigrationItemPrice (executes immediately) - returns raw Response. */ Response deleteRaw(String pc2MigrationItemPriceId) throws ChargebeeException { String path = @@ -115,6 +137,21 @@ public Pc2MigrationItemPriceDeleteResponse delete(String pc2MigrationItemPriceId return Pc2MigrationItemPriceDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for pc2MigrationItemPrice without params. */ + public CompletableFuture deleteAsync( + String pc2MigrationItemPriceId) { + String path = + buildPathWithParams( + "/pc2_migration_item_prices/{pc2-migration-item-price-id}/delete", + "pc2-migration-item-price-id", + pc2MigrationItemPriceId); + + return postAsync(path, null) + .thenApply( + response -> + Pc2MigrationItemPriceDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a pc2MigrationItemPrice (executes immediately) - returns raw Response. */ Response retrieveRaw(String pc2MigrationItemPriceId) throws ChargebeeException { String path = @@ -132,6 +169,22 @@ public Pc2MigrationItemPriceRetrieveResponse retrieve(String pc2MigrationItemPri return Pc2MigrationItemPriceRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for pc2MigrationItemPrice without params. */ + public CompletableFuture retrieveAsync( + String pc2MigrationItemPriceId) { + String path = + buildPathWithParams( + "/pc2_migration_item_prices/{pc2-migration-item-price-id}", + "pc2-migration-item-price-id", + pc2MigrationItemPriceId); + + return getAsync(path, null) + .thenApply( + response -> + Pc2MigrationItemPriceRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } + /** update a pc2MigrationItemPrice (executes immediately) - returns raw Response. */ Response updateRaw(String pc2MigrationItemPriceId) throws ChargebeeException { String path = @@ -177,9 +230,38 @@ public Pc2MigrationItemPriceUpdateResponse update( return Pc2MigrationItemPriceUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for pc2MigrationItemPrice with params. */ + public CompletableFuture updateAsync( + String pc2MigrationItemPriceId, Pc2MigrationItemPriceUpdateParams params) { + String path = + buildPathWithParams( + "/pc2_migration_item_prices/{pc2-migration-item-price-id}", + "pc2-migration-item-price-id", + pc2MigrationItemPriceId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + Pc2MigrationItemPriceUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public Pc2MigrationItemPriceUpdateResponse update(String pc2MigrationItemPriceId) throws ChargebeeException { Response response = updateRaw(pc2MigrationItemPriceId); return Pc2MigrationItemPriceUpdateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of update for pc2MigrationItemPrice without params. */ + public CompletableFuture updateAsync( + String pc2MigrationItemPriceId) { + String path = + buildPathWithParams( + "/pc2_migration_item_prices/{pc2-migration-item-price-id}", + "pc2-migration-item-price-id", + pc2MigrationItemPriceId); + + return postAsync(path, null) + .thenApply( + response -> + Pc2MigrationItemPriceUpdateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/Pc2MigrationItemService.java b/src/main/java/com/chargebee/v4/services/Pc2MigrationItemService.java index f4af870b..940a08b5 100644 --- a/src/main/java/com/chargebee/v4/services/Pc2MigrationItemService.java +++ b/src/main/java/com/chargebee/v4/services/Pc2MigrationItemService.java @@ -11,6 +11,7 @@ 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.pc2MigrationItem.params.Pc2MigrationItemUpdateParams; @@ -84,6 +85,21 @@ public Pc2MigrationItemRetrieveResponse retrieve(String pc2MigrationItemId) return Pc2MigrationItemRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for pc2MigrationItem without params. */ + public CompletableFuture retrieveAsync( + String pc2MigrationItemId) { + String path = + buildPathWithParams( + "/pc2_migration_items/{pc2-migration-item-id}", + "pc2-migration-item-id", + pc2MigrationItemId); + + return getAsync(path, null) + .thenApply( + response -> + Pc2MigrationItemRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a pc2MigrationItem (executes immediately) - returns raw Response. */ Response updateRaw(String pc2MigrationItemId) throws ChargebeeException { String path = @@ -126,12 +142,40 @@ public Pc2MigrationItemUpdateResponse update( return Pc2MigrationItemUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for pc2MigrationItem with params. */ + public CompletableFuture updateAsync( + String pc2MigrationItemId, Pc2MigrationItemUpdateParams params) { + String path = + buildPathWithParams( + "/pc2_migration_items/{pc2-migration-item-id}", + "pc2-migration-item-id", + pc2MigrationItemId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + Pc2MigrationItemUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public Pc2MigrationItemUpdateResponse update(String pc2MigrationItemId) throws ChargebeeException { Response response = updateRaw(pc2MigrationItemId); return Pc2MigrationItemUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for pc2MigrationItem without params. */ + public CompletableFuture updateAsync(String pc2MigrationItemId) { + String path = + buildPathWithParams( + "/pc2_migration_items/{pc2-migration-item-id}", + "pc2-migration-item-id", + pc2MigrationItemId); + + return postAsync(path, null) + .thenApply( + response -> + Pc2MigrationItemUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a pc2MigrationItem (executes immediately) - returns raw Response. */ Response deleteRaw(String pc2MigrationItemId) throws ChargebeeException { String path = @@ -149,6 +193,20 @@ public Pc2MigrationItemDeleteResponse delete(String pc2MigrationItemId) return Pc2MigrationItemDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for pc2MigrationItem without params. */ + public CompletableFuture deleteAsync(String pc2MigrationItemId) { + String path = + buildPathWithParams( + "/pc2_migration_items/{pc2-migration-item-id}/delete", + "pc2-migration-item-id", + pc2MigrationItemId); + + return postAsync(path, null) + .thenApply( + response -> + Pc2MigrationItemDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * list a pc2MigrationItem using immutable params (executes immediately) - returns raw Response. */ @@ -179,12 +237,33 @@ public Pc2MigrationItemListResponse list(Pc2MigrationItemListParams params) response.getBodyAsString(), this, params, response); } + /** Async variant of list for pc2MigrationItem with params. */ + public CompletableFuture listAsync( + Pc2MigrationItemListParams params) { + + return getAsync("/pc2_migration_items", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + Pc2MigrationItemListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public Pc2MigrationItemListResponse list() throws ChargebeeException { Response response = listRaw(); return Pc2MigrationItemListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for pc2MigrationItem without params. */ + public CompletableFuture listAsync() { + + return getAsync("/pc2_migration_items", null) + .thenApply( + response -> + Pc2MigrationItemListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** * create a pc2MigrationItem using immutable params (executes immediately) - returns raw Response. */ @@ -208,6 +287,16 @@ public Pc2MigrationItemCreateResponse create(Pc2MigrationItemCreateParams params return Pc2MigrationItemCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for pc2MigrationItem with params. */ + public CompletableFuture createAsync( + Pc2MigrationItemCreateParams params) { + + return postAsync("/pc2_migration_items", params != null ? params.toFormData() : null) + .thenApply( + response -> + Pc2MigrationItemCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * listApplicableAddons a pc2MigrationItem using immutable params (executes immediately) - returns * raw Response. @@ -245,6 +334,18 @@ public Pc2MigrationItemListApplicableAddonsResponse listApplicableAddons( response.getBodyAsString(), this, params, response); } + /** Async variant of listApplicableAddons for pc2MigrationItem with params. */ + public CompletableFuture listApplicableAddonsAsync( + Pc2MigrationItemListApplicableAddonsParams params) { + + return getAsync( + "/pc2_migration_items/applicable_items", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + Pc2MigrationItemListApplicableAddonsResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public Pc2MigrationItemListApplicableAddonsResponse listApplicableAddons() throws ChargebeeException { Response response = listApplicableAddonsRaw(); @@ -252,4 +353,15 @@ public Pc2MigrationItemListApplicableAddonsResponse listApplicableAddons() return Pc2MigrationItemListApplicableAddonsResponse.fromJson( response.getBodyAsString(), this, null, response); } + + /** Async variant of listApplicableAddons for pc2MigrationItem without params. */ + public CompletableFuture + listApplicableAddonsAsync() { + + return getAsync("/pc2_migration_items/applicable_items", null) + .thenApply( + response -> + Pc2MigrationItemListApplicableAddonsResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/Pc2MigrationService.java b/src/main/java/com/chargebee/v4/services/Pc2MigrationService.java index 55c58f7e..d9756928 100644 --- a/src/main/java/com/chargebee/v4/services/Pc2MigrationService.java +++ b/src/main/java/com/chargebee/v4/services/Pc2MigrationService.java @@ -11,6 +11,7 @@ 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.pc2Migration.params.Pc2MigrationCreateParams; @@ -74,6 +75,21 @@ public Pc2MigrationContactSupportResponse contactSupport(String pc2MigrationId) return Pc2MigrationContactSupportResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of contactSupport for pc2Migration without params. */ + public CompletableFuture contactSupportAsync( + String pc2MigrationId) { + String path = + buildPathWithParams( + "/pc2_migrations/{pc2-migration-id}/contact_support", + "pc2-migration-id", + pc2MigrationId); + + return postAsync(path, null) + .thenApply( + response -> + Pc2MigrationContactSupportResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a pc2Migration (executes immediately) - returns raw Response. */ Response retrieveRaw(String pc2MigrationId) throws ChargebeeException { String path = @@ -88,6 +104,18 @@ public Pc2MigrationRetrieveResponse retrieve(String pc2MigrationId) throws Charg return Pc2MigrationRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for pc2Migration without params. */ + public CompletableFuture retrieveAsync(String pc2MigrationId) { + String path = + buildPathWithParams( + "/pc2_migrations/{pc2-migration-id}", "pc2-migration-id", pc2MigrationId); + + return getAsync(path, null) + .thenApply( + response -> + Pc2MigrationRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** create a pc2Migration using immutable params (executes immediately) - returns raw Response. */ Response createRaw(Pc2MigrationCreateParams params) throws ChargebeeException { @@ -107,6 +135,15 @@ public Pc2MigrationCreateResponse create(Pc2MigrationCreateParams params) return Pc2MigrationCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for pc2Migration with params. */ + public CompletableFuture createAsync( + Pc2MigrationCreateParams params) { + + return postAsync("/pc2_migrations", params != null ? params.toFormData() : null) + .thenApply( + response -> Pc2MigrationCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** initiate a pc2Migration (executes immediately) - returns raw Response. */ Response initiateRaw(String pc2MigrationId) throws ChargebeeException { String path = @@ -120,4 +157,16 @@ public Pc2MigrationInitiateResponse initiate(String pc2MigrationId) throws Charg Response response = initiateRaw(pc2MigrationId); return Pc2MigrationInitiateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of initiate for pc2Migration without params. */ + public CompletableFuture initiateAsync(String pc2MigrationId) { + String path = + buildPathWithParams( + "/pc2_migrations/{pc2-migration-id}/initiate", "pc2-migration-id", pc2MigrationId); + + return postAsync(path, null) + .thenApply( + response -> + Pc2MigrationInitiateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PersonalizedOfferService.java b/src/main/java/com/chargebee/v4/services/PersonalizedOfferService.java index 4106323a..226f6cc8 100644 --- a/src/main/java/com/chargebee/v4/services/PersonalizedOfferService.java +++ b/src/main/java/com/chargebee/v4/services/PersonalizedOfferService.java @@ -11,6 +11,7 @@ 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.personalizedOffer.params.PersonalizedOffersParams; @@ -80,4 +81,16 @@ public PersonalizedOffersResponse personalizedOffers(PersonalizedOffersParams pa return PersonalizedOffersResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of personalizedOffers for personalizedOffer with params. */ + public CompletableFuture personalizedOffersAsync( + PersonalizedOffersParams params) { + + return postJsonWithSubDomainAsync( + "/personalized_offers", + SubDomain.GROW.getValue(), + params != null ? params.toJsonString() : null) + .thenApply( + response -> PersonalizedOffersResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PlanService.java b/src/main/java/com/chargebee/v4/services/PlanService.java index 6f202f0e..1e5c7545 100644 --- a/src/main/java/com/chargebee/v4/services/PlanService.java +++ b/src/main/java/com/chargebee/v4/services/PlanService.java @@ -11,6 +11,7 @@ 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.plan.params.PlanCopyParams; @@ -80,6 +81,15 @@ public PlanUnarchiveResponse unarchive(String planId) throws ChargebeeException return PlanUnarchiveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of unarchive for plan without params. */ + public CompletableFuture unarchiveAsync(String planId) { + String path = buildPathWithParams("/plans/{plan-id}/unarchive", "plan-id", planId); + + return postAsync(path, null) + .thenApply( + response -> PlanUnarchiveResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a plan (executes immediately) - returns raw Response. */ Response deleteRaw(String planId) throws ChargebeeException { String path = buildPathWithParams("/plans/{plan-id}/delete", "plan-id", planId); @@ -92,6 +102,14 @@ public PlanDeleteResponse delete(String planId) throws ChargebeeException { return PlanDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for plan without params. */ + public CompletableFuture deleteAsync(String planId) { + String path = buildPathWithParams("/plans/{plan-id}/delete", "plan-id", planId); + + return postAsync(path, null) + .thenApply(response -> PlanDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** copy a plan using immutable params (executes immediately) - returns raw Response. */ Response copyRaw(PlanCopyParams params) throws ChargebeeException { @@ -110,6 +128,13 @@ public PlanCopyResponse copy(PlanCopyParams params) throws ChargebeeException { return PlanCopyResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of copy for plan with params. */ + public CompletableFuture copyAsync(PlanCopyParams params) { + + return postAsync("/plans/copy", params != null ? params.toFormData() : null) + .thenApply(response -> PlanCopyResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a plan using immutable params (executes immediately) - returns raw Response. */ Response listRaw(PlanListParams params) throws ChargebeeException { @@ -134,12 +159,30 @@ public PlanListResponse list(PlanListParams params) throws ChargebeeException { return PlanListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for plan with params. */ + public CompletableFuture listAsync(PlanListParams params) { + + return getAsync("/plans", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + PlanListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public PlanListResponse list() throws ChargebeeException { Response response = listRaw(); return PlanListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for plan without params. */ + public CompletableFuture listAsync() { + + return getAsync("/plans", null) + .thenApply( + response -> + PlanListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a plan using immutable params (executes immediately) - returns raw Response. */ Response createRaw(PlanCreateParams params) throws ChargebeeException { @@ -158,6 +201,13 @@ public PlanCreateResponse create(PlanCreateParams params) throws ChargebeeExcept return PlanCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for plan with params. */ + public CompletableFuture createAsync(PlanCreateParams params) { + + return postAsync("/plans", params != null ? params.toFormData() : null) + .thenApply(response -> PlanCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a plan (executes immediately) - returns raw Response. */ Response retrieveRaw(String planId) throws ChargebeeException { String path = buildPathWithParams("/plans/{plan-id}", "plan-id", planId); @@ -170,6 +220,14 @@ public PlanRetrieveResponse retrieve(String planId) throws ChargebeeException { return PlanRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for plan without params. */ + public CompletableFuture retrieveAsync(String planId) { + String path = buildPathWithParams("/plans/{plan-id}", "plan-id", planId); + + return getAsync(path, null) + .thenApply(response -> PlanRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a plan (executes immediately) - returns raw Response. */ Response updateRaw(String planId) throws ChargebeeException { String path = buildPathWithParams("/plans/{plan-id}", "plan-id", planId); @@ -195,8 +253,23 @@ public PlanUpdateResponse update(String planId, PlanUpdateParams params) return PlanUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for plan with params. */ + public CompletableFuture updateAsync(String planId, PlanUpdateParams params) { + String path = buildPathWithParams("/plans/{plan-id}", "plan-id", planId); + return postAsync(path, params.toFormData()) + .thenApply(response -> PlanUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public PlanUpdateResponse update(String planId) throws ChargebeeException { Response response = updateRaw(planId); return PlanUpdateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of update for plan without params. */ + public CompletableFuture updateAsync(String planId) { + String path = buildPathWithParams("/plans/{plan-id}", "plan-id", planId); + + return postAsync(path, null) + .thenApply(response -> PlanUpdateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PortalSessionService.java b/src/main/java/com/chargebee/v4/services/PortalSessionService.java index 9e928f65..33b835b5 100644 --- a/src/main/java/com/chargebee/v4/services/PortalSessionService.java +++ b/src/main/java/com/chargebee/v4/services/PortalSessionService.java @@ -11,6 +11,7 @@ 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.portalSession.params.PortalSessionCreateParams; @@ -82,6 +83,15 @@ public PortalSessionCreateResponse create(PortalSessionCreateParams params) return PortalSessionCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for portalSession with params. */ + public CompletableFuture createAsync( + PortalSessionCreateParams params) { + + return postAsync("/portal_sessions", params != null ? params.toFormData() : null) + .thenApply( + response -> PortalSessionCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** activate a portalSession (executes immediately) - returns raw Response. */ Response activateRaw(String portalSessionId) throws ChargebeeException { String path = @@ -118,6 +128,18 @@ public PortalSessionActivateResponse activate( return PortalSessionActivateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of activate for portalSession with params. */ + public CompletableFuture activateAsync( + String portalSessionId, PortalSessionActivateParams params) { + String path = + buildPathWithParams( + "/portal_sessions/{portal-session-id}/activate", "portal-session-id", portalSessionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + PortalSessionActivateResponse.fromJson(response.getBodyAsString(), response)); + } + /** logout a portalSession (executes immediately) - returns raw Response. */ Response logoutRaw(String portalSessionId) throws ChargebeeException { String path = @@ -132,6 +154,17 @@ public PortalSessionLogoutResponse logout(String portalSessionId) throws Chargeb return PortalSessionLogoutResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of logout for portalSession without params. */ + public CompletableFuture logoutAsync(String portalSessionId) { + String path = + buildPathWithParams( + "/portal_sessions/{portal-session-id}/logout", "portal-session-id", portalSessionId); + + return postAsync(path, null) + .thenApply( + response -> PortalSessionLogoutResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a portalSession (executes immediately) - returns raw Response. */ Response retrieveRaw(String portalSessionId) throws ChargebeeException { String path = @@ -145,4 +178,16 @@ public PortalSessionRetrieveResponse retrieve(String portalSessionId) throws Cha Response response = retrieveRaw(portalSessionId); return PortalSessionRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for portalSession without params. */ + public CompletableFuture retrieveAsync(String portalSessionId) { + String path = + buildPathWithParams( + "/portal_sessions/{portal-session-id}", "portal-session-id", portalSessionId); + + return getAsync(path, null) + .thenApply( + response -> + PortalSessionRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PriceVariantService.java b/src/main/java/com/chargebee/v4/services/PriceVariantService.java index fee9d8ef..da76fa08 100644 --- a/src/main/java/com/chargebee/v4/services/PriceVariantService.java +++ b/src/main/java/com/chargebee/v4/services/PriceVariantService.java @@ -11,6 +11,7 @@ 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.priceVariant.params.PriceVariantListParams; @@ -77,6 +78,17 @@ public PriceVariantDeleteResponse delete(String priceVariantId) throws Chargebee return PriceVariantDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for priceVariant without params. */ + public CompletableFuture deleteAsync(String priceVariantId) { + String path = + buildPathWithParams( + "/price_variants/{price-variant-id}/delete", "price-variant-id", priceVariantId); + + return postAsync(path, null) + .thenApply( + response -> PriceVariantDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a priceVariant using immutable params (executes immediately) - returns raw Response. */ Response listRaw(PriceVariantListParams params) throws ChargebeeException { @@ -101,12 +113,32 @@ public PriceVariantListResponse list(PriceVariantListParams params) throws Charg return PriceVariantListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for priceVariant with params. */ + public CompletableFuture listAsync(PriceVariantListParams params) { + + return getAsync("/price_variants", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + PriceVariantListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public PriceVariantListResponse list() throws ChargebeeException { Response response = listRaw(); return PriceVariantListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for priceVariant without params. */ + public CompletableFuture listAsync() { + + return getAsync("/price_variants", null) + .thenApply( + response -> + PriceVariantListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** create a priceVariant using immutable params (executes immediately) - returns raw Response. */ Response createRaw(PriceVariantCreateParams params) throws ChargebeeException { @@ -126,6 +158,15 @@ public PriceVariantCreateResponse create(PriceVariantCreateParams params) return PriceVariantCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for priceVariant with params. */ + public CompletableFuture createAsync( + PriceVariantCreateParams params) { + + return postAsync("/price_variants", params != null ? params.toFormData() : null) + .thenApply( + response -> PriceVariantCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a priceVariant (executes immediately) - returns raw Response. */ Response retrieveRaw(String priceVariantId) throws ChargebeeException { String path = @@ -140,6 +181,18 @@ public PriceVariantRetrieveResponse retrieve(String priceVariantId) throws Charg return PriceVariantRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for priceVariant without params. */ + public CompletableFuture retrieveAsync(String priceVariantId) { + String path = + buildPathWithParams( + "/price_variants/{price-variant-id}", "price-variant-id", priceVariantId); + + return getAsync(path, null) + .thenApply( + response -> + PriceVariantRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a priceVariant (executes immediately) - returns raw Response. */ Response updateRaw(String priceVariantId) throws ChargebeeException { String path = @@ -172,8 +225,30 @@ public PriceVariantUpdateResponse update(String priceVariantId, PriceVariantUpda return PriceVariantUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for priceVariant with params. */ + public CompletableFuture updateAsync( + String priceVariantId, PriceVariantUpdateParams params) { + String path = + buildPathWithParams( + "/price_variants/{price-variant-id}", "price-variant-id", priceVariantId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> PriceVariantUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public PriceVariantUpdateResponse update(String priceVariantId) throws ChargebeeException { Response response = updateRaw(priceVariantId); return PriceVariantUpdateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of update for priceVariant without params. */ + public CompletableFuture updateAsync(String priceVariantId) { + String path = + buildPathWithParams( + "/price_variants/{price-variant-id}", "price-variant-id", priceVariantId); + + return postAsync(path, null) + .thenApply( + response -> PriceVariantUpdateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PricingPageSessionService.java b/src/main/java/com/chargebee/v4/services/PricingPageSessionService.java index 763de0cf..6e2f925b 100644 --- a/src/main/java/com/chargebee/v4/services/PricingPageSessionService.java +++ b/src/main/java/com/chargebee/v4/services/PricingPageSessionService.java @@ -11,6 +11,7 @@ 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.pricingPageSession.params.PricingPageSessionCreateForExistingSubscriptionParams; @@ -84,6 +85,20 @@ public PricingPageSessionCreateForExistingSubscriptionResponse createForExisting response.getBodyAsString(), response); } + /** Async variant of createForExistingSubscription for pricingPageSession with params. */ + public CompletableFuture + createForExistingSubscriptionAsync( + PricingPageSessionCreateForExistingSubscriptionParams params) { + + return postAsync( + "/pricing_page_sessions/create_for_existing_subscription", + params != null ? params.toFormData() : null) + .thenApply( + response -> + PricingPageSessionCreateForExistingSubscriptionResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * createForNewSubscription a pricingPageSession using immutable params (executes immediately) - * returns raw Response. @@ -112,4 +127,17 @@ public PricingPageSessionCreateForNewSubscriptionResponse createForNewSubscripti return PricingPageSessionCreateForNewSubscriptionResponse.fromJson( response.getBodyAsString(), response); } + + /** Async variant of createForNewSubscription for pricingPageSession with params. */ + public CompletableFuture + createForNewSubscriptionAsync(PricingPageSessionCreateForNewSubscriptionParams params) { + + return postAsync( + "/pricing_page_sessions/create_for_new_subscription", + params != null ? params.toFormData() : null) + .thenApply( + response -> + PricingPageSessionCreateForNewSubscriptionResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ProductService.java b/src/main/java/com/chargebee/v4/services/ProductService.java index 1a3fef34..1a91f535 100644 --- a/src/main/java/com/chargebee/v4/services/ProductService.java +++ b/src/main/java/com/chargebee/v4/services/ProductService.java @@ -11,6 +11,7 @@ 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.product.params.ProductUpdateParams; @@ -78,6 +79,15 @@ public ProductRetrieveResponse retrieve(String productId) throws ChargebeeExcept return ProductRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for product without params. */ + public CompletableFuture retrieveAsync(String productId) { + String path = buildPathWithParams("/products/{product-id}", "product-id", productId); + + return getAsync(path, null) + .thenApply( + response -> ProductRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a product (executes immediately) - returns raw Response. */ Response updateRaw(String productId) throws ChargebeeException { String path = buildPathWithParams("/products/{product-id}", "product-id", productId); @@ -103,11 +113,29 @@ public ProductUpdateResponse update(String productId, ProductUpdateParams params return ProductUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for product with params. */ + public CompletableFuture updateAsync( + String productId, ProductUpdateParams params) { + String path = buildPathWithParams("/products/{product-id}", "product-id", productId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> ProductUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public ProductUpdateResponse update(String productId) throws ChargebeeException { Response response = updateRaw(productId); return ProductUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for product without params. */ + public CompletableFuture updateAsync(String productId) { + String path = buildPathWithParams("/products/{product-id}", "product-id", productId); + + return postAsync(path, null) + .thenApply( + response -> ProductUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a product (executes immediately) - returns raw Response. */ Response deleteRaw(String productId) throws ChargebeeException { String path = buildPathWithParams("/products/{product-id}/delete", "product-id", productId); @@ -120,6 +148,15 @@ public ProductDeleteResponse delete(String productId) throws ChargebeeException return ProductDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for product without params. */ + public CompletableFuture deleteAsync(String productId) { + String path = buildPathWithParams("/products/{product-id}/delete", "product-id", productId); + + return postAsync(path, null) + .thenApply( + response -> ProductDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** updateOptions a product (executes immediately) - returns raw Response. */ Response updateOptionsRaw(String productId) throws ChargebeeException { String path = @@ -153,11 +190,33 @@ public ProductUpdateOptionsResponse updateOptions( return ProductUpdateOptionsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateOptions for product with params. */ + public CompletableFuture updateOptionsAsync( + String productId, ProductUpdateOptionsParams params) { + String path = + buildPathWithParams("/products/{product-id}/update_options", "product-id", productId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + ProductUpdateOptionsResponse.fromJson(response.getBodyAsString(), response)); + } + public ProductUpdateOptionsResponse updateOptions(String productId) throws ChargebeeException { Response response = updateOptionsRaw(productId); return ProductUpdateOptionsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateOptions for product without params. */ + public CompletableFuture updateOptionsAsync(String productId) { + String path = + buildPathWithParams("/products/{product-id}/update_options", "product-id", productId); + + return postAsync(path, null) + .thenApply( + response -> + ProductUpdateOptionsResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a product using immutable params (executes immediately) - returns raw Response. */ Response listRaw(ProductListParams params) throws ChargebeeException { @@ -182,12 +241,30 @@ public ProductListResponse list(ProductListParams params) throws ChargebeeExcept return ProductListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for product with params. */ + public CompletableFuture listAsync(ProductListParams params) { + + return getAsync("/products", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ProductListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public ProductListResponse list() throws ChargebeeException { Response response = listRaw(); return ProductListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for product without params. */ + public CompletableFuture listAsync() { + + return getAsync("/products", null) + .thenApply( + response -> + ProductListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** create a product using immutable params (executes immediately) - returns raw Response. */ Response createRaw(ProductCreateParams params) throws ChargebeeException { @@ -205,4 +282,12 @@ public ProductCreateResponse create(ProductCreateParams params) throws Chargebee return ProductCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for product with params. */ + public CompletableFuture createAsync(ProductCreateParams params) { + + return postAsync("/products", params != null ? params.toFormData() : null) + .thenApply( + response -> ProductCreateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PromotionalCreditService.java b/src/main/java/com/chargebee/v4/services/PromotionalCreditService.java index 6b616ca9..5e63ba19 100644 --- a/src/main/java/com/chargebee/v4/services/PromotionalCreditService.java +++ b/src/main/java/com/chargebee/v4/services/PromotionalCreditService.java @@ -11,6 +11,7 @@ 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.promotionalCredit.params.PromotionalCreditListParams; @@ -80,6 +81,19 @@ public PromotionalCreditRetrieveResponse retrieve(String accountCreditId) return PromotionalCreditRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for promotionalCredit without params. */ + public CompletableFuture retrieveAsync( + String accountCreditId) { + String path = + buildPathWithParams( + "/promotional_credits/{account-credit-id}", "account-credit-id", accountCreditId); + + return getAsync(path, null) + .thenApply( + response -> + PromotionalCreditRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * list a promotionalCredit using immutable params (executes immediately) - returns raw Response. */ @@ -110,12 +124,33 @@ public PromotionalCreditListResponse list(PromotionalCreditListParams params) response.getBodyAsString(), this, params, response); } + /** Async variant of list for promotionalCredit with params. */ + public CompletableFuture listAsync( + PromotionalCreditListParams params) { + + return getAsync("/promotional_credits", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + PromotionalCreditListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public PromotionalCreditListResponse list() throws ChargebeeException { Response response = listRaw(); return PromotionalCreditListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for promotionalCredit without params. */ + public CompletableFuture listAsync() { + + return getAsync("/promotional_credits", null) + .thenApply( + response -> + PromotionalCreditListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** * deduct a promotionalCredit using immutable params (executes immediately) - returns raw * Response. @@ -141,6 +176,16 @@ public PromotionalCreditDeductResponse deduct(PromotionalCreditDeductParams para return PromotionalCreditDeductResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deduct for promotionalCredit with params. */ + public CompletableFuture deductAsync( + PromotionalCreditDeductParams params) { + + return postAsync("/promotional_credits/deduct", params != null ? params.toFormData() : null) + .thenApply( + response -> + PromotionalCreditDeductResponse.fromJson(response.getBodyAsString(), response)); + } + /** * set a promotionalCredit using immutable params (executes immediately) - returns raw Response. */ @@ -164,6 +209,16 @@ public PromotionalCreditSetResponse set(PromotionalCreditSetParams params) return PromotionalCreditSetResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of set for promotionalCredit with params. */ + public CompletableFuture setAsync( + PromotionalCreditSetParams params) { + + return postAsync("/promotional_credits/set", params != null ? params.toFormData() : null) + .thenApply( + response -> + PromotionalCreditSetResponse.fromJson(response.getBodyAsString(), response)); + } + /** * add a promotionalCredit using immutable params (executes immediately) - returns raw Response. */ @@ -186,4 +241,14 @@ public PromotionalCreditAddResponse add(PromotionalCreditAddParams params) return PromotionalCreditAddResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of add for promotionalCredit with params. */ + public CompletableFuture addAsync( + PromotionalCreditAddParams params) { + + return postAsync("/promotional_credits/add", params != null ? params.toFormData() : null) + .thenApply( + response -> + PromotionalCreditAddResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/PurchaseService.java b/src/main/java/com/chargebee/v4/services/PurchaseService.java index c40269f4..c0e87713 100644 --- a/src/main/java/com/chargebee/v4/services/PurchaseService.java +++ b/src/main/java/com/chargebee/v4/services/PurchaseService.java @@ -11,6 +11,7 @@ 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.purchase.params.PurchaseCreateParams; @@ -72,6 +73,14 @@ public PurchaseCreateResponse create(PurchaseCreateParams params) throws Chargeb return PurchaseCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for purchase with params. */ + public CompletableFuture createAsync(PurchaseCreateParams params) { + + return postAsync("/purchases", params != null ? params.toFormData() : null) + .thenApply( + response -> PurchaseCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** estimate a purchase using immutable params (executes immediately) - returns raw Response. */ Response estimateRaw(PurchaseEstimateParams params) throws ChargebeeException { @@ -90,4 +99,12 @@ public PurchaseEstimateResponse estimate(PurchaseEstimateParams params) return PurchaseEstimateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of estimate for purchase with params. */ + public CompletableFuture estimateAsync(PurchaseEstimateParams params) { + + return postAsync("/purchases/estimate", params != null ? params.toFormData() : null) + .thenApply( + response -> PurchaseEstimateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/QuoteService.java b/src/main/java/com/chargebee/v4/services/QuoteService.java index 35fd21ec..49e88857 100644 --- a/src/main/java/com/chargebee/v4/services/QuoteService.java +++ b/src/main/java/com/chargebee/v4/services/QuoteService.java @@ -11,6 +11,7 @@ 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.quote.params.CreateSubscriptionItemsForCustomerQuoteParams; @@ -174,6 +175,22 @@ public CreateSubscriptionItemsForCustomerQuoteResponse createSubscriptionItemsFo response.getBodyAsString(), response); } + /** Async variant of createSubscriptionItemsForCustomerQuote for quote with params. */ + public CompletableFuture + createSubscriptionItemsForCustomerQuoteAsync( + String customerId, CreateSubscriptionItemsForCustomerQuoteParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/create_subscription_quote_for_items", + "customer-id", + customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CreateSubscriptionItemsForCustomerQuoteResponse.fromJson( + response.getBodyAsString(), response)); + } + public CreateSubscriptionItemsForCustomerQuoteResponse createSubscriptionItemsForCustomerQuote( String customerId) throws ChargebeeException { Response response = createSubscriptionItemsForCustomerQuoteRaw(customerId); @@ -181,6 +198,22 @@ public CreateSubscriptionItemsForCustomerQuoteResponse createSubscriptionItemsFo response.getBodyAsString(), response); } + /** Async variant of createSubscriptionItemsForCustomerQuote for quote without params. */ + public CompletableFuture + createSubscriptionItemsForCustomerQuoteAsync(String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/create_subscription_quote_for_items", + "customer-id", + customerId); + + return postAsync(path, null) + .thenApply( + response -> + CreateSubscriptionItemsForCustomerQuoteResponse.fromJson( + response.getBodyAsString(), response)); + } + /** retrieve a quote (executes immediately) - returns raw Response. */ Response retrieveRaw(String quoteId) throws ChargebeeException { String path = buildPathWithParams("/quotes/{quote-id}", "quote-id", quoteId); @@ -193,6 +226,15 @@ public QuoteRetrieveResponse retrieve(String quoteId) throws ChargebeeException return QuoteRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for quote without params. */ + public CompletableFuture retrieveAsync(String quoteId) { + String path = buildPathWithParams("/quotes/{quote-id}", "quote-id", quoteId); + + return getAsync(path, null) + .thenApply( + response -> QuoteRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * editCreateSubscriptionCustomerQuoteForItems a quote (executes immediately) - returns raw * Response. @@ -240,6 +282,20 @@ Response editCreateSubscriptionCustomerQuoteForItemsRaw(String quoteId, String j response.getBodyAsString(), response); } + /** Async variant of editCreateSubscriptionCustomerQuoteForItems for quote with params. */ + public CompletableFuture + editCreateSubscriptionCustomerQuoteForItemsAsync( + String quoteId, EditCreateSubscriptionCustomerQuoteForItemsParams params) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_create_subscription_quote_for_items", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + EditCreateSubscriptionCustomerQuoteForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + public EditCreateSubscriptionCustomerQuoteForItemsResponse editCreateSubscriptionCustomerQuoteForItems(String quoteId) throws ChargebeeException { Response response = editCreateSubscriptionCustomerQuoteForItemsRaw(quoteId); @@ -247,6 +303,20 @@ Response editCreateSubscriptionCustomerQuoteForItemsRaw(String quoteId, String j response.getBodyAsString(), response); } + /** Async variant of editCreateSubscriptionCustomerQuoteForItems for quote without params. */ + public CompletableFuture + editCreateSubscriptionCustomerQuoteForItemsAsync(String quoteId) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_create_subscription_quote_for_items", "quote-id", quoteId); + + return postAsync(path, null) + .thenApply( + response -> + EditCreateSubscriptionCustomerQuoteForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** updateStatus a quote (executes immediately) - returns raw Response. */ Response updateStatusRaw(String quoteId) throws ChargebeeException { String path = buildPathWithParams("/quotes/{quote-id}/update_status", "quote-id", quoteId); @@ -273,6 +343,15 @@ public QuoteUpdateStatusResponse updateStatus(String quoteId, QuoteUpdateStatusP return QuoteUpdateStatusResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateStatus for quote with params. */ + public CompletableFuture updateStatusAsync( + String quoteId, QuoteUpdateStatusParams params) { + String path = buildPathWithParams("/quotes/{quote-id}/update_status", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> QuoteUpdateStatusResponse.fromJson(response.getBodyAsString(), response)); + } + /** * updateSubscriptionQuoteForItems a quote using immutable params (executes immediately) - returns * raw Response. @@ -300,6 +379,19 @@ public UpdateSubscriptionQuoteForItemsResponse updateSubscriptionQuoteForItems( return UpdateSubscriptionQuoteForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateSubscriptionQuoteForItems for quote with params. */ + public CompletableFuture + updateSubscriptionQuoteForItemsAsync(UpdateSubscriptionQuoteForItemsParams params) { + + return postAsync( + "/quotes/update_subscription_quote_for_items", + params != null ? params.toFormData() : null) + .thenApply( + response -> + UpdateSubscriptionQuoteForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * quoteLineGroupsForQuote a quote using immutable params (executes immediately) - returns raw * Response. @@ -342,6 +434,28 @@ public QuoteLineGroupsForQuoteResponse quoteLineGroupsForQuote(String quoteId) response.getBodyAsString(), this, null, quoteId, response); } + /** Async variant of quoteLineGroupsForQuote for quote with params. */ + public CompletableFuture quoteLineGroupsForQuoteAsync( + String quoteId, QuoteLineGroupsForQuoteParams params) { + String path = buildPathWithParams("/quotes/{quote-id}/quote_line_groups", "quote-id", quoteId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + QuoteLineGroupsForQuoteResponse.fromJson( + response.getBodyAsString(), this, params, quoteId, response)); + } + + /** Async variant of quoteLineGroupsForQuote for quote without params. */ + public CompletableFuture quoteLineGroupsForQuoteAsync( + String quoteId) { + String path = buildPathWithParams("/quotes/{quote-id}/quote_line_groups", "quote-id", quoteId); + return getAsync(path, null) + .thenApply( + response -> + QuoteLineGroupsForQuoteResponse.fromJson( + response.getBodyAsString(), this, null, quoteId, response)); + } + /** extendExpiryDate a quote (executes immediately) - returns raw Response. */ Response extendExpiryDateRaw(String quoteId) throws ChargebeeException { String path = buildPathWithParams("/quotes/{quote-id}/extend_expiry_date", "quote-id", quoteId); @@ -372,6 +486,16 @@ public QuoteExtendExpiryDateResponse extendExpiryDate( return QuoteExtendExpiryDateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of extendExpiryDate for quote with params. */ + public CompletableFuture extendExpiryDateAsync( + String quoteId, QuoteExtendExpiryDateParams params) { + String path = buildPathWithParams("/quotes/{quote-id}/extend_expiry_date", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + QuoteExtendExpiryDateResponse.fromJson(response.getBodyAsString(), response)); + } + /** editForChargeItemsAndCharges a quote (executes immediately) - returns raw Response. */ Response editForChargeItemsAndChargesRaw(String quoteId) throws ChargebeeException { String path = @@ -411,12 +535,40 @@ public QuoteEditForChargeItemsAndChargesResponse editForChargeItemsAndCharges( return QuoteEditForChargeItemsAndChargesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of editForChargeItemsAndCharges for quote with params. */ + public CompletableFuture + editForChargeItemsAndChargesAsync( + String quoteId, QuoteEditForChargeItemsAndChargesParams params) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_for_charge_items_and_charges", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + QuoteEditForChargeItemsAndChargesResponse.fromJson( + response.getBodyAsString(), response)); + } + public QuoteEditForChargeItemsAndChargesResponse editForChargeItemsAndCharges(String quoteId) throws ChargebeeException { Response response = editForChargeItemsAndChargesRaw(quoteId); return QuoteEditForChargeItemsAndChargesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of editForChargeItemsAndCharges for quote without params. */ + public CompletableFuture + editForChargeItemsAndChargesAsync(String quoteId) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_for_charge_items_and_charges", "quote-id", quoteId); + + return postAsync(path, null) + .thenApply( + response -> + QuoteEditForChargeItemsAndChargesResponse.fromJson( + response.getBodyAsString(), response)); + } + /** editUpdateSubscriptionQuoteForItems a quote (executes immediately) - returns raw Response. */ Response editUpdateSubscriptionQuoteForItemsRaw(String quoteId) throws ChargebeeException { String path = @@ -457,6 +609,20 @@ public EditUpdateSubscriptionQuoteForItemsResponse editUpdateSubscriptionQuoteFo response.getBodyAsString(), response); } + /** Async variant of editUpdateSubscriptionQuoteForItems for quote with params. */ + public CompletableFuture + editUpdateSubscriptionQuoteForItemsAsync( + String quoteId, EditUpdateSubscriptionQuoteForItemsParams params) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_update_subscription_quote_for_items", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + EditUpdateSubscriptionQuoteForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + public EditUpdateSubscriptionQuoteForItemsResponse editUpdateSubscriptionQuoteForItems( String quoteId) throws ChargebeeException { Response response = editUpdateSubscriptionQuoteForItemsRaw(quoteId); @@ -464,6 +630,20 @@ public EditUpdateSubscriptionQuoteForItemsResponse editUpdateSubscriptionQuoteFo response.getBodyAsString(), response); } + /** Async variant of editUpdateSubscriptionQuoteForItems for quote without params. */ + public CompletableFuture + editUpdateSubscriptionQuoteForItemsAsync(String quoteId) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_update_subscription_quote_for_items", "quote-id", quoteId); + + return postAsync(path, null) + .thenApply( + response -> + EditUpdateSubscriptionQuoteForItemsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** list a quote using immutable params (executes immediately) - returns raw Response. */ Response listRaw(QuoteListParams params) throws ChargebeeException { @@ -488,12 +668,30 @@ public QuoteListResponse list(QuoteListParams params) throws ChargebeeException return QuoteListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for quote with params. */ + public CompletableFuture listAsync(QuoteListParams params) { + + return getAsync("/quotes", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + QuoteListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public QuoteListResponse list() throws ChargebeeException { Response response = listRaw(); return QuoteListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for quote without params. */ + public CompletableFuture listAsync() { + + return getAsync("/quotes", null) + .thenApply( + response -> + QuoteListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** pdf a quote (executes immediately) - returns raw Response. */ Response pdfRaw(String quoteId) throws ChargebeeException { String path = buildPathWithParams("/quotes/{quote-id}/pdf", "quote-id", quoteId); @@ -518,11 +716,26 @@ public QuotePdfResponse pdf(String quoteId, QuotePdfParams params) throws Charge return QuotePdfResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pdf for quote with params. */ + public CompletableFuture pdfAsync(String quoteId, QuotePdfParams params) { + String path = buildPathWithParams("/quotes/{quote-id}/pdf", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply(response -> QuotePdfResponse.fromJson(response.getBodyAsString(), response)); + } + public QuotePdfResponse pdf(String quoteId) throws ChargebeeException { Response response = pdfRaw(quoteId); return QuotePdfResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pdf for quote without params. */ + public CompletableFuture pdfAsync(String quoteId) { + String path = buildPathWithParams("/quotes/{quote-id}/pdf", "quote-id", quoteId); + + return postAsync(path, null) + .thenApply(response -> QuotePdfResponse.fromJson(response.getBodyAsString(), response)); + } + /** convert a quote (executes immediately) - returns raw Response. */ Response convertRaw(String quoteId) throws ChargebeeException { String path = buildPathWithParams("/quotes/{quote-id}/convert", "quote-id", quoteId); @@ -548,11 +761,27 @@ public QuoteConvertResponse convert(String quoteId, QuoteConvertParams params) return QuoteConvertResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of convert for quote with params. */ + public CompletableFuture convertAsync( + String quoteId, QuoteConvertParams params) { + String path = buildPathWithParams("/quotes/{quote-id}/convert", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply(response -> QuoteConvertResponse.fromJson(response.getBodyAsString(), response)); + } + public QuoteConvertResponse convert(String quoteId) throws ChargebeeException { Response response = convertRaw(quoteId); return QuoteConvertResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of convert for quote without params. */ + public CompletableFuture convertAsync(String quoteId) { + String path = buildPathWithParams("/quotes/{quote-id}/convert", "quote-id", quoteId); + + return postAsync(path, null) + .thenApply(response -> QuoteConvertResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createForChargeItemsAndCharges a quote using immutable params (executes immediately) - returns * raw Response. @@ -581,6 +810,19 @@ public QuoteCreateForChargeItemsAndChargesResponse createForChargeItemsAndCharge response.getBodyAsString(), response); } + /** Async variant of createForChargeItemsAndCharges for quote with params. */ + public CompletableFuture + createForChargeItemsAndChargesAsync(QuoteCreateForChargeItemsAndChargesParams params) { + + return postAsync( + "/quotes/create_for_charge_items_and_charges", + params != null ? params.toFormData() : null) + .thenApply( + response -> + QuoteCreateForChargeItemsAndChargesResponse.fromJson( + response.getBodyAsString(), response)); + } + /** delete a quote (executes immediately) - returns raw Response. */ Response deleteRaw(String quoteId) throws ChargebeeException { String path = buildPathWithParams("/quotes/{quote-id}/delete", "quote-id", quoteId); @@ -606,11 +848,27 @@ public QuoteDeleteResponse delete(String quoteId, QuoteDeleteParams params) return QuoteDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for quote with params. */ + public CompletableFuture deleteAsync( + String quoteId, QuoteDeleteParams params) { + String path = buildPathWithParams("/quotes/{quote-id}/delete", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply(response -> QuoteDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + public QuoteDeleteResponse delete(String quoteId) throws ChargebeeException { Response response = deleteRaw(quoteId); return QuoteDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for quote without params. */ + public CompletableFuture deleteAsync(String quoteId) { + String path = buildPathWithParams("/quotes/{quote-id}/delete", "quote-id", quoteId); + + return postAsync(path, null) + .thenApply(response -> QuoteDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** editOneTimeQuote a quote (executes immediately) - returns raw Response. */ Response editOneTimeQuoteRaw(String quoteId) throws ChargebeeException { String path = @@ -644,11 +902,31 @@ public EditOneTimeQuoteResponse editOneTimeQuote(String quoteId, EditOneTimeQuot return EditOneTimeQuoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of editOneTimeQuote for quote with params. */ + public CompletableFuture editOneTimeQuoteAsync( + String quoteId, EditOneTimeQuoteParams params) { + String path = + buildPathWithParams("/quotes/{quote-id}/edit_one_time_quote", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> EditOneTimeQuoteResponse.fromJson(response.getBodyAsString(), response)); + } + public EditOneTimeQuoteResponse editOneTimeQuote(String quoteId) throws ChargebeeException { Response response = editOneTimeQuoteRaw(quoteId); return EditOneTimeQuoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of editOneTimeQuote for quote without params. */ + public CompletableFuture editOneTimeQuoteAsync(String quoteId) { + String path = + buildPathWithParams("/quotes/{quote-id}/edit_one_time_quote", "quote-id", quoteId); + + return postAsync(path, null) + .thenApply( + response -> EditOneTimeQuoteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * updateSubscriptionQuote a quote using immutable params (executes immediately) - returns raw * Response. @@ -675,6 +953,17 @@ public UpdateSubscriptionQuoteResponse updateSubscriptionQuote( return UpdateSubscriptionQuoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateSubscriptionQuote for quote with params. */ + public CompletableFuture updateSubscriptionQuoteAsync( + UpdateSubscriptionQuoteParams params) { + + return postAsync( + "/quotes/update_subscription_quote", params != null ? params.toFormData() : null) + .thenApply( + response -> + UpdateSubscriptionQuoteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createForOnetimeCharges a quote using immutable params (executes immediately) - returns raw * Response. @@ -701,6 +990,18 @@ public QuoteCreateForOnetimeChargesResponse createForOnetimeCharges( return QuoteCreateForOnetimeChargesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createForOnetimeCharges for quote with params. */ + public CompletableFuture createForOnetimeChargesAsync( + QuoteCreateForOnetimeChargesParams params) { + + return postAsync( + "/quotes/create_for_onetime_charges", params != null ? params.toFormData() : null) + .thenApply( + response -> + QuoteCreateForOnetimeChargesResponse.fromJson( + response.getBodyAsString(), response)); + } + /** createSubscriptionForCustomerQuote a quote (executes immediately) - returns raw Response. */ Response createSubscriptionForCustomerQuoteRaw(String customerId) throws ChargebeeException { String path = @@ -743,6 +1044,20 @@ public CreateSubscriptionForCustomerQuoteResponse createSubscriptionForCustomerQ response.getBodyAsString(), response); } + /** Async variant of createSubscriptionForCustomerQuote for quote with params. */ + public CompletableFuture + createSubscriptionForCustomerQuoteAsync( + String customerId, CreateSubscriptionForCustomerQuoteParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/create_subscription_quote", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CreateSubscriptionForCustomerQuoteResponse.fromJson( + response.getBodyAsString(), response)); + } + public CreateSubscriptionForCustomerQuoteResponse createSubscriptionForCustomerQuote( String customerId) throws ChargebeeException { Response response = createSubscriptionForCustomerQuoteRaw(customerId); @@ -750,6 +1065,20 @@ public CreateSubscriptionForCustomerQuoteResponse createSubscriptionForCustomerQ response.getBodyAsString(), response); } + /** Async variant of createSubscriptionForCustomerQuote for quote without params. */ + public CompletableFuture + createSubscriptionForCustomerQuoteAsync(String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/create_subscription_quote", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + CreateSubscriptionForCustomerQuoteResponse.fromJson( + response.getBodyAsString(), response)); + } + /** editUpdateSubscriptionQuote a quote (executes immediately) - returns raw Response. */ Response editUpdateSubscriptionQuoteRaw(String quoteId) throws ChargebeeException { String path = @@ -789,12 +1118,37 @@ public EditUpdateSubscriptionQuoteResponse editUpdateSubscriptionQuote( return EditUpdateSubscriptionQuoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of editUpdateSubscriptionQuote for quote with params. */ + public CompletableFuture editUpdateSubscriptionQuoteAsync( + String quoteId, EditUpdateSubscriptionQuoteParams params) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_update_subscription_quote", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + EditUpdateSubscriptionQuoteResponse.fromJson(response.getBodyAsString(), response)); + } + public EditUpdateSubscriptionQuoteResponse editUpdateSubscriptionQuote(String quoteId) throws ChargebeeException { Response response = editUpdateSubscriptionQuoteRaw(quoteId); return EditUpdateSubscriptionQuoteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of editUpdateSubscriptionQuote for quote without params. */ + public CompletableFuture editUpdateSubscriptionQuoteAsync( + String quoteId) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_update_subscription_quote", "quote-id", quoteId); + + return postAsync(path, null) + .thenApply( + response -> + EditUpdateSubscriptionQuoteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * editCreateSubscriptionForCustomerQuote a quote (executes immediately) - returns raw Response. */ @@ -839,10 +1193,38 @@ public EditCreateSubscriptionForCustomerQuoteResponse editCreateSubscriptionForC response.getBodyAsString(), response); } + /** Async variant of editCreateSubscriptionForCustomerQuote for quote with params. */ + public CompletableFuture + editCreateSubscriptionForCustomerQuoteAsync( + String quoteId, EditCreateSubscriptionForCustomerQuoteParams params) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_create_subscription_quote", "quote-id", quoteId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + EditCreateSubscriptionForCustomerQuoteResponse.fromJson( + response.getBodyAsString(), response)); + } + public EditCreateSubscriptionForCustomerQuoteResponse editCreateSubscriptionForCustomerQuote( String quoteId) throws ChargebeeException { Response response = editCreateSubscriptionForCustomerQuoteRaw(quoteId); return EditCreateSubscriptionForCustomerQuoteResponse.fromJson( response.getBodyAsString(), response); } + + /** Async variant of editCreateSubscriptionForCustomerQuote for quote without params. */ + public CompletableFuture + editCreateSubscriptionForCustomerQuoteAsync(String quoteId) { + String path = + buildPathWithParams( + "/quotes/{quote-id}/edit_create_subscription_quote", "quote-id", quoteId); + + return postAsync(path, null) + .thenApply( + response -> + EditCreateSubscriptionForCustomerQuoteResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/RampService.java b/src/main/java/com/chargebee/v4/services/RampService.java index e6f96850..8a5e3cda 100644 --- a/src/main/java/com/chargebee/v4/services/RampService.java +++ b/src/main/java/com/chargebee/v4/services/RampService.java @@ -11,6 +11,7 @@ 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.ramp.params.RampCreateForSubscriptionParams; @@ -74,6 +75,14 @@ public RampRetrieveResponse retrieve(String rampId) throws ChargebeeException { return RampRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for ramp without params. */ + public CompletableFuture retrieveAsync(String rampId) { + String path = buildPathWithParams("/ramps/{ramp-id}", "ramp-id", rampId); + + return getAsync(path, null) + .thenApply(response -> RampRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** createForSubscription a ramp (executes immediately) - returns raw Response. */ Response createForSubscriptionRaw(String subscriptionId) throws ChargebeeException { String path = @@ -113,6 +122,18 @@ public RampCreateForSubscriptionResponse createForSubscription( return RampCreateForSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createForSubscription for ramp with params. */ + public CompletableFuture createForSubscriptionAsync( + String subscriptionId, RampCreateForSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/create_ramp", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + RampCreateForSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a ramp using immutable params (executes immediately) - returns raw Response. */ Response listRaw(RampListParams params) throws ChargebeeException { @@ -137,12 +158,30 @@ public RampListResponse list(RampListParams params) throws ChargebeeException { return RampListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for ramp with params. */ + public CompletableFuture listAsync(RampListParams params) { + + return getAsync("/ramps", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + RampListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public RampListResponse list() throws ChargebeeException { Response response = listRaw(); return RampListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for ramp without params. */ + public CompletableFuture listAsync() { + + return getAsync("/ramps", null) + .thenApply( + response -> + RampListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** update a ramp (executes immediately) - returns raw Response. */ Response updateRaw(String rampId) throws ChargebeeException { String path = buildPathWithParams("/ramps/{ramp-id}/update", "ramp-id", rampId); @@ -168,6 +207,13 @@ public RampUpdateResponse update(String rampId, RampUpdateParams params) return RampUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for ramp with params. */ + public CompletableFuture updateAsync(String rampId, RampUpdateParams params) { + String path = buildPathWithParams("/ramps/{ramp-id}/update", "ramp-id", rampId); + return postAsync(path, params.toFormData()) + .thenApply(response -> RampUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a ramp (executes immediately) - returns raw Response. */ Response deleteRaw(String rampId) throws ChargebeeException { String path = buildPathWithParams("/ramps/{ramp-id}/delete", "ramp-id", rampId); @@ -179,4 +225,12 @@ public RampDeleteResponse delete(String rampId) throws ChargebeeException { Response response = deleteRaw(rampId); return RampDeleteResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of delete for ramp without params. */ + public CompletableFuture deleteAsync(String rampId) { + String path = buildPathWithParams("/ramps/{ramp-id}/delete", "ramp-id", rampId); + + return postAsync(path, null) + .thenApply(response -> RampDeleteResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/RecordedPurchaseService.java b/src/main/java/com/chargebee/v4/services/RecordedPurchaseService.java index 67b65fe9..b43ea108 100644 --- a/src/main/java/com/chargebee/v4/services/RecordedPurchaseService.java +++ b/src/main/java/com/chargebee/v4/services/RecordedPurchaseService.java @@ -11,6 +11,7 @@ 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.recordedPurchase.params.RecordedPurchaseCreateParams; @@ -70,6 +71,21 @@ public RecordedPurchaseRetrieveResponse retrieve(String recordedPurchaseId) return RecordedPurchaseRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for recordedPurchase without params. */ + public CompletableFuture retrieveAsync( + String recordedPurchaseId) { + String path = + buildPathWithParams( + "/recorded_purchases/{recorded-purchase-id}", + "recorded-purchase-id", + recordedPurchaseId); + + return getAsync(path, null) + .thenApply( + response -> + RecordedPurchaseRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * create a recordedPurchase using immutable params (executes immediately) - returns raw Response. */ @@ -92,4 +108,14 @@ public RecordedPurchaseCreateResponse create(RecordedPurchaseCreateParams params return RecordedPurchaseCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for recordedPurchase with params. */ + public CompletableFuture createAsync( + RecordedPurchaseCreateParams params) { + + return postAsync("/recorded_purchases", params != null ? params.toFormData() : null) + .thenApply( + response -> + RecordedPurchaseCreateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ResourceMigrationService.java b/src/main/java/com/chargebee/v4/services/ResourceMigrationService.java index 19a552d5..bafac52e 100644 --- a/src/main/java/com/chargebee/v4/services/ResourceMigrationService.java +++ b/src/main/java/com/chargebee/v4/services/ResourceMigrationService.java @@ -11,6 +11,7 @@ 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.resourceMigration.params.ResourceMigrationRetrieveLatestParams; @@ -77,4 +78,16 @@ public ResourceMigrationRetrieveLatestResponse retrieveLatest( return ResourceMigrationRetrieveLatestResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieveLatest for resourceMigration with params. */ + public CompletableFuture retrieveLatestAsync( + ResourceMigrationRetrieveLatestParams params) { + + return getAsync( + "/resource_migrations/retrieve_latest", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ResourceMigrationRetrieveLatestResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/RuleService.java b/src/main/java/com/chargebee/v4/services/RuleService.java index 3b774961..9940ef4b 100644 --- a/src/main/java/com/chargebee/v4/services/RuleService.java +++ b/src/main/java/com/chargebee/v4/services/RuleService.java @@ -11,6 +11,7 @@ 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.rule.responses.RuleRetrieveResponse; @@ -59,4 +60,12 @@ public RuleRetrieveResponse retrieve(String ruleId) throws ChargebeeException { Response response = retrieveRaw(ruleId); return RuleRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for rule without params. */ + public CompletableFuture retrieveAsync(String ruleId) { + String path = buildPathWithParams("/rules/{rule-id}", "rule-id", ruleId); + + return getAsync(path, null) + .thenApply(response -> RuleRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/SiteMigrationDetailService.java b/src/main/java/com/chargebee/v4/services/SiteMigrationDetailService.java index f1d0f278..deff5d62 100644 --- a/src/main/java/com/chargebee/v4/services/SiteMigrationDetailService.java +++ b/src/main/java/com/chargebee/v4/services/SiteMigrationDetailService.java @@ -11,6 +11,7 @@ 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.siteMigrationDetail.params.SiteMigrationDetailListParams; @@ -83,10 +84,31 @@ public SiteMigrationDetailListResponse list(SiteMigrationDetailListParams params response.getBodyAsString(), this, params, response); } + /** Async variant of list for siteMigrationDetail with params. */ + public CompletableFuture listAsync( + SiteMigrationDetailListParams params) { + + return getAsync("/site_migration_details", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + SiteMigrationDetailListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public SiteMigrationDetailListResponse list() throws ChargebeeException { Response response = listRaw(); return SiteMigrationDetailListResponse.fromJson( response.getBodyAsString(), this, null, response); } + + /** Async variant of list for siteMigrationDetail without params. */ + public CompletableFuture listAsync() { + + return getAsync("/site_migration_details", null) + .thenApply( + response -> + SiteMigrationDetailListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/SubscriptionEntitlementService.java b/src/main/java/com/chargebee/v4/services/SubscriptionEntitlementService.java index ef765657..27ef5826 100644 --- a/src/main/java/com/chargebee/v4/services/SubscriptionEntitlementService.java +++ b/src/main/java/com/chargebee/v4/services/SubscriptionEntitlementService.java @@ -11,6 +11,7 @@ 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.subscriptionEntitlement.params.SetSubscriptionEntitlementAvailabilityParams; @@ -108,6 +109,25 @@ public SetSubscriptionEntitlementAvailabilityResponse setSubscriptionEntitlement response.getBodyAsString(), response); } + /** + * Async variant of setSubscriptionEntitlementAvailability for subscriptionEntitlement with + * params. + */ + public CompletableFuture + setSubscriptionEntitlementAvailabilityAsync( + String subscriptionId, SetSubscriptionEntitlementAvailabilityParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/subscription_entitlements/set_availability", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SetSubscriptionEntitlementAvailabilityResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * subscriptionEntitlementsForSubscription a subscriptionEntitlement using immutable params * (executes immediately) - returns raw Response. @@ -165,4 +185,41 @@ public SubscriptionEntitlementsForSubscriptionResponse subscriptionEntitlementsF return SubscriptionEntitlementsForSubscriptionResponse.fromJson( response.getBodyAsString(), this, null, subscriptionId, response); } + + /** + * Async variant of subscriptionEntitlementsForSubscription for subscriptionEntitlement with + * params. + */ + public CompletableFuture + subscriptionEntitlementsForSubscriptionAsync( + String subscriptionId, SubscriptionEntitlementsForSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/subscription_entitlements", + "subscription-id", + subscriptionId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + SubscriptionEntitlementsForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, params, subscriptionId, response)); + } + + /** + * Async variant of subscriptionEntitlementsForSubscription for subscriptionEntitlement without + * params. + */ + public CompletableFuture + subscriptionEntitlementsForSubscriptionAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/subscription_entitlements", + "subscription-id", + subscriptionId); + return getAsync(path, null) + .thenApply( + response -> + SubscriptionEntitlementsForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, null, subscriptionId, response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/SubscriptionService.java b/src/main/java/com/chargebee/v4/services/SubscriptionService.java index 60aeeced..083f7564 100644 --- a/src/main/java/com/chargebee/v4/services/SubscriptionService.java +++ b/src/main/java/com/chargebee/v4/services/SubscriptionService.java @@ -11,6 +11,7 @@ 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.subscription.params.SubscriptionRemoveAdvanceInvoiceScheduleParams; @@ -229,6 +230,22 @@ public SubscriptionRemoveAdvanceInvoiceScheduleResponse removeAdvanceInvoiceSche response.getBodyAsString(), response); } + /** Async variant of removeAdvanceInvoiceSchedule for subscription with params. */ + public CompletableFuture + removeAdvanceInvoiceScheduleAsync( + String subscriptionId, SubscriptionRemoveAdvanceInvoiceScheduleParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/remove_advance_invoice_schedule", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionRemoveAdvanceInvoiceScheduleResponse.fromJson( + response.getBodyAsString(), response)); + } + public SubscriptionRemoveAdvanceInvoiceScheduleResponse removeAdvanceInvoiceSchedule( String subscriptionId) throws ChargebeeException { Response response = removeAdvanceInvoiceScheduleRaw(subscriptionId); @@ -236,6 +253,22 @@ public SubscriptionRemoveAdvanceInvoiceScheduleResponse removeAdvanceInvoiceSche response.getBodyAsString(), response); } + /** Async variant of removeAdvanceInvoiceSchedule for subscription without params. */ + public CompletableFuture + removeAdvanceInvoiceScheduleAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/remove_advance_invoice_schedule", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionRemoveAdvanceInvoiceScheduleResponse.fromJson( + response.getBodyAsString(), response)); + } + /** updateForItems a subscription (executes immediately) - returns raw Response. */ Response updateForItemsRaw(String subscriptionId) throws ChargebeeException { String path = @@ -274,12 +307,37 @@ public SubscriptionUpdateForItemsResponse updateForItems( return SubscriptionUpdateForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateForItems for subscription with params. */ + public CompletableFuture updateForItemsAsync( + String subscriptionId, SubscriptionUpdateForItemsParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/update_for_items", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionUpdateForItemsResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionUpdateForItemsResponse updateForItems(String subscriptionId) throws ChargebeeException { Response response = updateForItemsRaw(subscriptionId); return SubscriptionUpdateForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of updateForItems for subscription without params. */ + public CompletableFuture updateForItemsAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/update_for_items", "subscription-id", subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionUpdateForItemsResponse.fromJson(response.getBodyAsString(), response)); + } + /** removeCoupons a subscription (executes immediately) - returns raw Response. */ Response removeCouponsRaw(String subscriptionId) throws ChargebeeException { String path = @@ -318,12 +376,37 @@ public SubscriptionRemoveCouponsResponse removeCoupons( return SubscriptionRemoveCouponsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeCoupons for subscription with params. */ + public CompletableFuture removeCouponsAsync( + String subscriptionId, SubscriptionRemoveCouponsParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/remove_coupons", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionRemoveCouponsResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionRemoveCouponsResponse removeCoupons(String subscriptionId) throws ChargebeeException { Response response = removeCouponsRaw(subscriptionId); return SubscriptionRemoveCouponsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeCoupons for subscription without params. */ + public CompletableFuture removeCouponsAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/remove_coupons", "subscription-id", subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionRemoveCouponsResponse.fromJson(response.getBodyAsString(), response)); + } + /** resume a subscription (executes immediately) - returns raw Response. */ Response resumeRaw(String subscriptionId) throws ChargebeeException { String path = @@ -356,11 +439,33 @@ public SubscriptionResumeResponse resume(String subscriptionId, SubscriptionResu return SubscriptionResumeResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resume for subscription with params. */ + public CompletableFuture resumeAsync( + String subscriptionId, SubscriptionResumeParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/resume", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> SubscriptionResumeResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionResumeResponse resume(String subscriptionId) throws ChargebeeException { Response response = resumeRaw(subscriptionId); return SubscriptionResumeResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of resume for subscription without params. */ + public CompletableFuture resumeAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/resume", "subscription-id", subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> SubscriptionResumeResponse.fromJson(response.getBodyAsString(), response)); + } + /** cancelForItems a subscription (executes immediately) - returns raw Response. */ Response cancelForItemsRaw(String subscriptionId) throws ChargebeeException { String path = @@ -399,12 +504,37 @@ public SubscriptionCancelForItemsResponse cancelForItems( return SubscriptionCancelForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of cancelForItems for subscription with params. */ + public CompletableFuture cancelForItemsAsync( + String subscriptionId, SubscriptionCancelForItemsParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/cancel_for_items", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionCancelForItemsResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionCancelForItemsResponse cancelForItems(String subscriptionId) throws ChargebeeException { Response response = cancelForItemsRaw(subscriptionId); return SubscriptionCancelForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of cancelForItems for subscription without params. */ + public CompletableFuture cancelForItemsAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/cancel_for_items", "subscription-id", subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionCancelForItemsResponse.fromJson(response.getBodyAsString(), response)); + } + /** regenerateInvoice a subscription (executes immediately) - returns raw Response. */ Response regenerateInvoiceRaw(String subscriptionId) throws ChargebeeException { String path = @@ -450,12 +580,43 @@ public SubscriptionRegenerateInvoiceResponse regenerateInvoice( return SubscriptionRegenerateInvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of regenerateInvoice for subscription with params. */ + public CompletableFuture regenerateInvoiceAsync( + String subscriptionId, SubscriptionRegenerateInvoiceParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/regenerate_invoice", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionRegenerateInvoiceResponse.fromJson( + response.getBodyAsString(), response)); + } + public SubscriptionRegenerateInvoiceResponse regenerateInvoice(String subscriptionId) throws ChargebeeException { Response response = regenerateInvoiceRaw(subscriptionId); return SubscriptionRegenerateInvoiceResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of regenerateInvoice for subscription without params. */ + public CompletableFuture regenerateInvoiceAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/regenerate_invoice", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionRegenerateInvoiceResponse.fromJson( + response.getBodyAsString(), response)); + } + /** list a subscription using immutable params (executes immediately) - returns raw Response. */ Response listRaw(SubscriptionListParams params) throws ChargebeeException { @@ -480,12 +641,32 @@ public SubscriptionListResponse list(SubscriptionListParams params) throws Charg return SubscriptionListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for subscription with params. */ + public CompletableFuture listAsync(SubscriptionListParams params) { + + return getAsync("/subscriptions", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + SubscriptionListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public SubscriptionListResponse list() throws ChargebeeException { Response response = listRaw(); return SubscriptionListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for subscription without params. */ + public CompletableFuture listAsync() { + + return getAsync("/subscriptions", null) + .thenApply( + response -> + SubscriptionListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** create a subscription using immutable params (executes immediately) - returns raw Response. */ Response createRaw(SubscriptionCreateParams params) throws ChargebeeException { @@ -505,6 +686,15 @@ public SubscriptionCreateResponse create(SubscriptionCreateParams params) return SubscriptionCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for subscription with params. */ + public CompletableFuture createAsync( + SubscriptionCreateParams params) { + + return postAsync("/subscriptions", params != null ? params.toFormData() : null) + .thenApply( + response -> SubscriptionCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** move a subscription (executes immediately) - returns raw Response. */ Response moveRaw(String subscriptionId) throws ChargebeeException { String path = @@ -536,6 +726,17 @@ public SubscriptionMoveResponse move(String subscriptionId, SubscriptionMovePara return SubscriptionMoveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of move for subscription with params. */ + public CompletableFuture moveAsync( + String subscriptionId, SubscriptionMoveParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/move", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> SubscriptionMoveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * subscriptionsForCustomer a subscription using immutable params (executes immediately) - returns * raw Response. @@ -582,6 +783,30 @@ public SubscriptionsForCustomerResponse subscriptionsForCustomer(String customer response.getBodyAsString(), this, null, customerId, response); } + /** Async variant of subscriptionsForCustomer for subscription with params. */ + public CompletableFuture subscriptionsForCustomerAsync( + String customerId, SubscriptionsForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/subscriptions", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + SubscriptionsForCustomerResponse.fromJson( + response.getBodyAsString(), this, params, customerId, response)); + } + + /** Async variant of subscriptionsForCustomer for subscription without params. */ + public CompletableFuture subscriptionsForCustomerAsync( + String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/subscriptions", "customer-id", customerId); + return getAsync(path, null) + .thenApply( + response -> + SubscriptionsForCustomerResponse.fromJson( + response.getBodyAsString(), this, null, customerId, response)); + } + /** createForCustomer a subscription (executes immediately) - returns raw Response. */ Response createForCustomerRaw(String customerId) throws ChargebeeException { String path = @@ -617,6 +842,18 @@ public SubscriptionCreateForCustomerResponse createForCustomer( return SubscriptionCreateForCustomerResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createForCustomer for subscription with params. */ + public CompletableFuture createForCustomerAsync( + String customerId, SubscriptionCreateForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/subscriptions", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionCreateForCustomerResponse.fromJson( + response.getBodyAsString(), response)); + } + /** importForItems a subscription (executes immediately) - returns raw Response. */ Response importForItemsRaw(String customerId) throws ChargebeeException { String path = @@ -652,6 +889,17 @@ public SubscriptionImportForItemsResponse importForItems( return SubscriptionImportForItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importForItems for subscription with params. */ + public CompletableFuture importForItemsAsync( + String customerId, SubscriptionImportForItemsParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/import_for_items", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionImportForItemsResponse.fromJson(response.getBodyAsString(), response)); + } + /** * retrieveAdvanceInvoiceSchedule a subscription (executes immediately) - returns raw Response. */ @@ -672,6 +920,22 @@ public SubscriptionRetrieveAdvanceInvoiceScheduleResponse retrieveAdvanceInvoice response.getBodyAsString(), response); } + /** Async variant of retrieveAdvanceInvoiceSchedule for subscription without params. */ + public CompletableFuture + retrieveAdvanceInvoiceScheduleAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/retrieve_advance_invoice_schedule", + "subscription-id", + subscriptionId); + + return getAsync(path, null) + .thenApply( + response -> + SubscriptionRetrieveAdvanceInvoiceScheduleResponse.fromJson( + response.getBodyAsString(), response)); + } + /** removeScheduledCancellation a subscription (executes immediately) - returns raw Response. */ Response removeScheduledCancellationRaw(String subscriptionId) throws ChargebeeException { String path = @@ -720,6 +984,22 @@ public SubscriptionRemoveScheduledCancellationResponse removeScheduledCancellati response.getBodyAsString(), response); } + /** Async variant of removeScheduledCancellation for subscription with params. */ + public CompletableFuture + removeScheduledCancellationAsync( + String subscriptionId, SubscriptionRemoveScheduledCancellationParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/remove_scheduled_cancellation", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionRemoveScheduledCancellationResponse.fromJson( + response.getBodyAsString(), response)); + } + public SubscriptionRemoveScheduledCancellationResponse removeScheduledCancellation( String subscriptionId) throws ChargebeeException { Response response = removeScheduledCancellationRaw(subscriptionId); @@ -727,6 +1007,22 @@ public SubscriptionRemoveScheduledCancellationResponse removeScheduledCancellati response.getBodyAsString(), response); } + /** Async variant of removeScheduledCancellation for subscription without params. */ + public CompletableFuture + removeScheduledCancellationAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/remove_scheduled_cancellation", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionRemoveScheduledCancellationResponse.fromJson( + response.getBodyAsString(), response)); + } + /** retrieveWithScheduledChanges a subscription (executes immediately) - returns raw Response. */ Response retrieveWithScheduledChangesRaw(String subscriptionId) throws ChargebeeException { String path = @@ -745,6 +1041,22 @@ public SubscriptionRetrieveWithScheduledChangesResponse retrieveWithScheduledCha response.getBodyAsString(), response); } + /** Async variant of retrieveWithScheduledChanges for subscription without params. */ + public CompletableFuture + retrieveWithScheduledChangesAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/retrieve_with_scheduled_changes", + "subscription-id", + subscriptionId); + + return getAsync(path, null) + .thenApply( + response -> + SubscriptionRetrieveWithScheduledChangesResponse.fromJson( + response.getBodyAsString(), response)); + } + /** reactivate a subscription (executes immediately) - returns raw Response. */ Response reactivateRaw(String subscriptionId) throws ChargebeeException { String path = @@ -781,12 +1093,36 @@ public SubscriptionReactivateResponse reactivate( return SubscriptionReactivateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of reactivate for subscription with params. */ + public CompletableFuture reactivateAsync( + String subscriptionId, SubscriptionReactivateParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/reactivate", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionReactivateResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionReactivateResponse reactivate(String subscriptionId) throws ChargebeeException { Response response = reactivateRaw(subscriptionId); return SubscriptionReactivateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of reactivate for subscription without params. */ + public CompletableFuture reactivateAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/reactivate", "subscription-id", subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionReactivateResponse.fromJson(response.getBodyAsString(), response)); + } + /** chargeFutureRenewals a subscription (executes immediately) - returns raw Response. */ Response chargeFutureRenewalsRaw(String subscriptionId) throws ChargebeeException { String path = @@ -834,12 +1170,43 @@ public SubscriptionChargeFutureRenewalsResponse chargeFutureRenewals( return SubscriptionChargeFutureRenewalsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of chargeFutureRenewals for subscription with params. */ + public CompletableFuture chargeFutureRenewalsAsync( + String subscriptionId, SubscriptionChargeFutureRenewalsParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/charge_future_renewals", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionChargeFutureRenewalsResponse.fromJson( + response.getBodyAsString(), response)); + } + public SubscriptionChargeFutureRenewalsResponse chargeFutureRenewals(String subscriptionId) throws ChargebeeException { Response response = chargeFutureRenewalsRaw(subscriptionId); return SubscriptionChargeFutureRenewalsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of chargeFutureRenewals for subscription without params. */ + public CompletableFuture chargeFutureRenewalsAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/charge_future_renewals", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionChargeFutureRenewalsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** addChargeAtTermEnd a subscription (executes immediately) - returns raw Response. */ Response addChargeAtTermEndRaw(String subscriptionId) throws ChargebeeException { String path = @@ -886,6 +1253,21 @@ public SubscriptionAddChargeAtTermEndResponse addChargeAtTermEnd( return SubscriptionAddChargeAtTermEndResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of addChargeAtTermEnd for subscription with params. */ + public CompletableFuture addChargeAtTermEndAsync( + String subscriptionId, SubscriptionAddChargeAtTermEndParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/add_charge_at_term_end", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionAddChargeAtTermEndResponse.fromJson( + response.getBodyAsString(), response)); + } + /** removeScheduledChanges a subscription (executes immediately) - returns raw Response. */ Response removeScheduledChangesRaw(String subscriptionId) throws ChargebeeException { String path = @@ -904,6 +1286,22 @@ public SubscriptionRemoveScheduledChangesResponse removeScheduledChanges(String response.getBodyAsString(), response); } + /** Async variant of removeScheduledChanges for subscription without params. */ + public CompletableFuture removeScheduledChangesAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/remove_scheduled_changes", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionRemoveScheduledChangesResponse.fromJson( + response.getBodyAsString(), response)); + } + /** changeTermEnd a subscription (executes immediately) - returns raw Response. */ Response changeTermEndRaw(String subscriptionId) throws ChargebeeException { String path = @@ -942,6 +1340,18 @@ public SubscriptionChangeTermEndResponse changeTermEnd( return SubscriptionChangeTermEndResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of changeTermEnd for subscription with params. */ + public CompletableFuture changeTermEndAsync( + String subscriptionId, SubscriptionChangeTermEndParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/change_term_end", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionChangeTermEndResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a subscription (executes immediately) - returns raw Response. */ Response deleteRaw(String subscriptionId) throws ChargebeeException { String path = @@ -956,6 +1366,17 @@ public SubscriptionDeleteResponse delete(String subscriptionId) throws Chargebee return SubscriptionDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for subscription without params. */ + public CompletableFuture deleteAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/delete", "subscription-id", subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> SubscriptionDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** createWithItems a subscription (executes immediately) - returns raw Response. */ Response createWithItemsRaw(String customerId) throws ChargebeeException { String path = @@ -994,12 +1415,37 @@ public SubscriptionCreateWithItemsResponse createWithItems( return SubscriptionCreateWithItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createWithItems for subscription with params. */ + public CompletableFuture createWithItemsAsync( + String customerId, SubscriptionCreateWithItemsParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/subscription_for_items", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionCreateWithItemsResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionCreateWithItemsResponse createWithItems(String customerId) throws ChargebeeException { Response response = createWithItemsRaw(customerId); return SubscriptionCreateWithItemsResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createWithItems for subscription without params. */ + public CompletableFuture createWithItemsAsync( + String customerId) { + String path = + buildPathWithParams( + "/customers/{customer-id}/subscription_for_items", "customer-id", customerId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionCreateWithItemsResponse.fromJson(response.getBodyAsString(), response)); + } + /** importUnbilledCharges a subscription (executes immediately) - returns raw Response. */ Response importUnbilledChargesRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1047,12 +1493,43 @@ public SubscriptionImportUnbilledChargesResponse importUnbilledCharges( return SubscriptionImportUnbilledChargesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importUnbilledCharges for subscription with params. */ + public CompletableFuture importUnbilledChargesAsync( + String subscriptionId, SubscriptionImportUnbilledChargesParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/import_unbilled_charges", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionImportUnbilledChargesResponse.fromJson( + response.getBodyAsString(), response)); + } + public SubscriptionImportUnbilledChargesResponse importUnbilledCharges(String subscriptionId) throws ChargebeeException { Response response = importUnbilledChargesRaw(subscriptionId); return SubscriptionImportUnbilledChargesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importUnbilledCharges for subscription without params. */ + public CompletableFuture importUnbilledChargesAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/import_unbilled_charges", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionImportUnbilledChargesResponse.fromJson( + response.getBodyAsString(), response)); + } + /** removeScheduledResumption a subscription (executes immediately) - returns raw Response. */ Response removeScheduledResumptionRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1071,6 +1548,22 @@ public SubscriptionRemoveScheduledResumptionResponse removeScheduledResumption( response.getBodyAsString(), response); } + /** Async variant of removeScheduledResumption for subscription without params. */ + public CompletableFuture + removeScheduledResumptionAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/remove_scheduled_resumption", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionRemoveScheduledResumptionResponse.fromJson( + response.getBodyAsString(), response)); + } + /** retrieve a subscription (executes immediately) - returns raw Response. */ Response retrieveRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1084,6 +1577,17 @@ public SubscriptionRetrieveResponse retrieve(String subscriptionId) throws Charg return SubscriptionRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for subscription without params. */ + public CompletableFuture retrieveAsync(String subscriptionId) { + String path = + buildPathWithParams("/subscriptions/{subscription-id}", "subscription-id", subscriptionId); + + return getAsync(path, null) + .thenApply( + response -> + SubscriptionRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a subscription (executes immediately) - returns raw Response. */ Response updateRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1113,11 +1617,31 @@ public SubscriptionUpdateResponse update(String subscriptionId, SubscriptionUpda return SubscriptionUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for subscription with params. */ + public CompletableFuture updateAsync( + String subscriptionId, SubscriptionUpdateParams params) { + String path = + buildPathWithParams("/subscriptions/{subscription-id}", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> SubscriptionUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionUpdateResponse update(String subscriptionId) throws ChargebeeException { Response response = updateRaw(subscriptionId); return SubscriptionUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for subscription without params. */ + public CompletableFuture updateAsync(String subscriptionId) { + String path = + buildPathWithParams("/subscriptions/{subscription-id}", "subscription-id", subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> SubscriptionUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** importContractTerm a subscription (executes immediately) - returns raw Response. */ Response importContractTermRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1164,12 +1688,43 @@ public SubscriptionImportContractTermResponse importContractTerm( return SubscriptionImportContractTermResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importContractTerm for subscription with params. */ + public CompletableFuture importContractTermAsync( + String subscriptionId, SubscriptionImportContractTermParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/import_contract_term", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionImportContractTermResponse.fromJson( + response.getBodyAsString(), response)); + } + public SubscriptionImportContractTermResponse importContractTerm(String subscriptionId) throws ChargebeeException { Response response = importContractTermRaw(subscriptionId); return SubscriptionImportContractTermResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importContractTerm for subscription without params. */ + public CompletableFuture importContractTermAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/import_contract_term", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionImportContractTermResponse.fromJson( + response.getBodyAsString(), response)); + } + /** overrideBillingProfile a subscription (executes immediately) - returns raw Response. */ Response overrideBillingProfileRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1218,6 +1773,21 @@ public SubscriptionOverrideBillingProfileResponse overrideBillingProfile( response.getBodyAsString(), response); } + /** Async variant of overrideBillingProfile for subscription with params. */ + public CompletableFuture overrideBillingProfileAsync( + String subscriptionId, SubscriptionOverrideBillingProfileParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/override_billing_profile", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionOverrideBillingProfileResponse.fromJson( + response.getBodyAsString(), response)); + } + public SubscriptionOverrideBillingProfileResponse overrideBillingProfile(String subscriptionId) throws ChargebeeException { Response response = overrideBillingProfileRaw(subscriptionId); @@ -1225,6 +1795,22 @@ public SubscriptionOverrideBillingProfileResponse overrideBillingProfile(String response.getBodyAsString(), response); } + /** Async variant of overrideBillingProfile for subscription without params. */ + public CompletableFuture overrideBillingProfileAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/override_billing_profile", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionOverrideBillingProfileResponse.fromJson( + response.getBodyAsString(), response)); + } + /** removeScheduledPause a subscription (executes immediately) - returns raw Response. */ Response removeScheduledPauseRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1242,6 +1828,22 @@ public SubscriptionRemoveScheduledPauseResponse removeScheduledPause(String subs return SubscriptionRemoveScheduledPauseResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of removeScheduledPause for subscription without params. */ + public CompletableFuture removeScheduledPauseAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/remove_scheduled_pause", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionRemoveScheduledPauseResponse.fromJson( + response.getBodyAsString(), response)); + } + /** editAdvanceInvoiceSchedule a subscription (executes immediately) - returns raw Response. */ Response editAdvanceInvoiceScheduleRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1290,6 +1892,22 @@ public SubscriptionEditAdvanceInvoiceScheduleResponse editAdvanceInvoiceSchedule response.getBodyAsString(), response); } + /** Async variant of editAdvanceInvoiceSchedule for subscription with params. */ + public CompletableFuture + editAdvanceInvoiceScheduleAsync( + String subscriptionId, SubscriptionEditAdvanceInvoiceScheduleParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/edit_advance_invoice_schedule", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionEditAdvanceInvoiceScheduleResponse.fromJson( + response.getBodyAsString(), response)); + } + public SubscriptionEditAdvanceInvoiceScheduleResponse editAdvanceInvoiceSchedule( String subscriptionId) throws ChargebeeException { Response response = editAdvanceInvoiceScheduleRaw(subscriptionId); @@ -1297,6 +1915,22 @@ public SubscriptionEditAdvanceInvoiceScheduleResponse editAdvanceInvoiceSchedule response.getBodyAsString(), response); } + /** Async variant of editAdvanceInvoiceSchedule for subscription without params. */ + public CompletableFuture + editAdvanceInvoiceScheduleAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/edit_advance_invoice_schedule", + "subscription-id", + subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> + SubscriptionEditAdvanceInvoiceScheduleResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * listDiscounts a subscription using immutable params (executes immediately) - returns raw * Response. @@ -1342,6 +1976,32 @@ public SubscriptionListDiscountsResponse listDiscounts(String subscriptionId) response.getBodyAsString(), this, null, subscriptionId, response); } + /** Async variant of listDiscounts for subscription with params. */ + public CompletableFuture listDiscountsAsync( + String subscriptionId, SubscriptionListDiscountsParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/discounts", "subscription-id", subscriptionId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + SubscriptionListDiscountsResponse.fromJson( + response.getBodyAsString(), this, params, subscriptionId, response)); + } + + /** Async variant of listDiscounts for subscription without params. */ + public CompletableFuture listDiscountsAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/discounts", "subscription-id", subscriptionId); + return getAsync(path, null) + .thenApply( + response -> + SubscriptionListDiscountsResponse.fromJson( + response.getBodyAsString(), this, null, subscriptionId, response)); + } + /** * contractTermsForSubscription a subscription using immutable params (executes immediately) - * returns raw Response. @@ -1391,6 +2051,32 @@ public ContractTermsForSubscriptionResponse contractTermsForSubscription(String response.getBodyAsString(), this, null, subscriptionId, response); } + /** Async variant of contractTermsForSubscription for subscription with params. */ + public CompletableFuture contractTermsForSubscriptionAsync( + String subscriptionId, ContractTermsForSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/contract_terms", "subscription-id", subscriptionId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ContractTermsForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, params, subscriptionId, response)); + } + + /** Async variant of contractTermsForSubscription for subscription without params. */ + public CompletableFuture contractTermsForSubscriptionAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/contract_terms", "subscription-id", subscriptionId); + return getAsync(path, null) + .thenApply( + response -> + ContractTermsForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, null, subscriptionId, response)); + } + /** pause a subscription (executes immediately) - returns raw Response. */ Response pauseRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1423,11 +2109,33 @@ public SubscriptionPauseResponse pause(String subscriptionId, SubscriptionPauseP return SubscriptionPauseResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pause for subscription with params. */ + public CompletableFuture pauseAsync( + String subscriptionId, SubscriptionPauseParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/pause", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> SubscriptionPauseResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionPauseResponse pause(String subscriptionId) throws ChargebeeException { Response response = pauseRaw(subscriptionId); return SubscriptionPauseResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pause for subscription without params. */ + public CompletableFuture pauseAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/pause", "subscription-id", subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> SubscriptionPauseResponse.fromJson(response.getBodyAsString(), response)); + } + /** importForCustomer a subscription (executes immediately) - returns raw Response. */ Response importForCustomerRaw(String customerId) throws ChargebeeException { String path = @@ -1466,6 +2174,19 @@ public SubscriptionImportForCustomerResponse importForCustomer( return SubscriptionImportForCustomerResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importForCustomer for subscription with params. */ + public CompletableFuture importForCustomerAsync( + String customerId, SubscriptionImportForCustomerParams params) { + String path = + buildPathWithParams( + "/customers/{customer-id}/import_subscription", "customer-id", customerId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionImportForCustomerResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * importSubscription a subscription using immutable params (executes immediately) - returns raw * Response. @@ -1491,6 +2212,16 @@ public ImportSubscriptionResponse importSubscription(ImportSubscriptionParams pa return ImportSubscriptionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of importSubscription for subscription with params. */ + public CompletableFuture importSubscriptionAsync( + ImportSubscriptionParams params) { + + return postAsync( + "/subscriptions/import_subscription", params != null ? params.toFormData() : null) + .thenApply( + response -> ImportSubscriptionResponse.fromJson(response.getBodyAsString(), response)); + } + /** cancel a subscription (executes immediately) - returns raw Response. */ Response cancelRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1523,11 +2254,33 @@ public SubscriptionCancelResponse cancel(String subscriptionId, SubscriptionCanc return SubscriptionCancelResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of cancel for subscription with params. */ + public CompletableFuture cancelAsync( + String subscriptionId, SubscriptionCancelParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/cancel", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> SubscriptionCancelResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionCancelResponse cancel(String subscriptionId) throws ChargebeeException { Response response = cancelRaw(subscriptionId); return SubscriptionCancelResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of cancel for subscription without params. */ + public CompletableFuture cancelAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/cancel", "subscription-id", subscriptionId); + + return postAsync(path, null) + .thenApply( + response -> SubscriptionCancelResponse.fromJson(response.getBodyAsString(), response)); + } + /** chargeAddonAtTermEnd a subscription (executes immediately) - returns raw Response. */ Response chargeAddonAtTermEndRaw(String subscriptionId) throws ChargebeeException { String path = @@ -1574,4 +2327,19 @@ public SubscriptionChargeAddonAtTermEndResponse chargeAddonAtTermEnd( Response response = chargeAddonAtTermEndRaw(subscriptionId, params); return SubscriptionChargeAddonAtTermEndResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of chargeAddonAtTermEnd for subscription with params. */ + public CompletableFuture chargeAddonAtTermEndAsync( + String subscriptionId, SubscriptionChargeAddonAtTermEndParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/charge_addon_at_term_end", + "subscription-id", + subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + SubscriptionChargeAddonAtTermEndResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/SubscriptionSettingService.java b/src/main/java/com/chargebee/v4/services/SubscriptionSettingService.java index 0649cf3d..05922cf0 100644 --- a/src/main/java/com/chargebee/v4/services/SubscriptionSettingService.java +++ b/src/main/java/com/chargebee/v4/services/SubscriptionSettingService.java @@ -11,6 +11,7 @@ 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.subscriptionSetting.params.SubscriptionSettingRetrieveParams; @@ -84,9 +85,29 @@ public SubscriptionSettingRetrieveResponse retrieve(SubscriptionSettingRetrieveP return SubscriptionSettingRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for subscriptionSetting with params. */ + public CompletableFuture retrieveAsync( + SubscriptionSettingRetrieveParams params) { + + return getAsync( + "/subscription_settings/retrieve", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + SubscriptionSettingRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + public SubscriptionSettingRetrieveResponse retrieve() throws ChargebeeException { Response response = retrieveRaw(); return SubscriptionSettingRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for subscriptionSetting without params. */ + public CompletableFuture retrieveAsync() { + + return getAsync("/subscription_settings/retrieve", null) + .thenApply( + response -> + SubscriptionSettingRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ThirdPartyConfigurationService.java b/src/main/java/com/chargebee/v4/services/ThirdPartyConfigurationService.java index 46882176..22ec1b12 100644 --- a/src/main/java/com/chargebee/v4/services/ThirdPartyConfigurationService.java +++ b/src/main/java/com/chargebee/v4/services/ThirdPartyConfigurationService.java @@ -11,6 +11,7 @@ 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.thirdPartyConfiguration.params.ThirdPartyConfigurationConfigurationsParams; @@ -89,6 +90,19 @@ public ThirdPartyConfigurationConfigurationsResponse configurations( response.getBodyAsString(), response); } + /** Async variant of configurations for thirdPartyConfiguration with params. */ + public CompletableFuture configurationsAsync( + ThirdPartyConfigurationConfigurationsParams params) { + + return getAsync( + "/third_party_configurations/configurations", + params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ThirdPartyConfigurationConfigurationsResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * retrieve a thirdPartyConfiguration using immutable params (executes immediately) - returns raw * Response. @@ -114,6 +128,17 @@ public ThirdPartyConfigurationRetrieveResponse retrieve( return ThirdPartyConfigurationRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for thirdPartyConfiguration with params. */ + public CompletableFuture retrieveAsync( + ThirdPartyConfigurationRetrieveParams params) { + + return getAsync("/third_party_configurations", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ThirdPartyConfigurationRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * update a thirdPartyConfiguration using immutable params (executes immediately) - returns raw * Response. @@ -138,4 +163,15 @@ public ThirdPartyConfigurationUpdateResponse update(ThirdPartyConfigurationUpdat return ThirdPartyConfigurationUpdateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of update for thirdPartyConfiguration with params. */ + public CompletableFuture updateAsync( + ThirdPartyConfigurationUpdateParams params) { + + return postAsync("/third_party_configurations", params != null ? params.toFormData() : null) + .thenApply( + response -> + ThirdPartyConfigurationUpdateResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ThirdPartyEntityMappingService.java b/src/main/java/com/chargebee/v4/services/ThirdPartyEntityMappingService.java index add15861..983d6bdc 100644 --- a/src/main/java/com/chargebee/v4/services/ThirdPartyEntityMappingService.java +++ b/src/main/java/com/chargebee/v4/services/ThirdPartyEntityMappingService.java @@ -11,6 +11,7 @@ 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.thirdPartyEntityMapping.params.ThirdPartyEntityMappingRetrieveEntityParams; @@ -92,6 +93,18 @@ public ThirdPartyEntityMappingRetrieveEntityResponse retrieveEntity( response.getBodyAsString(), response); } + /** Async variant of retrieveEntity for thirdPartyEntityMapping with params. */ + public CompletableFuture retrieveEntityAsync( + ThirdPartyEntityMappingRetrieveEntityParams params) { + + return getAsync( + "/third_party_entity_mappings/retrieve", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ThirdPartyEntityMappingRetrieveEntityResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * listAll a thirdPartyEntityMapping using immutable params (executes immediately) - returns raw * Response. @@ -118,6 +131,18 @@ public ThirdPartyEntityMappingListAllResponse listAll(ThirdPartyEntityMappingLis return ThirdPartyEntityMappingListAllResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of listAll for thirdPartyEntityMapping with params. */ + public CompletableFuture listAllAsync( + ThirdPartyEntityMappingListAllParams params) { + + return getAsync( + "/third_party_entity_mappings/list_all", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ThirdPartyEntityMappingListAllResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * updateEntity a thirdPartyEntityMapping using immutable params (executes immediately) - returns * raw Response. @@ -146,6 +171,19 @@ public ThirdPartyEntityMappingUpdateEntityResponse updateEntity( response.getBodyAsString(), response); } + /** Async variant of updateEntity for thirdPartyEntityMapping with params. */ + public CompletableFuture updateEntityAsync( + ThirdPartyEntityMappingUpdateEntityParams params) { + + return postAsync( + "/third_party_entity_mappings/update_entity", + params != null ? params.toFormData() : null) + .thenApply( + response -> + ThirdPartyEntityMappingUpdateEntityResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * list a thirdPartyEntityMapping using immutable params (executes immediately) - returns raw * Response. @@ -180,10 +218,31 @@ public ThirdPartyEntityMappingListResponse list(ThirdPartyEntityMappingListParam response.getBodyAsString(), this, params, response); } + /** Async variant of list for thirdPartyEntityMapping with params. */ + public CompletableFuture listAsync( + ThirdPartyEntityMappingListParams params) { + + return getAsync("/third_party_entity_mappings", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ThirdPartyEntityMappingListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public ThirdPartyEntityMappingListResponse list() throws ChargebeeException { Response response = listRaw(); return ThirdPartyEntityMappingListResponse.fromJson( response.getBodyAsString(), this, null, response); } + + /** Async variant of list for thirdPartyEntityMapping without params. */ + public CompletableFuture listAsync() { + + return getAsync("/third_party_entity_mappings", null) + .thenApply( + response -> + ThirdPartyEntityMappingListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/ThirdPartySyncDetailService.java b/src/main/java/com/chargebee/v4/services/ThirdPartySyncDetailService.java index c76bda07..e1b4ff6f 100644 --- a/src/main/java/com/chargebee/v4/services/ThirdPartySyncDetailService.java +++ b/src/main/java/com/chargebee/v4/services/ThirdPartySyncDetailService.java @@ -11,6 +11,7 @@ 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.thirdPartySyncDetail.params.ThirdPartySyncDetailUpdateParams; @@ -78,6 +79,22 @@ public ThirdPartySyncDetailRetrieveResponse retrieve(String tpIntegSyncDetailId) return ThirdPartySyncDetailRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for thirdPartySyncDetail without params. */ + public CompletableFuture retrieveAsync( + String tpIntegSyncDetailId) { + String path = + buildPathWithParams( + "/third_party_sync_details/{tp-integ-sync-detail-id}", + "tp-integ-sync-detail-id", + tpIntegSyncDetailId); + + return getAsync(path, null) + .thenApply( + response -> + ThirdPartySyncDetailRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } + /** update a thirdPartySyncDetail (executes immediately) - returns raw Response. */ Response updateRaw(String tpIntegSyncDetailId) throws ChargebeeException { String path = @@ -123,6 +140,20 @@ public ThirdPartySyncDetailUpdateResponse update( return ThirdPartySyncDetailUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for thirdPartySyncDetail with params. */ + public CompletableFuture updateAsync( + String tpIntegSyncDetailId, ThirdPartySyncDetailUpdateParams params) { + String path = + buildPathWithParams( + "/third_party_sync_details/{tp-integ-sync-detail-id}", + "tp-integ-sync-detail-id", + tpIntegSyncDetailId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + ThirdPartySyncDetailUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * create a thirdPartySyncDetail using immutable params (executes immediately) - returns raw * Response. @@ -148,6 +179,16 @@ public ThirdPartySyncDetailCreateResponse create(ThirdPartySyncDetailCreateParam return ThirdPartySyncDetailCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for thirdPartySyncDetail with params. */ + public CompletableFuture createAsync( + ThirdPartySyncDetailCreateParams params) { + + return postAsync("/third_party_sync_details", params != null ? params.toFormData() : null) + .thenApply( + response -> + ThirdPartySyncDetailCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * retrieveLatestSync a thirdPartySyncDetail using immutable params (executes immediately) - * returns raw Response. @@ -186,6 +227,19 @@ public ThirdPartySyncDetailRetrieveLatestSyncResponse retrieveLatestSync( response.getBodyAsString(), response); } + /** Async variant of retrieveLatestSync for thirdPartySyncDetail with params. */ + public CompletableFuture retrieveLatestSyncAsync( + ThirdPartySyncDetailRetrieveLatestSyncParams params) { + + return getAsync( + "/third_party_sync_details/retrieve_latest_sync", + params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ThirdPartySyncDetailRetrieveLatestSyncResponse.fromJson( + response.getBodyAsString(), response)); + } + public ThirdPartySyncDetailRetrieveLatestSyncResponse retrieveLatestSync() throws ChargebeeException { Response response = retrieveLatestSyncRaw(); @@ -193,4 +247,15 @@ public ThirdPartySyncDetailRetrieveLatestSyncResponse retrieveLatestSync() return ThirdPartySyncDetailRetrieveLatestSyncResponse.fromJson( response.getBodyAsString(), response); } + + /** Async variant of retrieveLatestSync for thirdPartySyncDetail without params. */ + public CompletableFuture + retrieveLatestSyncAsync() { + + return getAsync("/third_party_sync_details/retrieve_latest_sync", null) + .thenApply( + response -> + ThirdPartySyncDetailRetrieveLatestSyncResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/TimeMachineService.java b/src/main/java/com/chargebee/v4/services/TimeMachineService.java index 9c05e302..13cc8ad9 100644 --- a/src/main/java/com/chargebee/v4/services/TimeMachineService.java +++ b/src/main/java/com/chargebee/v4/services/TimeMachineService.java @@ -11,6 +11,7 @@ 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.timeMachine.params.TimeMachineTravelForwardParams; @@ -76,6 +77,17 @@ public TimeMachineRetrieveResponse retrieve(String timeMachineName) throws Charg return TimeMachineRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for timeMachine without params. */ + public CompletableFuture retrieveAsync(String timeMachineName) { + String path = + buildPathWithParams( + "/time_machines/{time-machine-name}", "time-machine-name", timeMachineName); + + return getAsync(path, null) + .thenApply( + response -> TimeMachineRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** travelForward a timeMachine (executes immediately) - returns raw Response. */ Response travelForwardRaw(String timeMachineName) throws ChargebeeException { String path = @@ -120,12 +132,41 @@ public TimeMachineTravelForwardResponse travelForward( return TimeMachineTravelForwardResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of travelForward for timeMachine with params. */ + public CompletableFuture travelForwardAsync( + String timeMachineName, TimeMachineTravelForwardParams params) { + String path = + buildPathWithParams( + "/time_machines/{time-machine-name}/travel_forward", + "time-machine-name", + timeMachineName); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + TimeMachineTravelForwardResponse.fromJson(response.getBodyAsString(), response)); + } + public TimeMachineTravelForwardResponse travelForward(String timeMachineName) throws ChargebeeException { Response response = travelForwardRaw(timeMachineName); return TimeMachineTravelForwardResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of travelForward for timeMachine without params. */ + public CompletableFuture travelForwardAsync( + String timeMachineName) { + String path = + buildPathWithParams( + "/time_machines/{time-machine-name}/travel_forward", + "time-machine-name", + timeMachineName); + + return postAsync(path, null) + .thenApply( + response -> + TimeMachineTravelForwardResponse.fromJson(response.getBodyAsString(), response)); + } + /** startAfresh a timeMachine (executes immediately) - returns raw Response. */ Response startAfreshRaw(String timeMachineName) throws ChargebeeException { String path = @@ -168,12 +209,41 @@ public TimeMachineStartAfreshResponse startAfresh( return TimeMachineStartAfreshResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of startAfresh for timeMachine with params. */ + public CompletableFuture startAfreshAsync( + String timeMachineName, TimeMachineStartAfreshParams params) { + String path = + buildPathWithParams( + "/time_machines/{time-machine-name}/start_afresh", + "time-machine-name", + timeMachineName); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + TimeMachineStartAfreshResponse.fromJson(response.getBodyAsString(), response)); + } + public TimeMachineStartAfreshResponse startAfresh(String timeMachineName) throws ChargebeeException { Response response = startAfreshRaw(timeMachineName); return TimeMachineStartAfreshResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of startAfresh for timeMachine without params. */ + public CompletableFuture startAfreshAsync( + String timeMachineName) { + String path = + buildPathWithParams( + "/time_machines/{time-machine-name}/start_afresh", + "time-machine-name", + timeMachineName); + + return postAsync(path, null) + .thenApply( + response -> + TimeMachineStartAfreshResponse.fromJson(response.getBodyAsString(), response)); + } + // === Time Travel Completion Helper === /** diff --git a/src/main/java/com/chargebee/v4/services/TpSiteUserService.java b/src/main/java/com/chargebee/v4/services/TpSiteUserService.java index 03c77958..4630c1b5 100644 --- a/src/main/java/com/chargebee/v4/services/TpSiteUserService.java +++ b/src/main/java/com/chargebee/v4/services/TpSiteUserService.java @@ -11,6 +11,7 @@ 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.tpSiteUser.params.UsersForTpSiteUserParams; @@ -106,6 +107,32 @@ public UsersForTpSiteUserResponse usersForTpSiteUser(String tpSiteUserDomain) response.getBodyAsString(), this, null, tpSiteUserDomain, response); } + /** Async variant of usersForTpSiteUser for tpSiteUser with params. */ + public CompletableFuture usersForTpSiteUserAsync( + String tpSiteUserDomain, UsersForTpSiteUserParams params) { + String path = + buildPathWithParams( + "/tp_site_users/{tp-site-user-domain}/users", "tp-site-user-domain", tpSiteUserDomain); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + UsersForTpSiteUserResponse.fromJson( + response.getBodyAsString(), this, params, tpSiteUserDomain, response)); + } + + /** Async variant of usersForTpSiteUser for tpSiteUser without params. */ + public CompletableFuture usersForTpSiteUserAsync( + String tpSiteUserDomain) { + String path = + buildPathWithParams( + "/tp_site_users/{tp-site-user-domain}/users", "tp-site-user-domain", tpSiteUserDomain); + return getAsync(path, null) + .thenApply( + response -> + UsersForTpSiteUserResponse.fromJson( + response.getBodyAsString(), this, null, tpSiteUserDomain, response)); + } + /** * payNowEnableLive a tpSiteUser using immutable params (executes immediately) - returns raw * Response. @@ -131,6 +158,17 @@ public TpSiteUserPayNowEnableLiveResponse payNowEnableLive( return TpSiteUserPayNowEnableLiveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of payNowEnableLive for tpSiteUser with params. */ + public CompletableFuture payNowEnableLiveAsync( + TpSiteUserPayNowEnableLiveParams params) { + + return postAsync( + "/tp_site_users/pay_now_enable_live", params != null ? params.toFormData() : null) + .thenApply( + response -> + TpSiteUserPayNowEnableLiveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * guestsForTpSiteUser a tpSiteUser using immutable params (executes immediately) - returns raw * Response. @@ -178,4 +216,30 @@ public GuestsForTpSiteUserResponse guestsForTpSiteUser(String tpSiteUserDomain) return GuestsForTpSiteUserResponse.fromJson( response.getBodyAsString(), this, null, tpSiteUserDomain, response); } + + /** Async variant of guestsForTpSiteUser for tpSiteUser with params. */ + public CompletableFuture guestsForTpSiteUserAsync( + String tpSiteUserDomain, GuestsForTpSiteUserParams params) { + String path = + buildPathWithParams( + "/tp_site_users/{tp-site-user-domain}/guests", "tp-site-user-domain", tpSiteUserDomain); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + GuestsForTpSiteUserResponse.fromJson( + response.getBodyAsString(), this, params, tpSiteUserDomain, response)); + } + + /** Async variant of guestsForTpSiteUser for tpSiteUser without params. */ + public CompletableFuture guestsForTpSiteUserAsync( + String tpSiteUserDomain) { + String path = + buildPathWithParams( + "/tp_site_users/{tp-site-user-domain}/guests", "tp-site-user-domain", tpSiteUserDomain); + return getAsync(path, null) + .thenApply( + response -> + GuestsForTpSiteUserResponse.fromJson( + response.getBodyAsString(), this, null, tpSiteUserDomain, response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/TransactionService.java b/src/main/java/com/chargebee/v4/services/TransactionService.java index 8642caf9..42d48923 100644 --- a/src/main/java/com/chargebee/v4/services/TransactionService.java +++ b/src/main/java/com/chargebee/v4/services/TransactionService.java @@ -11,6 +11,7 @@ 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.transaction.params.TransactionListParams; @@ -112,12 +113,31 @@ public TransactionListResponse list(TransactionListParams params) throws Chargeb return TransactionListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for transaction with params. */ + public CompletableFuture listAsync(TransactionListParams params) { + + return getAsync("/transactions", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + TransactionListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public TransactionListResponse list() throws ChargebeeException { Response response = listRaw(); return TransactionListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for transaction without params. */ + public CompletableFuture listAsync() { + + return getAsync("/transactions", null) + .thenApply( + response -> + TransactionListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } + /** reconcile a transaction (executes immediately) - returns raw Response. */ Response reconcileRaw(String transactionId) throws ChargebeeException { String path = @@ -154,11 +174,35 @@ public TransactionReconcileResponse reconcile( return TransactionReconcileResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of reconcile for transaction with params. */ + public CompletableFuture reconcileAsync( + String transactionId, TransactionReconcileParams params) { + String path = + buildPathWithParams( + "/transactions/{transaction-id}/reconcile", "transaction-id", transactionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + TransactionReconcileResponse.fromJson(response.getBodyAsString(), response)); + } + public TransactionReconcileResponse reconcile(String transactionId) throws ChargebeeException { Response response = reconcileRaw(transactionId); return TransactionReconcileResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of reconcile for transaction without params. */ + public CompletableFuture reconcileAsync(String transactionId) { + String path = + buildPathWithParams( + "/transactions/{transaction-id}/reconcile", "transaction-id", transactionId); + + return postAsync(path, null) + .thenApply( + response -> + TransactionReconcileResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a transaction (executes immediately) - returns raw Response. */ Response retrieveRaw(String transactionId) throws ChargebeeException { String path = @@ -172,6 +216,16 @@ public TransactionRetrieveResponse retrieve(String transactionId) throws Chargeb return TransactionRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for transaction without params. */ + public CompletableFuture retrieveAsync(String transactionId) { + String path = + buildPathWithParams("/transactions/{transaction-id}", "transaction-id", transactionId); + + return getAsync(path, null) + .thenApply( + response -> TransactionRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** refund a transaction (executes immediately) - returns raw Response. */ Response refundRaw(String transactionId) throws ChargebeeException { String path = @@ -204,11 +258,33 @@ public TransactionRefundResponse refund(String transactionId, TransactionRefundP return TransactionRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of refund for transaction with params. */ + public CompletableFuture refundAsync( + String transactionId, TransactionRefundParams params) { + String path = + buildPathWithParams( + "/transactions/{transaction-id}/refund", "transaction-id", transactionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> TransactionRefundResponse.fromJson(response.getBodyAsString(), response)); + } + public TransactionRefundResponse refund(String transactionId) throws ChargebeeException { Response response = refundRaw(transactionId); return TransactionRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of refund for transaction without params. */ + public CompletableFuture refundAsync(String transactionId) { + String path = + buildPathWithParams( + "/transactions/{transaction-id}/refund", "transaction-id", transactionId); + + return postAsync(path, null) + .thenApply( + response -> TransactionRefundResponse.fromJson(response.getBodyAsString(), response)); + } + /** * transactionsForCustomer a transaction using immutable params (executes immediately) - returns * raw Response. @@ -255,6 +331,30 @@ public TransactionsForCustomerResponse transactionsForCustomer(String customerId response.getBodyAsString(), this, null, customerId, response); } + /** Async variant of transactionsForCustomer for transaction with params. */ + public CompletableFuture transactionsForCustomerAsync( + String customerId, TransactionsForCustomerParams params) { + String path = + buildPathWithParams("/customers/{customer-id}/transactions", "customer-id", customerId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + TransactionsForCustomerResponse.fromJson( + response.getBodyAsString(), this, params, customerId, response)); + } + + /** Async variant of transactionsForCustomer for transaction without params. */ + public CompletableFuture transactionsForCustomerAsync( + String customerId) { + String path = + buildPathWithParams("/customers/{customer-id}/transactions", "customer-id", customerId); + return getAsync(path, null) + .thenApply( + response -> + TransactionsForCustomerResponse.fromJson( + response.getBodyAsString(), this, null, customerId, response)); + } + /** recordRefund a transaction (executes immediately) - returns raw Response. */ Response recordRefundRaw(String transactionId) throws ChargebeeException { String path = @@ -293,6 +393,18 @@ public TransactionRecordRefundResponse recordRefund( return TransactionRecordRefundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of recordRefund for transaction with params. */ + public CompletableFuture recordRefundAsync( + String transactionId, TransactionRecordRefundParams params) { + String path = + buildPathWithParams( + "/transactions/{transaction-id}/record_refund", "transaction-id", transactionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + TransactionRecordRefundResponse.fromJson(response.getBodyAsString(), response)); + } + /** * transactionsForSubscription a transaction using immutable params (executes immediately) - * returns raw Response. @@ -342,6 +454,32 @@ public TransactionsForSubscriptionResponse transactionsForSubscription(String su response.getBodyAsString(), this, null, subscriptionId, response); } + /** Async variant of transactionsForSubscription for transaction with params. */ + public CompletableFuture transactionsForSubscriptionAsync( + String subscriptionId, TransactionsForSubscriptionParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/transactions", "subscription-id", subscriptionId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + TransactionsForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, params, subscriptionId, response)); + } + + /** Async variant of transactionsForSubscription for transaction without params. */ + public CompletableFuture transactionsForSubscriptionAsync( + String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/transactions", "subscription-id", subscriptionId); + return getAsync(path, null) + .thenApply( + response -> + TransactionsForSubscriptionResponse.fromJson( + response.getBodyAsString(), this, null, subscriptionId, response)); + } + /** voidTransaction a transaction (executes immediately) - returns raw Response. */ Response voidTransactionRaw(String transactionId) throws ChargebeeException { String path = @@ -355,6 +493,16 @@ public VoidTransactionResponse voidTransaction(String transactionId) throws Char return VoidTransactionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of voidTransaction for transaction without params. */ + public CompletableFuture voidTransactionAsync(String transactionId) { + String path = + buildPathWithParams("/transactions/{transaction-id}/void", "transaction-id", transactionId); + + return postAsync(path, null) + .thenApply( + response -> VoidTransactionResponse.fromJson(response.getBodyAsString(), response)); + } + /** syncTransaction a transaction (executes immediately) - returns raw Response. */ Response syncTransactionRaw(String transactionId) throws ChargebeeException { String path = @@ -368,6 +516,16 @@ public SyncTransactionResponse syncTransaction(String transactionId) throws Char return SyncTransactionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of syncTransaction for transaction without params. */ + public CompletableFuture syncTransactionAsync(String transactionId) { + String path = + buildPathWithParams("/transactions/{transaction-id}/sync", "transaction-id", transactionId); + + return postAsync(path, null) + .thenApply( + response -> SyncTransactionResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createAuthorization a transaction using immutable params (executes immediately) - returns raw * Response. @@ -394,6 +552,18 @@ public TransactionCreateAuthorizationResponse createAuthorization( return TransactionCreateAuthorizationResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createAuthorization for transaction with params. */ + public CompletableFuture createAuthorizationAsync( + TransactionCreateAuthorizationParams params) { + + return postAsync( + "/transactions/create_authorization", params != null ? params.toFormData() : null) + .thenApply( + response -> + TransactionCreateAuthorizationResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * paymentsForInvoice a transaction using immutable params (executes immediately) - returns raw * Response. @@ -435,6 +605,28 @@ public TransactionPaymentsForInvoiceResponse paymentsForInvoice(String invoiceId response.getBodyAsString(), this, null, invoiceId, response); } + /** Async variant of paymentsForInvoice for transaction with params. */ + public CompletableFuture paymentsForInvoiceAsync( + String invoiceId, TransactionPaymentsForInvoiceParams params) { + String path = buildPathWithParams("/invoices/{invoice-id}/payments", "invoice-id", invoiceId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + TransactionPaymentsForInvoiceResponse.fromJson( + response.getBodyAsString(), this, params, invoiceId, response)); + } + + /** Async variant of paymentsForInvoice for transaction without params. */ + public CompletableFuture paymentsForInvoiceAsync( + String invoiceId) { + String path = buildPathWithParams("/invoices/{invoice-id}/payments", "invoice-id", invoiceId); + return getAsync(path, null) + .thenApply( + response -> + TransactionPaymentsForInvoiceResponse.fromJson( + response.getBodyAsString(), this, null, invoiceId, response)); + } + /** deleteOfflineTransaction a transaction (executes immediately) - returns raw Response. */ Response deleteOfflineTransactionRaw(String transactionId) throws ChargebeeException { String path = @@ -480,9 +672,38 @@ public DeleteOfflineTransactionResponse deleteOfflineTransaction( return DeleteOfflineTransactionResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteOfflineTransaction for transaction with params. */ + public CompletableFuture deleteOfflineTransactionAsync( + String transactionId, DeleteOfflineTransactionParams params) { + String path = + buildPathWithParams( + "/transactions/{transaction-id}/delete_offline_transaction", + "transaction-id", + transactionId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + DeleteOfflineTransactionResponse.fromJson(response.getBodyAsString(), response)); + } + public DeleteOfflineTransactionResponse deleteOfflineTransaction(String transactionId) throws ChargebeeException { Response response = deleteOfflineTransactionRaw(transactionId); return DeleteOfflineTransactionResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of deleteOfflineTransaction for transaction without params. */ + public CompletableFuture deleteOfflineTransactionAsync( + String transactionId) { + String path = + buildPathWithParams( + "/transactions/{transaction-id}/delete_offline_transaction", + "transaction-id", + transactionId); + + return postAsync(path, null) + .thenApply( + response -> + DeleteOfflineTransactionResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/UnbilledChargeService.java b/src/main/java/com/chargebee/v4/services/UnbilledChargeService.java index 3d294cd5..17eb874a 100644 --- a/src/main/java/com/chargebee/v4/services/UnbilledChargeService.java +++ b/src/main/java/com/chargebee/v4/services/UnbilledChargeService.java @@ -11,6 +11,7 @@ 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.unbilledCharge.params.UnbilledChargeInvoiceNowEstimateParams; @@ -85,6 +86,20 @@ public UnbilledChargeDeleteResponse delete(String unbilledChargeId) throws Charg return UnbilledChargeDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for unbilledCharge without params. */ + public CompletableFuture deleteAsync(String unbilledChargeId) { + String path = + buildPathWithParams( + "/unbilled_charges/{unbilled-charge-id}/delete", + "unbilled-charge-id", + unbilledChargeId); + + return postAsync(path, null) + .thenApply( + response -> + UnbilledChargeDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * invoiceNowEstimate a unbilledCharge using immutable params (executes immediately) - returns raw * Response. @@ -112,6 +127,18 @@ public UnbilledChargeInvoiceNowEstimateResponse invoiceNowEstimate( return UnbilledChargeInvoiceNowEstimateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of invoiceNowEstimate for unbilledCharge with params. */ + public CompletableFuture invoiceNowEstimateAsync( + UnbilledChargeInvoiceNowEstimateParams params) { + + return postAsync( + "/unbilled_charges/invoice_now_estimate", params != null ? params.toFormData() : null) + .thenApply( + response -> + UnbilledChargeInvoiceNowEstimateResponse.fromJson( + response.getBodyAsString(), response)); + } + /** * invoiceUnbilledCharges a unbilledCharge using immutable params (executes immediately) - returns * raw Response. @@ -139,6 +166,18 @@ public InvoiceUnbilledChargesResponse invoiceUnbilledCharges(InvoiceUnbilledChar return InvoiceUnbilledChargesResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of invoiceUnbilledCharges for unbilledCharge with params. */ + public CompletableFuture invoiceUnbilledChargesAsync( + InvoiceUnbilledChargesParams params) { + + return postAsync( + "/unbilled_charges/invoice_unbilled_charges", + params != null ? params.toFormData() : null) + .thenApply( + response -> + InvoiceUnbilledChargesResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a unbilledCharge using immutable params (executes immediately) - returns raw Response. */ Response listRaw(UnbilledChargeListParams params) throws ChargebeeException { @@ -164,12 +203,32 @@ public UnbilledChargeListResponse list(UnbilledChargeListParams params) return UnbilledChargeListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for unbilledCharge with params. */ + public CompletableFuture listAsync(UnbilledChargeListParams params) { + + return getAsync("/unbilled_charges", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + UnbilledChargeListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public UnbilledChargeListResponse list() throws ChargebeeException { Response response = listRaw(); return UnbilledChargeListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for unbilledCharge without params. */ + public CompletableFuture listAsync() { + + return getAsync("/unbilled_charges", null) + .thenApply( + response -> + UnbilledChargeListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** * create a unbilledCharge using immutable params (executes immediately) - returns raw Response. */ @@ -193,6 +252,16 @@ public UnbilledChargeCreateResponse create(UnbilledChargeCreateParams params) return UnbilledChargeCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for unbilledCharge with params. */ + public CompletableFuture createAsync( + UnbilledChargeCreateParams params) { + + return postAsync("/unbilled_charges", params != null ? params.toFormData() : null) + .thenApply( + response -> + UnbilledChargeCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createUnbilledCharge a unbilledCharge using immutable params (executes immediately) - returns * raw Response. @@ -217,4 +286,14 @@ public CreateUnbilledChargeResponse createUnbilledCharge(CreateUnbilledChargePar return CreateUnbilledChargeResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of createUnbilledCharge for unbilledCharge with params. */ + public CompletableFuture createUnbilledChargeAsync( + CreateUnbilledChargeParams params) { + + return postAsync("/unbilled_charges/create", params != null ? params.toFormData() : null) + .thenApply( + response -> + CreateUnbilledChargeResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/UnbilledChargesSettingService.java b/src/main/java/com/chargebee/v4/services/UnbilledChargesSettingService.java index cad3e21a..576c5e57 100644 --- a/src/main/java/com/chargebee/v4/services/UnbilledChargesSettingService.java +++ b/src/main/java/com/chargebee/v4/services/UnbilledChargesSettingService.java @@ -11,6 +11,7 @@ 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.unbilledChargesSetting.params.UnbilledChargesSettingRetrieveParams; @@ -85,9 +86,30 @@ public UnbilledChargesSettingRetrieveResponse retrieve( return UnbilledChargesSettingRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for unbilledChargesSetting with params. */ + public CompletableFuture retrieveAsync( + UnbilledChargesSettingRetrieveParams params) { + + return getAsync("/unbilled_charges_settings", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + UnbilledChargesSettingRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } + public UnbilledChargesSettingRetrieveResponse retrieve() throws ChargebeeException { Response response = retrieveRaw(); return UnbilledChargesSettingRetrieveResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of retrieve for unbilledChargesSetting without params. */ + public CompletableFuture retrieveAsync() { + + return getAsync("/unbilled_charges_settings", null) + .thenApply( + response -> + UnbilledChargesSettingRetrieveResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/UsageEventService.java b/src/main/java/com/chargebee/v4/services/UsageEventService.java index fe900b27..11725aca 100644 --- a/src/main/java/com/chargebee/v4/services/UsageEventService.java +++ b/src/main/java/com/chargebee/v4/services/UsageEventService.java @@ -11,6 +11,7 @@ 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.usageEvent.params.UsageEventCreateParams; @@ -77,6 +78,17 @@ public UsageEventCreateResponse create(UsageEventCreateParams params) throws Cha return UsageEventCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for usageEvent with params. */ + public CompletableFuture createAsync(UsageEventCreateParams params) { + + return postJsonWithSubDomainAsync( + "/usage_events", + SubDomain.INGEST.getValue(), + params != null ? params.toJsonString() : null) + .thenApply( + response -> UsageEventCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * batchIngest a usageEvent using immutable params (executes immediately) - returns raw Response. */ @@ -102,4 +114,17 @@ public UsageEventBatchIngestResponse batchIngest(UsageEventBatchIngestParams par return UsageEventBatchIngestResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of batchIngest for usageEvent with params. */ + public CompletableFuture batchIngestAsync( + UsageEventBatchIngestParams params) { + + return postJsonWithSubDomainAsync( + "/batch/usage_events", + SubDomain.INGEST.getValue(), + params != null ? params.toJsonString() : null) + .thenApply( + response -> + UsageEventBatchIngestResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/UsageFileService.java b/src/main/java/com/chargebee/v4/services/UsageFileService.java index 497cbc79..bda60e5c 100644 --- a/src/main/java/com/chargebee/v4/services/UsageFileService.java +++ b/src/main/java/com/chargebee/v4/services/UsageFileService.java @@ -11,6 +11,7 @@ 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.usageFile.params.UsageFileUploadUrlParams; @@ -69,6 +70,19 @@ public UsageFileProcessingStatusResponse processingStatus(String usageFileId) return UsageFileProcessingStatusResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of processingStatus for usageFile without params. */ + public CompletableFuture processingStatusAsync( + String usageFileId) { + String path = + buildPathWithParams( + "/usage_files/{usage-file-id}/processing_status", "usage-file-id", usageFileId); + + return getWithSubDomainAsync(path, SubDomain.FILE_INGEST.getValue(), null) + .thenApply( + response -> + UsageFileProcessingStatusResponse.fromJson(response.getBodyAsString(), response)); + } + /** uploadUrl a usageFile using immutable params (executes immediately) - returns raw Response. */ Response uploadUrlRaw(UsageFileUploadUrlParams params) throws ChargebeeException { @@ -91,4 +105,16 @@ public UsageFileUploadUrlResponse uploadUrl(UsageFileUploadUrlParams params) return UsageFileUploadUrlResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of uploadUrl for usageFile with params. */ + public CompletableFuture uploadUrlAsync( + UsageFileUploadUrlParams params) { + + return postWithSubDomainAsync( + "/usage_files/upload_url", + SubDomain.FILE_INGEST.getValue(), + params != null ? params.toFormData() : null) + .thenApply( + response -> UsageFileUploadUrlResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/UsageService.java b/src/main/java/com/chargebee/v4/services/UsageService.java index 9c6690aa..43a1271f 100644 --- a/src/main/java/com/chargebee/v4/services/UsageService.java +++ b/src/main/java/com/chargebee/v4/services/UsageService.java @@ -11,6 +11,7 @@ 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.usage.params.UsagePdfParams; @@ -84,6 +85,13 @@ public UsagePdfResponse pdf(UsagePdfParams params) throws ChargebeeException { return UsagePdfResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of pdf for usage with params. */ + public CompletableFuture pdfAsync(UsagePdfParams params) { + + return postAsync("/usages/pdf", params != null ? params.toFormData() : null) + .thenApply(response -> UsagePdfResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a usage (executes immediately) - returns raw Response. */ Response retrieveRaw(String subscriptionId) throws ChargebeeException { String path = @@ -108,11 +116,33 @@ public UsageRetrieveResponse retrieve(String subscriptionId, UsageRetrieveParams return UsageRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for usage with params. */ + public CompletableFuture retrieveAsync( + String subscriptionId, UsageRetrieveParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/usages", "subscription-id", subscriptionId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> UsageRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + public UsageRetrieveResponse retrieve(String subscriptionId) throws ChargebeeException { Response response = retrieveRaw(subscriptionId); return UsageRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for usage without params. */ + public CompletableFuture retrieveAsync(String subscriptionId) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/usages", "subscription-id", subscriptionId); + + return getAsync(path, null) + .thenApply( + response -> UsageRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** create a usage (executes immediately) - returns raw Response. */ Response createRaw(String subscriptionId) throws ChargebeeException { String path = @@ -144,6 +174,16 @@ public UsageCreateResponse create(String subscriptionId, UsageCreateParams param return UsageCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for usage with params. */ + public CompletableFuture createAsync( + String subscriptionId, UsageCreateParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/usages", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply(response -> UsageCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a usage (executes immediately) - returns raw Response. */ Response deleteRaw(String subscriptionId) throws ChargebeeException { String path = @@ -175,6 +215,16 @@ public UsageDeleteResponse delete(String subscriptionId, UsageDeleteParams param return UsageDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for usage with params. */ + public CompletableFuture deleteAsync( + String subscriptionId, UsageDeleteParams params) { + String path = + buildPathWithParams( + "/subscriptions/{subscription-id}/delete_usage", "subscription-id", subscriptionId); + return postAsync(path, params.toFormData()) + .thenApply(response -> UsageDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** list a usage using immutable params (executes immediately) - returns raw Response. */ Response listRaw(UsageListParams params) throws ChargebeeException { @@ -199,9 +249,27 @@ public UsageListResponse list(UsageListParams params) throws ChargebeeException return UsageListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for usage with params. */ + public CompletableFuture listAsync(UsageListParams params) { + + return getAsync("/usages", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + UsageListResponse.fromJson(response.getBodyAsString(), this, params, response)); + } + public UsageListResponse list() throws ChargebeeException { Response response = listRaw(); return UsageListResponse.fromJson(response.getBodyAsString(), this, null, response); } + + /** Async variant of list for usage without params. */ + public CompletableFuture listAsync() { + + return getAsync("/usages", null) + .thenApply( + response -> + UsageListResponse.fromJson(response.getBodyAsString(), this, null, response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/VariantService.java b/src/main/java/com/chargebee/v4/services/VariantService.java index bcce54e0..870ca60d 100644 --- a/src/main/java/com/chargebee/v4/services/VariantService.java +++ b/src/main/java/com/chargebee/v4/services/VariantService.java @@ -11,6 +11,7 @@ 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.variant.params.ListProductVariantsParams; @@ -101,6 +102,27 @@ public ListProductVariantsResponse listProductVariants(String productId) response.getBodyAsString(), this, null, productId, response); } + /** Async variant of listProductVariants for variant with params. */ + public CompletableFuture listProductVariantsAsync( + String productId, ListProductVariantsParams params) { + String path = buildPathWithParams("/products/{product-id}/variants", "product-id", productId); + return getAsync(path, params != null ? params.toQueryParams() : null) + .thenApply( + response -> + ListProductVariantsResponse.fromJson( + response.getBodyAsString(), this, params, productId, response)); + } + + /** Async variant of listProductVariants for variant without params. */ + public CompletableFuture listProductVariantsAsync(String productId) { + String path = buildPathWithParams("/products/{product-id}/variants", "product-id", productId); + return getAsync(path, null) + .thenApply( + response -> + ListProductVariantsResponse.fromJson( + response.getBodyAsString(), this, null, productId, response)); + } + /** createProductVariant a variant (executes immediately) - returns raw Response. */ Response createProductVariantRaw(String productId) throws ChargebeeException { String path = buildPathWithParams("/products/{product-id}/variants", "product-id", productId); @@ -133,6 +155,16 @@ public CreateProductVariantResponse createProductVariant( return CreateProductVariantResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of createProductVariant for variant with params. */ + public CompletableFuture createProductVariantAsync( + String productId, CreateProductVariantParams params) { + String path = buildPathWithParams("/products/{product-id}/variants", "product-id", productId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + CreateProductVariantResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a variant (executes immediately) - returns raw Response. */ Response retrieveRaw(String productVariantId) throws ChargebeeException { String path = @@ -147,6 +179,17 @@ public VariantRetrieveResponse retrieve(String productVariantId) throws Chargebe return VariantRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for variant without params. */ + public CompletableFuture retrieveAsync(String productVariantId) { + String path = + buildPathWithParams( + "/variants/{product-variant-id}", "product-variant-id", productVariantId); + + return getAsync(path, null) + .thenApply( + response -> VariantRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a variant (executes immediately) - returns raw Response. */ Response updateRaw(String productVariantId) throws ChargebeeException { String path = @@ -179,11 +222,33 @@ public VariantUpdateResponse update(String productVariantId, VariantUpdateParams return VariantUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for variant with params. */ + public CompletableFuture updateAsync( + String productVariantId, VariantUpdateParams params) { + String path = + buildPathWithParams( + "/variants/{product-variant-id}", "product-variant-id", productVariantId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> VariantUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public VariantUpdateResponse update(String productVariantId) throws ChargebeeException { Response response = updateRaw(productVariantId); return VariantUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for variant without params. */ + public CompletableFuture updateAsync(String productVariantId) { + String path = + buildPathWithParams( + "/variants/{product-variant-id}", "product-variant-id", productVariantId); + + return postAsync(path, null) + .thenApply( + response -> VariantUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** delete a variant (executes immediately) - returns raw Response. */ Response deleteRaw(String productVariantId) throws ChargebeeException { String path = @@ -197,4 +262,15 @@ public VariantDeleteResponse delete(String productVariantId) throws ChargebeeExc Response response = deleteRaw(productVariantId); return VariantDeleteResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of delete for variant without params. */ + public CompletableFuture deleteAsync(String productVariantId) { + String path = + buildPathWithParams( + "/variants/{product-variant-id}/delete", "product-variant-id", productVariantId); + + return postAsync(path, null) + .thenApply( + response -> VariantDeleteResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/VirtualBankAccountService.java b/src/main/java/com/chargebee/v4/services/VirtualBankAccountService.java index 24623b29..4998e499 100644 --- a/src/main/java/com/chargebee/v4/services/VirtualBankAccountService.java +++ b/src/main/java/com/chargebee/v4/services/VirtualBankAccountService.java @@ -11,6 +11,7 @@ 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.virtualBankAccount.params.VirtualBankAccountListParams; @@ -84,6 +85,22 @@ public VirtualBankAccountDeleteLocalResponse deleteLocal(String virtualBankAccou return VirtualBankAccountDeleteLocalResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of deleteLocal for virtualBankAccount without params. */ + public CompletableFuture deleteLocalAsync( + String virtualBankAccountId) { + String path = + buildPathWithParams( + "/virtual_bank_accounts/{virtual-bank-account-id}/delete_local", + "virtual-bank-account-id", + virtualBankAccountId); + + return postAsync(path, null) + .thenApply( + response -> + VirtualBankAccountDeleteLocalResponse.fromJson( + response.getBodyAsString(), response)); + } + /** delete a virtualBankAccount (executes immediately) - returns raw Response. */ Response deleteRaw(String virtualBankAccountId) throws ChargebeeException { String path = @@ -101,6 +118,21 @@ public VirtualBankAccountDeleteResponse delete(String virtualBankAccountId) return VirtualBankAccountDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for virtualBankAccount without params. */ + public CompletableFuture deleteAsync( + String virtualBankAccountId) { + String path = + buildPathWithParams( + "/virtual_bank_accounts/{virtual-bank-account-id}/delete", + "virtual-bank-account-id", + virtualBankAccountId); + + return postAsync(path, null) + .thenApply( + response -> + VirtualBankAccountDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** * list a virtualBankAccount using immutable params (executes immediately) - returns raw Response. */ @@ -131,6 +163,17 @@ public VirtualBankAccountListResponse list(VirtualBankAccountListParams params) response.getBodyAsString(), this, params, response); } + /** Async variant of list for virtualBankAccount with params. */ + public CompletableFuture listAsync( + VirtualBankAccountListParams params) { + + return getAsync("/virtual_bank_accounts", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + VirtualBankAccountListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public VirtualBankAccountListResponse list() throws ChargebeeException { Response response = listRaw(); @@ -138,6 +181,16 @@ public VirtualBankAccountListResponse list() throws ChargebeeException { response.getBodyAsString(), this, null, response); } + /** Async variant of list for virtualBankAccount without params. */ + public CompletableFuture listAsync() { + + return getAsync("/virtual_bank_accounts", null) + .thenApply( + response -> + VirtualBankAccountListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** * create a virtualBankAccount using immutable params (executes immediately) - returns raw * Response. @@ -163,6 +216,16 @@ public VirtualBankAccountCreateResponse create(VirtualBankAccountCreateParams pa return VirtualBankAccountCreateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of create for virtualBankAccount with params. */ + public CompletableFuture createAsync( + VirtualBankAccountCreateParams params) { + + return postAsync("/virtual_bank_accounts", params != null ? params.toFormData() : null) + .thenApply( + response -> + VirtualBankAccountCreateResponse.fromJson(response.getBodyAsString(), response)); + } + /** syncFund a virtualBankAccount (executes immediately) - returns raw Response. */ Response syncFundRaw(String virtualBankAccountId) throws ChargebeeException { String path = @@ -180,6 +243,21 @@ public VirtualBankAccountSyncFundResponse syncFund(String virtualBankAccountId) return VirtualBankAccountSyncFundResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of syncFund for virtualBankAccount without params. */ + public CompletableFuture syncFundAsync( + String virtualBankAccountId) { + String path = + buildPathWithParams( + "/virtual_bank_accounts/{virtual-bank-account-id}/sync_fund", + "virtual-bank-account-id", + virtualBankAccountId); + + return postAsync(path, null) + .thenApply( + response -> + VirtualBankAccountSyncFundResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a virtualBankAccount (executes immediately) - returns raw Response. */ Response retrieveRaw(String virtualBankAccountId) throws ChargebeeException { String path = @@ -197,6 +275,21 @@ public VirtualBankAccountRetrieveResponse retrieve(String virtualBankAccountId) return VirtualBankAccountRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for virtualBankAccount without params. */ + public CompletableFuture retrieveAsync( + String virtualBankAccountId) { + String path = + buildPathWithParams( + "/virtual_bank_accounts/{virtual-bank-account-id}", + "virtual-bank-account-id", + virtualBankAccountId); + + return getAsync(path, null) + .thenApply( + response -> + VirtualBankAccountRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** * createUsingPermanentToken a virtualBankAccount using immutable params (executes immediately) - * returns raw Response. @@ -225,4 +318,17 @@ public VirtualBankAccountCreateUsingPermanentTokenResponse createUsingPermanentT return VirtualBankAccountCreateUsingPermanentTokenResponse.fromJson( response.getBodyAsString(), response); } + + /** Async variant of createUsingPermanentToken for virtualBankAccount with params. */ + public CompletableFuture + createUsingPermanentTokenAsync(VirtualBankAccountCreateUsingPermanentTokenParams params) { + + return postAsync( + "/virtual_bank_accounts/create_using_permanent_token", + params != null ? params.toFormData() : null) + .thenApply( + response -> + VirtualBankAccountCreateUsingPermanentTokenResponse.fromJson( + response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/services/WebhookEndpointService.java b/src/main/java/com/chargebee/v4/services/WebhookEndpointService.java index 9fce3a99..c4a5a599 100644 --- a/src/main/java/com/chargebee/v4/services/WebhookEndpointService.java +++ b/src/main/java/com/chargebee/v4/services/WebhookEndpointService.java @@ -11,6 +11,7 @@ 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.webhookEndpoint.params.WebhookEndpointUpdateParams; @@ -79,6 +80,20 @@ public WebhookEndpointDeleteResponse delete(String webhookEndpointId) throws Cha return WebhookEndpointDeleteResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of delete for webhookEndpoint without params. */ + public CompletableFuture deleteAsync(String webhookEndpointId) { + String path = + buildPathWithParams( + "/webhook_endpoints/{webhook-endpoint-id}/delete", + "webhook-endpoint-id", + webhookEndpointId); + + return postAsync(path, null) + .thenApply( + response -> + WebhookEndpointDeleteResponse.fromJson(response.getBodyAsString(), response)); + } + /** retrieve a webhookEndpoint (executes immediately) - returns raw Response. */ Response retrieveRaw(String webhookEndpointId) throws ChargebeeException { String path = @@ -94,6 +109,19 @@ public WebhookEndpointRetrieveResponse retrieve(String webhookEndpointId) return WebhookEndpointRetrieveResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of retrieve for webhookEndpoint without params. */ + public CompletableFuture retrieveAsync( + String webhookEndpointId) { + String path = + buildPathWithParams( + "/webhook_endpoints/{webhook-endpoint-id}", "webhook-endpoint-id", webhookEndpointId); + + return getAsync(path, null) + .thenApply( + response -> + WebhookEndpointRetrieveResponse.fromJson(response.getBodyAsString(), response)); + } + /** update a webhookEndpoint (executes immediately) - returns raw Response. */ Response updateRaw(String webhookEndpointId) throws ChargebeeException { String path = @@ -130,11 +158,35 @@ public WebhookEndpointUpdateResponse update( return WebhookEndpointUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for webhookEndpoint with params. */ + public CompletableFuture updateAsync( + String webhookEndpointId, WebhookEndpointUpdateParams params) { + String path = + buildPathWithParams( + "/webhook_endpoints/{webhook-endpoint-id}", "webhook-endpoint-id", webhookEndpointId); + return postAsync(path, params.toFormData()) + .thenApply( + response -> + WebhookEndpointUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + public WebhookEndpointUpdateResponse update(String webhookEndpointId) throws ChargebeeException { Response response = updateRaw(webhookEndpointId); return WebhookEndpointUpdateResponse.fromJson(response.getBodyAsString(), response); } + /** Async variant of update for webhookEndpoint without params. */ + public CompletableFuture updateAsync(String webhookEndpointId) { + String path = + buildPathWithParams( + "/webhook_endpoints/{webhook-endpoint-id}", "webhook-endpoint-id", webhookEndpointId); + + return postAsync(path, null) + .thenApply( + response -> + WebhookEndpointUpdateResponse.fromJson(response.getBodyAsString(), response)); + } + /** * list a webhookEndpoint using immutable params (executes immediately) - returns raw Response. */ @@ -164,12 +216,33 @@ public WebhookEndpointListResponse list(WebhookEndpointListParams params) return WebhookEndpointListResponse.fromJson(response.getBodyAsString(), this, params, response); } + /** Async variant of list for webhookEndpoint with params. */ + public CompletableFuture listAsync( + WebhookEndpointListParams params) { + + return getAsync("/webhook_endpoints", params != null ? params.toQueryParams() : null) + .thenApply( + response -> + WebhookEndpointListResponse.fromJson( + response.getBodyAsString(), this, params, response)); + } + public WebhookEndpointListResponse list() throws ChargebeeException { Response response = listRaw(); return WebhookEndpointListResponse.fromJson(response.getBodyAsString(), this, null, response); } + /** Async variant of list for webhookEndpoint without params. */ + public CompletableFuture listAsync() { + + return getAsync("/webhook_endpoints", null) + .thenApply( + response -> + WebhookEndpointListResponse.fromJson( + response.getBodyAsString(), this, null, response)); + } + /** * create a webhookEndpoint using immutable params (executes immediately) - returns raw Response. */ @@ -192,4 +265,14 @@ public WebhookEndpointCreateResponse create(WebhookEndpointCreateParams params) return WebhookEndpointCreateResponse.fromJson(response.getBodyAsString(), response); } + + /** Async variant of create for webhookEndpoint with params. */ + public CompletableFuture createAsync( + WebhookEndpointCreateParams params) { + + return postAsync("/webhook_endpoints", params != null ? params.toFormData() : null) + .thenApply( + response -> + WebhookEndpointCreateResponse.fromJson(response.getBodyAsString(), response)); + } } diff --git a/src/main/java/com/chargebee/v4/transport/DefaultTransport.java b/src/main/java/com/chargebee/v4/transport/DefaultTransport.java index 7c43abd3..0c8df9f4 100644 --- a/src/main/java/com/chargebee/v4/transport/DefaultTransport.java +++ b/src/main/java/com/chargebee/v4/transport/DefaultTransport.java @@ -7,17 +7,21 @@ import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import java.util.zip.GZIPInputStream; /** * Default HTTP transport implementation using HttpURLConnection for both sync and async operations. * Async operations are executed on a background thread pool. */ -public class DefaultTransport implements Transport { +public class DefaultTransport implements Transport, AutoCloseable { private final TransportConfig config; - private final Executor asyncExecutor; + private final ExecutorService asyncExecutor; + private final boolean ownsExecutor; private static final String VERSION; @@ -41,7 +45,45 @@ public TransportConfig getConfig() { public DefaultTransport(TransportConfig config) { this.config = Objects.requireNonNull(config, "TransportConfig cannot be null"); - this.asyncExecutor = ForkJoinPool.commonPool(); + if (config.getAsyncExecutor() != null) { + this.asyncExecutor = config.getAsyncExecutor(); + this.ownsExecutor = false; + } else { + this.asyncExecutor = createDefaultExecutor(); + this.ownsExecutor = true; + } + } + + private static ExecutorService createDefaultExecutor() { + AtomicInteger counter = new AtomicInteger(); + ThreadFactory factory = r -> { + Thread t = new Thread(r, "chargebee-async-" + counter.incrementAndGet()); + t.setDaemon(true); + return t; + }; + return Executors.newCachedThreadPool(factory); + } + + /** + * Returns the executor used for async operations. + */ + public ExecutorService getAsyncExecutor() { + return asyncExecutor; + } + + @Override + public void close() { + if (ownsExecutor) { + asyncExecutor.shutdown(); + try { + if (!asyncExecutor.awaitTermination(5, TimeUnit.SECONDS)) { + asyncExecutor.shutdownNow(); + } + } catch (InterruptedException e) { + asyncExecutor.shutdownNow(); + Thread.currentThread().interrupt(); + } + } } @Override diff --git a/src/main/java/com/chargebee/v4/transport/TransportConfig.java b/src/main/java/com/chargebee/v4/transport/TransportConfig.java index 1bd26c70..15829295 100644 --- a/src/main/java/com/chargebee/v4/transport/TransportConfig.java +++ b/src/main/java/com/chargebee/v4/transport/TransportConfig.java @@ -1,6 +1,7 @@ package com.chargebee.v4.transport; import java.util.*; +import java.util.concurrent.ExecutorService; /** * Immutable configuration for HTTP transport. @@ -15,7 +16,8 @@ public final class TransportConfig { private final int maxConnections; private final long keepAliveDurationMs; private final RequestLogger requestLogger; - + private final ExecutorService asyncExecutor; + private TransportConfig(Builder builder) { this.apiKey = builder.apiKey; this.connectTimeoutMs = builder.connectTimeoutMs; @@ -26,6 +28,7 @@ private TransportConfig(Builder builder) { this.maxConnections = builder.maxConnections; this.keepAliveDurationMs = builder.keepAliveDurationMs; this.requestLogger = builder.requestLogger; + this.asyncExecutor = builder.asyncExecutor; } public String getApiKey() { @@ -63,6 +66,13 @@ public long getKeepAliveDurationMs() { public RequestLogger getRequestLogger() { return requestLogger; } + + /** + * Returns the configured async executor, or null if the default should be used. + */ + public ExecutorService getAsyncExecutor() { + return asyncExecutor; + } public static Builder builder() { return new Builder(); @@ -78,6 +88,7 @@ public static class Builder { private int maxConnections = 20; private long keepAliveDurationMs = 300000; // 5 minutes private RequestLogger requestLogger; + private ExecutorService asyncExecutor; public Builder() { // Standard headers are set by DefaultTransport @@ -150,6 +161,14 @@ public Builder requestLogger(RequestLogger requestLogger) { this.requestLogger = requestLogger; return this; } + + /** + * Set a custom executor for async operations. If not set, a dedicated cached thread pool is used. + */ + public Builder asyncExecutor(ExecutorService asyncExecutor) { + this.asyncExecutor = asyncExecutor; + return this; + } public TransportConfig build() { if (apiKey == null || apiKey.trim().isEmpty()) { diff --git a/src/test/java/com/chargebee/v4/client/ChargebeeClientAsyncExecutorTest.java b/src/test/java/com/chargebee/v4/client/ChargebeeClientAsyncExecutorTest.java new file mode 100644 index 00000000..dbfe293b --- /dev/null +++ b/src/test/java/com/chargebee/v4/client/ChargebeeClientAsyncExecutorTest.java @@ -0,0 +1,341 @@ +package com.chargebee.v4.client; + +import com.chargebee.v4.exceptions.NetworkException; +import com.chargebee.v4.internal.RetryConfig; +import com.chargebee.v4.transport.*; +import org.junit.jupiter.api.*; + +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +@DisplayName("ChargebeeClient Async Executor Tests") +class ChargebeeClientAsyncExecutorTest { + + private static final String TEST_API_KEY = "test_api_key"; + private static final String TEST_SITE = "test-site"; + + @Nested + @DisplayName("delayAndRetry - ScheduledExecutorService Tests") + class DelayAndRetryTests { + + @Test + @DisplayName("should use ScheduledExecutorService for retry delays instead of Thread.sleep") + @Timeout(10) + void shouldUseScheduledExecutorForDelays() throws Exception { + Transport mockTransport = mock(Transport.class); + Response retryableResponse = createResponse(429); + Response successResponse = createSuccessResponse(); + + when(mockTransport.sendAsync(any(Request.class))) + .thenReturn(CompletableFuture.completedFuture(retryableResponse)) + .thenReturn(CompletableFuture.completedFuture(successResponse)); + + RetryConfig retryConfig = RetryConfig.builder() + .enabled(true) + .maxRetries(2) + .baseDelayMs(50) + .retryOnStatus(new HashSet<>(Arrays.asList(429))) + .build(); + + ChargebeeClient client = ChargebeeClient.builder() + .apiKey(TEST_API_KEY) + .siteName(TEST_SITE) + .transport(mockTransport) + .retry(retryConfig) + .build(); + + Request request = Request.builder() + .method("GET") + .url("http://test.com") + .build(); + + long start = System.currentTimeMillis(); + CompletableFuture future = client.sendWithRetryAsync(request); + Response response = future.get(5, TimeUnit.SECONDS); + long duration = System.currentTimeMillis() - start; + + assertEquals(200, response.getStatusCode()); + verify(mockTransport, times(2)).sendAsync(any(Request.class)); + // Verify delay was actually applied + assertTrue(duration >= 30, "Retry delay should have been applied, but took only " + duration + "ms"); + + client.close(); + } + + @Test + @DisplayName("should not block ForkJoinPool.commonPool threads during retry delay") + @Timeout(15) + void shouldNotBlockCommonPoolDuringDelay() throws Exception { + Transport mockTransport = mock(Transport.class); + Response retryableResponse = createResponse(429); + Response successResponse = createSuccessResponse(); + + AtomicInteger callCount = new AtomicInteger(0); + when(mockTransport.sendAsync(any(Request.class))).thenAnswer(invocation -> { + int count = callCount.incrementAndGet(); + if (count <= 2) { + return CompletableFuture.completedFuture(retryableResponse); + } + return CompletableFuture.completedFuture(successResponse); + }); + + RetryConfig retryConfig = RetryConfig.builder() + .enabled(true) + .maxRetries(3) + .baseDelayMs(100) + .retryOnStatus(new HashSet<>(Arrays.asList(429))) + .build(); + + ChargebeeClient client = ChargebeeClient.builder() + .apiKey(TEST_API_KEY) + .siteName(TEST_SITE) + .transport(mockTransport) + .retry(retryConfig) + .build(); + + // Submit work on ForkJoinPool.commonPool to verify it's not starved + CompletableFuture commonPoolTask = CompletableFuture.supplyAsync(() -> { + // This should complete quickly if common pool is not blocked + return "common-pool-not-blocked"; + }); + + Request request = Request.builder() + .method("GET") + .url("http://test.com") + .build(); + + CompletableFuture retryFuture = client.sendWithRetryAsync(request); + + // Common pool task should complete even while retries are in progress + String result = commonPoolTask.get(2, TimeUnit.SECONDS); + assertEquals("common-pool-not-blocked", result); + + // Wait for retry to complete + Response response = retryFuture.get(10, TimeUnit.SECONDS); + assertEquals(200, response.getStatusCode()); + + client.close(); + } + + @Test + @DisplayName("should handle multiple concurrent async retries without exhausting threads") + @Timeout(30) + void shouldHandleConcurrentRetriesWithoutExhaustingThreads() throws Exception { + Transport mockTransport = mock(Transport.class); + Response retryableResponse = createResponse(429); + Response successResponse = createSuccessResponse(); + + AtomicInteger totalCalls = new AtomicInteger(0); + when(mockTransport.sendAsync(any(Request.class))).thenAnswer(invocation -> { + int count = totalCalls.incrementAndGet(); + // First call for each request returns 429, second returns 200 + // With 10 requests, calls 1-10 return 429, calls 11-20 return 200 + if (count <= 10) { + return CompletableFuture.completedFuture(retryableResponse); + } + return CompletableFuture.completedFuture(successResponse); + }); + + RetryConfig retryConfig = RetryConfig.builder() + .enabled(true) + .maxRetries(2) + .baseDelayMs(50) + .retryOnStatus(new HashSet<>(Arrays.asList(429))) + .build(); + + ChargebeeClient client = ChargebeeClient.builder() + .apiKey(TEST_API_KEY) + .siteName(TEST_SITE) + .transport(mockTransport) + .retry(retryConfig) + .build(); + + int concurrentRequests = 10; + List> futures = new ArrayList<>(); + + for (int i = 0; i < concurrentRequests; i++) { + Request request = Request.builder() + .method("GET") + .url("http://test.com") + .build(); + futures.add(client.sendWithRetryAsync(request)); + } + + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) + .get(20, TimeUnit.SECONDS); + + for (CompletableFuture future : futures) { + assertEquals(200, future.get().getStatusCode()); + } + + client.close(); + } + + @Test + @DisplayName("should apply correct backoff delay in async retries") + @Timeout(10) + void shouldApplyCorrectBackoffDelayInAsyncRetries() throws Exception { + Transport mockTransport = mock(Transport.class); + NetworkException networkException = new NetworkException("Network error", new Exception()); + Response successResponse = createSuccessResponse(); + + List callTimestamps = Collections.synchronizedList(new ArrayList<>()); + + CompletableFuture failedFuture1 = new CompletableFuture<>(); + failedFuture1.completeExceptionally(networkException); + CompletableFuture failedFuture2 = new CompletableFuture<>(); + failedFuture2.completeExceptionally(networkException); + + when(mockTransport.sendAsync(any(Request.class))).thenAnswer(invocation -> { + callTimestamps.add(System.currentTimeMillis()); + if (callTimestamps.size() <= 2) { + CompletableFuture failed = new CompletableFuture<>(); + failed.completeExceptionally(networkException); + return failed; + } + return CompletableFuture.completedFuture(successResponse); + }); + + RetryConfig retryConfig = RetryConfig.builder() + .enabled(true) + .maxRetries(3) + .baseDelayMs(100) + .build(); + + ChargebeeClient client = ChargebeeClient.builder() + .apiKey(TEST_API_KEY) + .siteName(TEST_SITE) + .transport(mockTransport) + .retry(retryConfig) + .build(); + + Request request = Request.builder() + .method("GET") + .url("http://test.com") + .build(); + + Response response = client.sendWithRetryAsync(request).get(10, TimeUnit.SECONDS); + assertEquals(200, response.getStatusCode()); + + // Verify exponential backoff: delays should increase + assertEquals(3, callTimestamps.size()); + long delay1 = callTimestamps.get(1) - callTimestamps.get(0); + long delay2 = callTimestamps.get(2) - callTimestamps.get(1); + + // First retry delay ~100ms, second ~200ms (with jitter) + assertTrue(delay1 >= 50, "First retry delay too short: " + delay1 + "ms"); + assertTrue(delay2 >= 100, "Second retry delay too short: " + delay2 + "ms"); + + client.close(); + } + } + + @Nested + @DisplayName("ChargebeeClient AutoCloseable Tests") + class ClientAutoCloseableTests { + + @Test + @DisplayName("should implement AutoCloseable") + void shouldImplementAutoCloseable() { + ChargebeeClient client = ChargebeeClient.builder() + .apiKey(TEST_API_KEY) + .siteName(TEST_SITE) + .build(); + + assertTrue(client instanceof AutoCloseable); + client.close(); + } + + @Test + @DisplayName("should work with try-with-resources") + void shouldWorkWithTryWithResources() throws Exception { + Transport mockTransport = mock(Transport.class); + when(mockTransport.sendAsync(any(Request.class))) + .thenReturn(CompletableFuture.completedFuture(createSuccessResponse())); + + try (ChargebeeClient client = ChargebeeClient.builder() + .apiKey(TEST_API_KEY) + .siteName(TEST_SITE) + .transport(mockTransport) + .build()) { + + Request request = Request.builder() + .method("GET") + .url("http://test.com") + .build(); + + Response response = client.sendWithRetryAsync(request).get(5, TimeUnit.SECONDS); + assertEquals(200, response.getStatusCode()); + } + // No exception should be thrown after close + } + + @Test + @DisplayName("should close transport when transport is AutoCloseable") + void shouldCloseTransportWhenAutoCloseable() throws Exception { + DefaultTransport transport = new DefaultTransport( + TransportConfig.builder().apiKey(TEST_API_KEY).build()); + + ChargebeeClient client = ChargebeeClient.builder() + .apiKey(TEST_API_KEY) + .siteName(TEST_SITE) + .transport(transport) + .build(); + + ExecutorService transportExecutor = transport.getAsyncExecutor(); + assertFalse(transportExecutor.isShutdown()); + + client.close(); + + assertTrue(transportExecutor.isShutdown(), + "Transport executor should be shut down when client is closed"); + } + + @Test + @DisplayName("should handle close gracefully when transport is not AutoCloseable") + void shouldHandleCloseWhenTransportNotAutoCloseable() { + Transport mockTransport = mock(Transport.class); + + ChargebeeClient client = ChargebeeClient.builder() + .apiKey(TEST_API_KEY) + .siteName(TEST_SITE) + .transport(mockTransport) + .build(); + + // Should not throw even with non-closeable transport + assertDoesNotThrow(() -> client.close()); + } + + @Test + @DisplayName("should handle multiple close calls gracefully") + void shouldHandleMultipleCloseCalls() { + ChargebeeClient client = ChargebeeClient.builder() + .apiKey(TEST_API_KEY) + .siteName(TEST_SITE) + .build(); + + assertDoesNotThrow(() -> { + client.close(); + client.close(); + }); + } + } + + // Helper methods + + private Response createSuccessResponse() { + return new Response(200, new HashMap<>(), "OK".getBytes()); + } + + private Response createResponse(int statusCode) { + Map> headers = new HashMap<>(); + headers.put("Content-Type", Arrays.asList("application/json")); + String body = String.format("{\"status\":%d}", statusCode); + return new Response(statusCode, headers, body.getBytes()); + } +} diff --git a/src/test/java/com/chargebee/v4/transport/DefaultTransportExecutorTest.java b/src/test/java/com/chargebee/v4/transport/DefaultTransportExecutorTest.java new file mode 100644 index 00000000..d1160f8c --- /dev/null +++ b/src/test/java/com/chargebee/v4/transport/DefaultTransportExecutorTest.java @@ -0,0 +1,311 @@ +package com.chargebee.v4.transport; + +import org.junit.jupiter.api.*; + +import com.sun.net.httpserver.HttpServer; + +import java.io.*; +import java.net.*; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.*; + +import static org.junit.jupiter.api.Assertions.*; + +@DisplayName("DefaultTransport Executor Tests") +class DefaultTransportExecutorTest { + + private static final String TEST_API_KEY = "test_api_key"; + + @Nested + @DisplayName("Default Executor Tests") + class DefaultExecutorTests { + + @Test + @DisplayName("should create a dedicated executor by default instead of ForkJoinPool.commonPool") + void shouldUseDedicatedExecutorByDefault() { + TransportConfig config = TransportConfig.builder() + .apiKey(TEST_API_KEY) + .build(); + + DefaultTransport transport = new DefaultTransport(config); + + ExecutorService executor = transport.getAsyncExecutor(); + assertNotNull(executor); + assertNotSame(ForkJoinPool.commonPool(), executor); + + transport.close(); + } + + @Test + @DisplayName("should use daemon threads in default executor") + void shouldUseDaemonThreadsInDefaultExecutor() throws Exception { + TransportConfig config = TransportConfig.builder() + .apiKey(TEST_API_KEY) + .build(); + + DefaultTransport transport = new DefaultTransport(config); + + CompletableFuture isDaemon = new CompletableFuture<>(); + CompletableFuture threadName = new CompletableFuture<>(); + + transport.getAsyncExecutor().execute(() -> { + isDaemon.complete(Thread.currentThread().isDaemon()); + threadName.complete(Thread.currentThread().getName()); + }); + + assertTrue(isDaemon.get(5, TimeUnit.SECONDS), "Default executor threads should be daemon threads"); + assertTrue(threadName.get(5, TimeUnit.SECONDS).startsWith("chargebee-async-"), + "Default executor threads should be named chargebee-async-*"); + + transport.close(); + } + + @Test + @DisplayName("should execute async requests on dedicated thread pool, not common pool") + void shouldExecuteAsyncOnDedicatedPool() throws Exception { + TransportConfig config = TransportConfig.builder() + .apiKey(TEST_API_KEY) + .build(); + + DefaultTransport transport = new DefaultTransport(config); + + TestHttpServer server = new TestHttpServer(); + server.start(); + + try { + Request request = Request.builder() + .method("GET") + .url(server.getUrl()) + .build(); + + CompletableFuture threadNameFuture = new CompletableFuture<>(); + + // Intercept the thread name during async execution + CompletableFuture responseFuture = transport.sendAsync(request); + responseFuture.thenRun(() -> threadNameFuture.complete("completed")); + + Response response = responseFuture.get(5, TimeUnit.SECONDS); + assertEquals(200, response.getStatusCode()); + } finally { + server.stop(); + transport.close(); + } + } + } + + @Nested + @DisplayName("Custom Executor Tests") + class CustomExecutorTests { + + @Test + @DisplayName("should use custom executor when provided via TransportConfig") + void shouldUseCustomExecutor() throws Exception { + ExecutorService customExecutor = Executors.newFixedThreadPool(2); + + TransportConfig config = TransportConfig.builder() + .apiKey(TEST_API_KEY) + .asyncExecutor(customExecutor) + .build(); + + DefaultTransport transport = new DefaultTransport(config); + + assertSame(customExecutor, transport.getAsyncExecutor()); + + transport.close(); + // Custom executor should NOT be shut down by transport + assertFalse(customExecutor.isShutdown(), + "Transport should not shut down a user-provided executor"); + + customExecutor.shutdown(); + } + + @Test + @DisplayName("should execute async requests on custom executor") + void shouldExecuteAsyncOnCustomExecutor() throws Exception { + CompletableFuture executingThreadName = new CompletableFuture<>(); + + ExecutorService customExecutor = Executors.newSingleThreadExecutor(r -> { + Thread t = new Thread(r, "custom-test-thread"); + t.setDaemon(true); + return t; + }); + + TransportConfig config = TransportConfig.builder() + .apiKey(TEST_API_KEY) + .asyncExecutor(customExecutor) + .build(); + + DefaultTransport transport = new DefaultTransport(config); + + TestHttpServer server = new TestHttpServer(); + server.start(); + + try { + Request request = Request.builder() + .method("GET") + .url(server.getUrl()) + .build(); + + Response response = transport.sendAsync(request).get(5, TimeUnit.SECONDS); + assertEquals(200, response.getStatusCode()); + } finally { + server.stop(); + transport.close(); + customExecutor.shutdown(); + } + } + } + + @Nested + @DisplayName("AutoCloseable Tests") + class AutoCloseableTests { + + @Test + @DisplayName("should shut down owned executor on close") + void shouldShutDownOwnedExecutorOnClose() { + TransportConfig config = TransportConfig.builder() + .apiKey(TEST_API_KEY) + .build(); + + DefaultTransport transport = new DefaultTransport(config); + ExecutorService executor = transport.getAsyncExecutor(); + + assertFalse(executor.isShutdown()); + + transport.close(); + + assertTrue(executor.isShutdown(), "Owned executor should be shut down on close"); + } + + @Test + @DisplayName("should not shut down user-provided executor on close") + void shouldNotShutDownUserProvidedExecutorOnClose() { + ExecutorService userExecutor = Executors.newCachedThreadPool(); + + TransportConfig config = TransportConfig.builder() + .apiKey(TEST_API_KEY) + .asyncExecutor(userExecutor) + .build(); + + DefaultTransport transport = new DefaultTransport(config); + transport.close(); + + assertFalse(userExecutor.isShutdown(), + "User-provided executor must not be shut down by transport"); + + userExecutor.shutdown(); + } + + @Test + @DisplayName("should be usable with try-with-resources") + void shouldWorkWithTryWithResources() throws Exception { + ExecutorService capturedExecutor; + + try (DefaultTransport transport = new DefaultTransport( + TransportConfig.builder().apiKey(TEST_API_KEY).build())) { + capturedExecutor = transport.getAsyncExecutor(); + assertFalse(capturedExecutor.isShutdown()); + } + + assertTrue(capturedExecutor.isShutdown(), + "Executor should be shut down after try-with-resources block"); + } + + @Test + @DisplayName("should handle multiple close calls gracefully") + void shouldHandleMultipleCloseCalls() { + TransportConfig config = TransportConfig.builder() + .apiKey(TEST_API_KEY) + .build(); + + DefaultTransport transport = new DefaultTransport(config); + + // Should not throw on multiple close calls + transport.close(); + transport.close(); + } + } + + @Nested + @DisplayName("Concurrency Tests") + class ConcurrencyTests { + + @Test + @DisplayName("should handle multiple concurrent async requests") + @Timeout(10) + void shouldHandleConcurrentAsyncRequests() throws Exception { + TransportConfig config = TransportConfig.builder() + .apiKey(TEST_API_KEY) + .build(); + + DefaultTransport transport = new DefaultTransport(config); + + TestHttpServer server = new TestHttpServer(); + server.start(); + + try { + int concurrentRequests = 20; + List> futures = new ArrayList<>(); + + for (int i = 0; i < concurrentRequests; i++) { + Request request = Request.builder() + .method("GET") + .url(server.getUrl()) + .build(); + futures.add(transport.sendAsync(request)); + } + + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) + .get(10, TimeUnit.SECONDS); + + for (CompletableFuture future : futures) { + assertEquals(200, future.get().getStatusCode()); + } + } finally { + server.stop(); + transport.close(); + } + } + } + + /** + * Simple embedded HTTP server for testing. + */ + private static class TestHttpServer { + private HttpServer server; + private int port; + + void start() throws IOException { + port = findFreePort(); + server = HttpServer.create(new InetSocketAddress(port), 0); + + server.createContext("/", exchange -> { + byte[] responseBytes = "OK".getBytes(StandardCharsets.UTF_8); + exchange.sendResponseHeaders(200, responseBytes.length); + try (OutputStream os = exchange.getResponseBody()) { + os.write(responseBytes); + } + }); + + server.setExecutor(null); + server.start(); + } + + void stop() { + if (server != null) { + server.stop(0); + } + } + + String getUrl() { + return "http://localhost:" + port + "/"; + } + + private int findFreePort() throws IOException { + try (ServerSocket socket = new ServerSocket(0)) { + return socket.getLocalPort(); + } + } + } +}