1111import com .chargebee .v4 .client .request .RequestOptions ;
1212import com .chargebee .v4 .exceptions .ChargebeeException ;
1313import com .chargebee .v4 .transport .Response ;
14+ import java .util .concurrent .CompletableFuture ;
1415
1516import com .chargebee .v4 .models .addon .params .AddonCopyParams ;
1617
@@ -86,6 +87,13 @@ public AddonCopyResponse copy(AddonCopyParams params) throws ChargebeeException
8687 return AddonCopyResponse .fromJson (response .getBodyAsString (), response );
8788 }
8889
90+ /** Async variant of copy for addon with params. */
91+ public CompletableFuture <AddonCopyResponse > copyAsync (AddonCopyParams params ) {
92+
93+ return postAsync ("/addons/copy" , params != null ? params .toFormData () : null )
94+ .thenApply (response -> AddonCopyResponse .fromJson (response .getBodyAsString (), response ));
95+ }
96+
8997 /** unarchive a addon (executes immediately) - returns raw Response. */
9098 Response unarchiveRaw (String addonId ) throws ChargebeeException {
9199 String path = buildPathWithParams ("/addons/{addon-id}/unarchive" , "addon-id" , addonId );
@@ -98,6 +106,15 @@ public AddonUnarchiveResponse unarchive(String addonId) throws ChargebeeExceptio
98106 return AddonUnarchiveResponse .fromJson (response .getBodyAsString (), response );
99107 }
100108
109+ /** Async variant of unarchive for addon without params. */
110+ public CompletableFuture <AddonUnarchiveResponse > unarchiveAsync (String addonId ) {
111+ String path = buildPathWithParams ("/addons/{addon-id}/unarchive" , "addon-id" , addonId );
112+
113+ return postAsync (path , null )
114+ .thenApply (
115+ response -> AddonUnarchiveResponse .fromJson (response .getBodyAsString (), response ));
116+ }
117+
101118 /** retrieve a addon (executes immediately) - returns raw Response. */
102119 Response retrieveRaw (String addonId ) throws ChargebeeException {
103120 String path = buildPathWithParams ("/addons/{addon-id}" , "addon-id" , addonId );
@@ -110,6 +127,15 @@ public AddonRetrieveResponse retrieve(String addonId) throws ChargebeeException
110127 return AddonRetrieveResponse .fromJson (response .getBodyAsString (), response );
111128 }
112129
130+ /** Async variant of retrieve for addon without params. */
131+ public CompletableFuture <AddonRetrieveResponse > retrieveAsync (String addonId ) {
132+ String path = buildPathWithParams ("/addons/{addon-id}" , "addon-id" , addonId );
133+
134+ return getAsync (path , null )
135+ .thenApply (
136+ response -> AddonRetrieveResponse .fromJson (response .getBodyAsString (), response ));
137+ }
138+
113139 /** update a addon (executes immediately) - returns raw Response. */
114140 Response updateRaw (String addonId ) throws ChargebeeException {
115141 String path = buildPathWithParams ("/addons/{addon-id}" , "addon-id" , addonId );
@@ -135,11 +161,27 @@ public AddonUpdateResponse update(String addonId, AddonUpdateParams params)
135161 return AddonUpdateResponse .fromJson (response .getBodyAsString (), response );
136162 }
137163
164+ /** Async variant of update for addon with params. */
165+ public CompletableFuture <AddonUpdateResponse > updateAsync (
166+ String addonId , AddonUpdateParams params ) {
167+ String path = buildPathWithParams ("/addons/{addon-id}" , "addon-id" , addonId );
168+ return postAsync (path , params .toFormData ())
169+ .thenApply (response -> AddonUpdateResponse .fromJson (response .getBodyAsString (), response ));
170+ }
171+
138172 public AddonUpdateResponse update (String addonId ) throws ChargebeeException {
139173 Response response = updateRaw (addonId );
140174 return AddonUpdateResponse .fromJson (response .getBodyAsString (), response );
141175 }
142176
177+ /** Async variant of update for addon without params. */
178+ public CompletableFuture <AddonUpdateResponse > updateAsync (String addonId ) {
179+ String path = buildPathWithParams ("/addons/{addon-id}" , "addon-id" , addonId );
180+
181+ return postAsync (path , null )
182+ .thenApply (response -> AddonUpdateResponse .fromJson (response .getBodyAsString (), response ));
183+ }
184+
143185 /** list a addon using immutable params (executes immediately) - returns raw Response. */
144186 Response listRaw (AddonListParams params ) throws ChargebeeException {
145187
@@ -164,12 +206,30 @@ public AddonListResponse list(AddonListParams params) throws ChargebeeException
164206 return AddonListResponse .fromJson (response .getBodyAsString (), this , params , response );
165207 }
166208
209+ /** Async variant of list for addon with params. */
210+ public CompletableFuture <AddonListResponse > listAsync (AddonListParams params ) {
211+
212+ return getAsync ("/addons" , params != null ? params .toQueryParams () : null )
213+ .thenApply (
214+ response ->
215+ AddonListResponse .fromJson (response .getBodyAsString (), this , params , response ));
216+ }
217+
167218 public AddonListResponse list () throws ChargebeeException {
168219 Response response = listRaw ();
169220
170221 return AddonListResponse .fromJson (response .getBodyAsString (), this , null , response );
171222 }
172223
224+ /** Async variant of list for addon without params. */
225+ public CompletableFuture <AddonListResponse > listAsync () {
226+
227+ return getAsync ("/addons" , null )
228+ .thenApply (
229+ response ->
230+ AddonListResponse .fromJson (response .getBodyAsString (), this , null , response ));
231+ }
232+
173233 /** create a addon using immutable params (executes immediately) - returns raw Response. */
174234 Response createRaw (AddonCreateParams params ) throws ChargebeeException {
175235
@@ -188,6 +248,13 @@ public AddonCreateResponse create(AddonCreateParams params) throws ChargebeeExce
188248 return AddonCreateResponse .fromJson (response .getBodyAsString (), response );
189249 }
190250
251+ /** Async variant of create for addon with params. */
252+ public CompletableFuture <AddonCreateResponse > createAsync (AddonCreateParams params ) {
253+
254+ return postAsync ("/addons" , params != null ? params .toFormData () : null )
255+ .thenApply (response -> AddonCreateResponse .fromJson (response .getBodyAsString (), response ));
256+ }
257+
191258 /** delete a addon (executes immediately) - returns raw Response. */
192259 Response deleteRaw (String addonId ) throws ChargebeeException {
193260 String path = buildPathWithParams ("/addons/{addon-id}/delete" , "addon-id" , addonId );
@@ -199,4 +266,12 @@ public AddonDeleteResponse delete(String addonId) throws ChargebeeException {
199266 Response response = deleteRaw (addonId );
200267 return AddonDeleteResponse .fromJson (response .getBodyAsString (), response );
201268 }
269+
270+ /** Async variant of delete for addon without params. */
271+ public CompletableFuture <AddonDeleteResponse > deleteAsync (String addonId ) {
272+ String path = buildPathWithParams ("/addons/{addon-id}/delete" , "addon-id" , addonId );
273+
274+ return postAsync (path , null )
275+ .thenApply (response -> AddonDeleteResponse .fromJson (response .getBodyAsString (), response ));
276+ }
202277}
0 commit comments