|
2 | 2 | package com.stripe.model;
|
3 | 3 |
|
4 | 4 | import com.google.gson.annotations.SerializedName;
|
| 5 | +import com.stripe.exception.StripeException; |
| 6 | +import com.stripe.net.ApiMode; |
| 7 | +import com.stripe.net.ApiRequestParams; |
5 | 8 | import com.stripe.net.ApiResource;
|
| 9 | +import com.stripe.net.BaseAddress; |
| 10 | +import com.stripe.net.RequestOptions; |
| 11 | +import com.stripe.net.StripeResponseGetter; |
| 12 | +import com.stripe.param.InvoiceLineItemUpdateParams; |
6 | 13 | import java.math.BigDecimal;
|
7 | 14 | import java.util.List;
|
8 | 15 | import java.util.Map;
|
|
14 | 21 | @Getter
|
15 | 22 | @Setter
|
16 | 23 | @EqualsAndHashCode(callSuper = false)
|
17 |
| -public class InvoiceLineItem extends StripeObject implements HasId { |
| 24 | +public class InvoiceLineItem extends ApiResource implements HasId { |
18 | 25 | /** The amount, in cents (or local equivalent). */
|
19 | 26 | @SerializedName("amount")
|
20 | 27 | Long amount;
|
@@ -249,6 +256,79 @@ public void setDiscountObjects(List<Discount> objs) {
|
249 | 256 | : null;
|
250 | 257 | }
|
251 | 258 |
|
| 259 | + /** |
| 260 | + * Updates an invoice’s line item. Some fields, such as {@code tax_amounts}, only live on the |
| 261 | + * invoice line item, so they can only be updated through this endpoint. Other fields, such as |
| 262 | + * {@code amount}, live on both the invoice item and the invoice line item, so updates on this |
| 263 | + * endpoint will propagate to the invoice item as well. Updating an invoice’s line item is only |
| 264 | + * possible before the invoice is finalized. |
| 265 | + */ |
| 266 | + public InvoiceLineItem update(String invoice, Map<String, Object> params) throws StripeException { |
| 267 | + return update(invoice, params, (RequestOptions) null); |
| 268 | + } |
| 269 | + |
| 270 | + /** |
| 271 | + * Updates an invoice’s line item. Some fields, such as {@code tax_amounts}, only live on the |
| 272 | + * invoice line item, so they can only be updated through this endpoint. Other fields, such as |
| 273 | + * {@code amount}, live on both the invoice item and the invoice line item, so updates on this |
| 274 | + * endpoint will propagate to the invoice item as well. Updating an invoice’s line item is only |
| 275 | + * possible before the invoice is finalized. |
| 276 | + */ |
| 277 | + public InvoiceLineItem update(String invoice, Map<String, Object> params, RequestOptions options) |
| 278 | + throws StripeException { |
| 279 | + String path = |
| 280 | + String.format( |
| 281 | + "/v1/invoices/%s/lines/%s", |
| 282 | + ApiResource.urlEncodeId(invoice), ApiResource.urlEncodeId(this.getId())); |
| 283 | + return getResponseGetter() |
| 284 | + .request( |
| 285 | + BaseAddress.API, |
| 286 | + ApiResource.RequestMethod.POST, |
| 287 | + path, |
| 288 | + params, |
| 289 | + InvoiceLineItem.class, |
| 290 | + options, |
| 291 | + ApiMode.V1); |
| 292 | + } |
| 293 | + |
| 294 | + /** |
| 295 | + * Updates an invoice’s line item. Some fields, such as {@code tax_amounts}, only live on the |
| 296 | + * invoice line item, so they can only be updated through this endpoint. Other fields, such as |
| 297 | + * {@code amount}, live on both the invoice item and the invoice line item, so updates on this |
| 298 | + * endpoint will propagate to the invoice item as well. Updating an invoice’s line item is only |
| 299 | + * possible before the invoice is finalized. |
| 300 | + */ |
| 301 | + public InvoiceLineItem update(String invoice, InvoiceLineItemUpdateParams params) |
| 302 | + throws StripeException { |
| 303 | + return update(invoice, params, (RequestOptions) null); |
| 304 | + } |
| 305 | + |
| 306 | + /** |
| 307 | + * Updates an invoice’s line item. Some fields, such as {@code tax_amounts}, only live on the |
| 308 | + * invoice line item, so they can only be updated through this endpoint. Other fields, such as |
| 309 | + * {@code amount}, live on both the invoice item and the invoice line item, so updates on this |
| 310 | + * endpoint will propagate to the invoice item as well. Updating an invoice’s line item is only |
| 311 | + * possible before the invoice is finalized. |
| 312 | + */ |
| 313 | + public InvoiceLineItem update( |
| 314 | + String invoice, InvoiceLineItemUpdateParams params, RequestOptions options) |
| 315 | + throws StripeException { |
| 316 | + String path = |
| 317 | + String.format( |
| 318 | + "/v1/invoices/%s/lines/%s", |
| 319 | + ApiResource.urlEncodeId(invoice), ApiResource.urlEncodeId(this.getId())); |
| 320 | + ApiResource.checkNullTypedParams(path, params); |
| 321 | + return getResponseGetter() |
| 322 | + .request( |
| 323 | + BaseAddress.API, |
| 324 | + ApiResource.RequestMethod.POST, |
| 325 | + path, |
| 326 | + ApiRequestParams.paramsToMap(params), |
| 327 | + InvoiceLineItem.class, |
| 328 | + options, |
| 329 | + ApiMode.V1); |
| 330 | + } |
| 331 | + |
252 | 332 | @Getter
|
253 | 333 | @Setter
|
254 | 334 | @EqualsAndHashCode(callSuper = false)
|
@@ -376,4 +456,16 @@ public void setTaxRateObject(TaxRate expandableObject) {
|
376 | 456 | this.taxRate = new ExpandableField<TaxRate>(expandableObject.getId(), expandableObject);
|
377 | 457 | }
|
378 | 458 | }
|
| 459 | + |
| 460 | + @Override |
| 461 | + public void setResponseGetter(StripeResponseGetter responseGetter) { |
| 462 | + super.setResponseGetter(responseGetter); |
| 463 | + trySetResponseGetter(invoiceItem, responseGetter); |
| 464 | + trySetResponseGetter(period, responseGetter); |
| 465 | + trySetResponseGetter(plan, responseGetter); |
| 466 | + trySetResponseGetter(price, responseGetter); |
| 467 | + trySetResponseGetter(prorationDetails, responseGetter); |
| 468 | + trySetResponseGetter(subscription, responseGetter); |
| 469 | + trySetResponseGetter(subscriptionItem, responseGetter); |
| 470 | + } |
379 | 471 | }
|
0 commit comments