Skip to content

Commit 0b1bdd3

Browse files
committed
support params in get api
1 parent 65f6a6d commit 0b1bdd3

9 files changed

Lines changed: 154 additions & 3 deletions
332 Bytes
Binary file not shown.

src/main/java/com/chargebee/v4/exceptions/APIException.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.chargebee.v4.exceptions.codes.ApiErrorCode;
99
import com.chargebee.v4.internal.JsonUtil;
10+
import com.chargebee.v4.transport.HttpException;
1011
import com.chargebee.v4.transport.Request;
1112
import com.chargebee.v4.transport.Response;
1213

@@ -252,11 +253,12 @@ private String extractErrorCauseId(String jsonResponse) {
252253

253254
/**
254255
* API errors are generally not retryable as they indicate business logic issues.
255-
*
256+
*
256257
* <p>Exceptions that may warrant retry:
258+
*
257259
* <ul>
258-
* <li>429 Too Many Requests - Rate limiting</li>
259-
* <li>5xx Server errors - Temporary server issues</li>
260+
* <li>429 Too Many Requests - Rate limiting
261+
* <li>5xx Server errors - Temporary server issues
260262
* </ul>
261263
*
262264
* @return true only for 429 or 5xx status codes

src/main/java/com/chargebee/v4/services/AttachedItemService.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import com.chargebee.v4.client.request.RequestOptions;
1212
import com.chargebee.v4.transport.Response;
1313

14+
import com.chargebee.v4.models.attachedItem.params.AttachedItemRetrieveParams;
15+
1416
import com.chargebee.v4.models.attachedItem.params.AttachedItemUpdateParams;
1517

1618
import com.chargebee.v4.models.attachedItem.params.AttachedItemsForItemParams;
@@ -73,6 +75,22 @@ Response retrieveRaw(String attachedItemId) throws Exception {
7375
return get(path, null);
7476
}
7577

78+
/**
79+
* retrieve a attachedItem using immutable params (executes immediately) - returns raw Response.
80+
*/
81+
Response retrieveRaw(String attachedItemId, AttachedItemRetrieveParams params) throws Exception {
82+
String path =
83+
buildPathWithParams(
84+
"/attached_items/{attached-item-id}", "attached-item-id", attachedItemId);
85+
return get(path, params != null ? params.toQueryParams() : null);
86+
}
87+
88+
public AttachedItemRetrieveResponse retrieve(
89+
String attachedItemId, AttachedItemRetrieveParams params) throws Exception {
90+
Response response = retrieveRaw(attachedItemId, params);
91+
return AttachedItemRetrieveResponse.fromJson(response.getBodyAsString(), response);
92+
}
93+
7694
public AttachedItemRetrieveResponse retrieve(String attachedItemId) throws Exception {
7795
Response response = retrieveRaw(attachedItemId);
7896
return AttachedItemRetrieveResponse.fromJson(response.getBodyAsString(), response);

src/main/java/com/chargebee/v4/services/CreditNoteService.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
import com.chargebee.v4.models.creditNote.params.RemoveTaxWithheldRefundForCreditNoteParams;
3333

34+
import com.chargebee.v4.models.creditNote.params.CreditNoteRetrieveParams;
35+
3436
import com.chargebee.v4.models.creditNote.responses.RecordRefundForCreditNoteResponse;
3537

3638
import com.chargebee.v4.models.creditNote.responses.ImportCreditNoteResponse;
@@ -493,6 +495,19 @@ Response retrieveRaw(String creditNoteId) throws Exception {
493495
return get(path, null);
494496
}
495497

498+
/** retrieve a creditNote using immutable params (executes immediately) - returns raw Response. */
499+
Response retrieveRaw(String creditNoteId, CreditNoteRetrieveParams params) throws Exception {
500+
String path =
501+
buildPathWithParams("/credit_notes/{credit-note-id}", "credit-note-id", creditNoteId);
502+
return get(path, params != null ? params.toQueryParams() : null);
503+
}
504+
505+
public CreditNoteRetrieveResponse retrieve(String creditNoteId, CreditNoteRetrieveParams params)
506+
throws Exception {
507+
Response response = retrieveRaw(creditNoteId, params);
508+
return CreditNoteRetrieveResponse.fromJson(response.getBodyAsString(), response);
509+
}
510+
496511
public CreditNoteRetrieveResponse retrieve(String creditNoteId) throws Exception {
497512
Response response = retrieveRaw(creditNoteId);
498513
return CreditNoteRetrieveResponse.fromJson(response.getBodyAsString(), response);

src/main/java/com/chargebee/v4/services/CustomerService.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
import com.chargebee.v4.models.customer.params.CustomerMoveParams;
2525

26+
import com.chargebee.v4.models.customer.params.HierarchyForCustomerParams;
27+
2628
import com.chargebee.v4.models.customer.params.UpdatePaymentMethodForCustomerParams;
2729

2830
import com.chargebee.v4.models.customer.params.CustomerUpdateParams;
@@ -358,6 +360,23 @@ Response hierarchyForCustomerRaw(String customerId) throws Exception {
358360
return get(path, null);
359361
}
360362

363+
/**
364+
* hierarchyForCustomer a customer using immutable params (executes immediately) - returns raw
365+
* Response.
366+
*/
367+
Response hierarchyForCustomerRaw(String customerId, HierarchyForCustomerParams params)
368+
throws Exception {
369+
String path =
370+
buildPathWithParams("/customers/{customer-id}/hierarchy", "customer-id", customerId);
371+
return get(path, params != null ? params.toQueryParams() : null);
372+
}
373+
374+
public HierarchyForCustomerResponse hierarchyForCustomer(
375+
String customerId, HierarchyForCustomerParams params) throws Exception {
376+
Response response = hierarchyForCustomerRaw(customerId, params);
377+
return HierarchyForCustomerResponse.fromJson(response.getBodyAsString(), response);
378+
}
379+
361380
public HierarchyForCustomerResponse hierarchyForCustomer(String customerId) throws Exception {
362381
Response response = hierarchyForCustomerRaw(customerId);
363382
return HierarchyForCustomerResponse.fromJson(response.getBodyAsString(), response);

src/main/java/com/chargebee/v4/services/DifferentialPriceService.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import com.chargebee.v4.models.differentialPrice.params.DifferentialPriceListParams;
1919

20+
import com.chargebee.v4.models.differentialPrice.params.DifferentialPriceRetrieveParams;
21+
2022
import com.chargebee.v4.models.differentialPrice.params.DifferentialPriceUpdateParams;
2123

2224
import com.chargebee.v4.models.differentialPrice.responses.DeleteDifferentialPriceResponse;
@@ -196,6 +198,26 @@ Response retrieveRaw(String differentialPriceId) throws Exception {
196198
return get(path, null);
197199
}
198200

201+
/**
202+
* retrieve a differentialPrice using immutable params (executes immediately) - returns raw
203+
* Response.
204+
*/
205+
Response retrieveRaw(String differentialPriceId, DifferentialPriceRetrieveParams params)
206+
throws Exception {
207+
String path =
208+
buildPathWithParams(
209+
"/differential_prices/{differential-price-id}",
210+
"differential-price-id",
211+
differentialPriceId);
212+
return get(path, params != null ? params.toQueryParams() : null);
213+
}
214+
215+
public DifferentialPriceRetrieveResponse retrieve(
216+
String differentialPriceId, DifferentialPriceRetrieveParams params) throws Exception {
217+
Response response = retrieveRaw(differentialPriceId, params);
218+
return DifferentialPriceRetrieveResponse.fromJson(response.getBodyAsString(), response);
219+
}
220+
199221
public DifferentialPriceRetrieveResponse retrieve(String differentialPriceId) throws Exception {
200222
Response response = retrieveRaw(differentialPriceId);
201223
return DifferentialPriceRetrieveResponse.fromJson(response.getBodyAsString(), response);

src/main/java/com/chargebee/v4/services/EstimateService.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import com.chargebee.v4.client.request.RequestOptions;
1212
import com.chargebee.v4.transport.Response;
1313

14+
import com.chargebee.v4.models.estimate.params.RenewalEstimateForSubscriptionParams;
15+
1416
import com.chargebee.v4.models.estimate.params.EstimateCreateSubscriptionForItemsParams;
1517

1618
import com.chargebee.v4.models.estimate.params.EstimatePaymentSchedulesParams;
@@ -39,6 +41,8 @@
3941

4042
import com.chargebee.v4.models.estimate.params.EstimateGiftSubscriptionParams;
4143

44+
import com.chargebee.v4.models.estimate.params.CreateSubscriptionEstimateForCustomerParams;
45+
4246
import com.chargebee.v4.models.estimate.params.EstimateCreateSubscriptionParams;
4347

4448
import com.chargebee.v4.models.estimate.params.EstimateCreateInvoiceParams;
@@ -128,6 +132,24 @@ Response renewalEstimateForSubscriptionRaw(String subscriptionId) throws Excepti
128132
return get(path, null);
129133
}
130134

135+
/**
136+
* renewalEstimateForSubscription a estimate using immutable params (executes immediately) -
137+
* returns raw Response.
138+
*/
139+
Response renewalEstimateForSubscriptionRaw(
140+
String subscriptionId, RenewalEstimateForSubscriptionParams params) throws Exception {
141+
String path =
142+
buildPathWithParams(
143+
"/subscriptions/{subscription-id}/renewal_estimate", "subscription-id", subscriptionId);
144+
return get(path, params != null ? params.toQueryParams() : null);
145+
}
146+
147+
public RenewalEstimateForSubscriptionResponse renewalEstimateForSubscription(
148+
String subscriptionId, RenewalEstimateForSubscriptionParams params) throws Exception {
149+
Response response = renewalEstimateForSubscriptionRaw(subscriptionId, params);
150+
return RenewalEstimateForSubscriptionResponse.fromJson(response.getBodyAsString(), response);
151+
}
152+
131153
public RenewalEstimateForSubscriptionResponse renewalEstimateForSubscription(
132154
String subscriptionId) throws Exception {
133155
Response response = renewalEstimateForSubscriptionRaw(subscriptionId);
@@ -702,6 +724,25 @@ Response createSubscriptionEstimateForCustomerRaw(String customerId) throws Exce
702724
return get(path, null);
703725
}
704726

727+
/**
728+
* createSubscriptionEstimateForCustomer a estimate using immutable params (executes immediately)
729+
* - returns raw Response.
730+
*/
731+
Response createSubscriptionEstimateForCustomerRaw(
732+
String customerId, CreateSubscriptionEstimateForCustomerParams params) throws Exception {
733+
String path =
734+
buildPathWithParams(
735+
"/customers/{customer-id}/create_subscription_estimate", "customer-id", customerId);
736+
return get(path, params != null ? params.toQueryParams() : null);
737+
}
738+
739+
public CreateSubscriptionEstimateForCustomerResponse createSubscriptionEstimateForCustomer(
740+
String customerId, CreateSubscriptionEstimateForCustomerParams params) throws Exception {
741+
Response response = createSubscriptionEstimateForCustomerRaw(customerId, params);
742+
return CreateSubscriptionEstimateForCustomerResponse.fromJson(
743+
response.getBodyAsString(), response);
744+
}
745+
705746
public CreateSubscriptionEstimateForCustomerResponse createSubscriptionEstimateForCustomer(
706747
String customerId) throws Exception {
707748
Response response = createSubscriptionEstimateForCustomerRaw(customerId);

src/main/java/com/chargebee/v4/services/InvoiceService.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141

4242
import com.chargebee.v4.models.invoice.params.ApplyCreditsForInvoiceParams;
4343

44+
import com.chargebee.v4.models.invoice.params.InvoiceRetrieveParams;
45+
4446
import com.chargebee.v4.models.invoice.params.InvoiceCreateForChargeItemParams;
4547

4648
import com.chargebee.v4.models.invoice.params.InvoiceCreateForChargeItemsAndChargesParams;
@@ -718,6 +720,18 @@ Response retrieveRaw(String invoiceId) throws Exception {
718720
return get(path, null);
719721
}
720722

723+
/** retrieve a invoice using immutable params (executes immediately) - returns raw Response. */
724+
Response retrieveRaw(String invoiceId, InvoiceRetrieveParams params) throws Exception {
725+
String path = buildPathWithParams("/invoices/{invoice-id}", "invoice-id", invoiceId);
726+
return get(path, params != null ? params.toQueryParams() : null);
727+
}
728+
729+
public InvoiceRetrieveResponse retrieve(String invoiceId, InvoiceRetrieveParams params)
730+
throws Exception {
731+
Response response = retrieveRaw(invoiceId, params);
732+
return InvoiceRetrieveResponse.fromJson(response.getBodyAsString(), response);
733+
}
734+
721735
public InvoiceRetrieveResponse retrieve(String invoiceId) throws Exception {
722736
Response response = retrieveRaw(invoiceId);
723737
return InvoiceRetrieveResponse.fromJson(response.getBodyAsString(), response);

src/main/java/com/chargebee/v4/services/UsageService.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
import com.chargebee.v4.models.usage.params.UsagePdfParams;
1515

16+
import com.chargebee.v4.models.usage.params.UsagesForSubscriptionParams;
17+
1618
import com.chargebee.v4.models.usage.params.AddUsageForSubscriptionParams;
1719

1820
import com.chargebee.v4.models.usage.params.DeleteUsageForSubscriptionParams;
@@ -90,6 +92,24 @@ Response usagesForSubscriptionRaw(String subscriptionId) throws Exception {
9092
return get(path, null);
9193
}
9294

95+
/**
96+
* usagesForSubscription a usage using immutable params (executes immediately) - returns raw
97+
* Response.
98+
*/
99+
Response usagesForSubscriptionRaw(String subscriptionId, UsagesForSubscriptionParams params)
100+
throws Exception {
101+
String path =
102+
buildPathWithParams(
103+
"/subscriptions/{subscription-id}/usages", "subscription-id", subscriptionId);
104+
return get(path, params != null ? params.toQueryParams() : null);
105+
}
106+
107+
public UsagesForSubscriptionResponse usagesForSubscription(
108+
String subscriptionId, UsagesForSubscriptionParams params) throws Exception {
109+
Response response = usagesForSubscriptionRaw(subscriptionId, params);
110+
return UsagesForSubscriptionResponse.fromJson(response.getBodyAsString(), response);
111+
}
112+
93113
public UsagesForSubscriptionResponse usagesForSubscription(String subscriptionId)
94114
throws Exception {
95115
Response response = usagesForSubscriptionRaw(subscriptionId);

0 commit comments

Comments
 (0)