Skip to content

Commit e92add7

Browse files
remi-stripeob-stripe
authored andcommitted
Codegen for openapi ab6898a (#908)
1 parent d725e2d commit e92add7

File tree

5 files changed

+332
-15
lines changed

5 files changed

+332
-15
lines changed

src/main/java/com/stripe/model/CreditNote.java

+27
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.stripe.net.RequestOptions;
88
import com.stripe.param.CreditNoteCreateParams;
99
import com.stripe.param.CreditNoteListParams;
10+
import com.stripe.param.CreditNotePreviewParams;
1011
import com.stripe.param.CreditNoteRetrieveParams;
1112
import com.stripe.param.CreditNoteUpdateParams;
1213
import com.stripe.param.CreditNoteVoidCreditNoteParams;
@@ -317,6 +318,32 @@ public static CreditNote create(CreditNoteCreateParams params, RequestOptions op
317318
ApiResource.RequestMethod.POST, url, params, CreditNote.class, options);
318319
}
319320

321+
/** Get a preview of a credit note without creating it. */
322+
public static CreditNote preview(Map<String, Object> params) throws StripeException {
323+
return preview(params, (RequestOptions) null);
324+
}
325+
326+
/** Get a preview of a credit note without creating it. */
327+
public static CreditNote preview(Map<String, Object> params, RequestOptions options)
328+
throws StripeException {
329+
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/credit_notes/preview");
330+
return ApiResource.request(
331+
ApiResource.RequestMethod.GET, url, params, CreditNote.class, options);
332+
}
333+
334+
/** Get a preview of a credit note without creating it. */
335+
public static CreditNote preview(CreditNotePreviewParams params) throws StripeException {
336+
return preview(params, (RequestOptions) null);
337+
}
338+
339+
/** Get a preview of a credit note without creating it. */
340+
public static CreditNote preview(CreditNotePreviewParams params, RequestOptions options)
341+
throws StripeException {
342+
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/credit_notes/preview");
343+
return ApiResource.request(
344+
ApiResource.RequestMethod.GET, url, params, CreditNote.class, options);
345+
}
346+
320347
/** Retrieves the credit note object with the given identifier. */
321348
public static CreditNote retrieve(String id) throws StripeException {
322349
return retrieve(id, (Map<String, Object>) null, (RequestOptions) null);

src/main/java/com/stripe/model/Refund.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public class Refund extends ApiResource implements MetadataStore<Refund>, Balanc
9292
ExpandableField<PaymentIntent> paymentIntent;
9393

9494
/**
95-
* Reason for the refund. If set, possible values are `duplicate`, `fraudulent`, and
96-
* `requested_by_customer`.
95+
* Reason for the refund, either user-provided (`duplicate`, `fraudulent`, or
96+
* `requested_by_customer`) or generated by Stripe internally (`expired_uncaptured_charge`).
9797
*/
9898
@SerializedName("reason")
9999
String reason;

src/main/java/com/stripe/model/issuing/Card.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ public class Card extends ApiResource implements HasId, MetadataStore<Card> {
100100
@Setter(lombok.AccessLevel.NONE)
101101
ExpandableField<Card> replacementFor;
102102

103-
/**
104-
* Why the card that this card replaces (if any) needed to be replaced. One of `damage`,
105-
* `expiration`, `loss`, or `theft`.
106-
*/
103+
/** The reason why the previous card needed to be replaced. */
107104
@SerializedName("replacement_reason")
108105
String replacementReason;
109106

@@ -379,7 +376,7 @@ public static class AuthorizationControls extends StripeObject {
379376
@Setter
380377
@EqualsAndHashCode(callSuper = false)
381378
public static class Pin extends StripeObject {
382-
/** The status of the pin. One of `blocked` or `active`. */
379+
/** Wether the PIN will be accepted or not. */
383380
@SerializedName("status")
384381
String status;
385382
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
package com.stripe.param;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import com.stripe.net.ApiRequestParams;
5+
import java.util.ArrayList;
6+
import java.util.HashMap;
7+
import java.util.List;
8+
import java.util.Map;
9+
import lombok.Getter;
10+
11+
@Getter
12+
public class CreditNotePreviewParams extends ApiRequestParams {
13+
/** The integer amount in **%s** representing the total amount of the credit note. */
14+
@SerializedName("amount")
15+
Long amount;
16+
17+
/**
18+
* The integer amount in **%s** representing the amount to credit the customer's balance, which
19+
* will be automatically applied to their next invoice.
20+
*/
21+
@SerializedName("credit_amount")
22+
Long creditAmount;
23+
24+
/** Specifies which fields in the response should be expanded. */
25+
@SerializedName("expand")
26+
List<String> expand;
27+
28+
/**
29+
* Map of extra parameters for custom features not available in this client library. The content
30+
* in this map is not serialized under this field's {@code @SerializedName} value. Instead, each
31+
* key/value pair is serialized as if the key is a root-level field (serialized) name in this
32+
* param object. Effectively, this map is flattened to its parent instance.
33+
*/
34+
@SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY)
35+
Map<String, Object> extraParams;
36+
37+
/** ID of the invoice. */
38+
@SerializedName("invoice")
39+
String invoice;
40+
41+
/** The credit note's memo appears on the credit note PDF. */
42+
@SerializedName("memo")
43+
String memo;
44+
45+
/**
46+
* Set of key-value pairs that you can attach to an object. This can be useful for storing
47+
* additional information about the object in a structured format. Individual keys can be unset by
48+
* posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
49+
*/
50+
@SerializedName("metadata")
51+
Map<String, String> metadata;
52+
53+
/** The integer amount in **%s** representing the amount that is credited outside of Stripe. */
54+
@SerializedName("out_of_band_amount")
55+
Long outOfBandAmount;
56+
57+
/**
58+
* Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or
59+
* `product_unsatisfactory`.
60+
*/
61+
@SerializedName("reason")
62+
Reason reason;
63+
64+
/** ID of an existing refund to link this credit note to. */
65+
@SerializedName("refund")
66+
String refund;
67+
68+
/**
69+
* The integer amount in **%s** representing the amount to refund. If set, a refund will be
70+
* created for the charge associated with the invoice.
71+
*/
72+
@SerializedName("refund_amount")
73+
Long refundAmount;
74+
75+
private CreditNotePreviewParams(
76+
Long amount,
77+
Long creditAmount,
78+
List<String> expand,
79+
Map<String, Object> extraParams,
80+
String invoice,
81+
String memo,
82+
Map<String, String> metadata,
83+
Long outOfBandAmount,
84+
Reason reason,
85+
String refund,
86+
Long refundAmount) {
87+
this.amount = amount;
88+
this.creditAmount = creditAmount;
89+
this.expand = expand;
90+
this.extraParams = extraParams;
91+
this.invoice = invoice;
92+
this.memo = memo;
93+
this.metadata = metadata;
94+
this.outOfBandAmount = outOfBandAmount;
95+
this.reason = reason;
96+
this.refund = refund;
97+
this.refundAmount = refundAmount;
98+
}
99+
100+
public static Builder builder() {
101+
return new Builder();
102+
}
103+
104+
public static class Builder {
105+
private Long amount;
106+
107+
private Long creditAmount;
108+
109+
private List<String> expand;
110+
111+
private Map<String, Object> extraParams;
112+
113+
private String invoice;
114+
115+
private String memo;
116+
117+
private Map<String, String> metadata;
118+
119+
private Long outOfBandAmount;
120+
121+
private Reason reason;
122+
123+
private String refund;
124+
125+
private Long refundAmount;
126+
127+
/** Finalize and obtain parameter instance from this builder. */
128+
public CreditNotePreviewParams build() {
129+
return new CreditNotePreviewParams(
130+
this.amount,
131+
this.creditAmount,
132+
this.expand,
133+
this.extraParams,
134+
this.invoice,
135+
this.memo,
136+
this.metadata,
137+
this.outOfBandAmount,
138+
this.reason,
139+
this.refund,
140+
this.refundAmount);
141+
}
142+
143+
/** The integer amount in **%s** representing the total amount of the credit note. */
144+
public Builder setAmount(Long amount) {
145+
this.amount = amount;
146+
return this;
147+
}
148+
149+
/**
150+
* The integer amount in **%s** representing the amount to credit the customer's balance, which
151+
* will be automatically applied to their next invoice.
152+
*/
153+
public Builder setCreditAmount(Long creditAmount) {
154+
this.creditAmount = creditAmount;
155+
return this;
156+
}
157+
158+
/**
159+
* Add an element to `expand` list. A list is initialized for the first `add/addAll` call, and
160+
* subsequent calls adds additional elements to the original list. See {@link
161+
* CreditNotePreviewParams#expand} for the field documentation.
162+
*/
163+
public Builder addExpand(String element) {
164+
if (this.expand == null) {
165+
this.expand = new ArrayList<>();
166+
}
167+
this.expand.add(element);
168+
return this;
169+
}
170+
171+
/**
172+
* Add all elements to `expand` list. A list is initialized for the first `add/addAll` call, and
173+
* subsequent calls adds additional elements to the original list. See {@link
174+
* CreditNotePreviewParams#expand} for the field documentation.
175+
*/
176+
public Builder addAllExpand(List<String> elements) {
177+
if (this.expand == null) {
178+
this.expand = new ArrayList<>();
179+
}
180+
this.expand.addAll(elements);
181+
return this;
182+
}
183+
184+
/**
185+
* Add a key/value pair to `extraParams` map. A map is initialized for the first `put/putAll`
186+
* call, and subsequent calls add additional key/value pairs to the original map. See {@link
187+
* CreditNotePreviewParams#extraParams} for the field documentation.
188+
*/
189+
public Builder putExtraParam(String key, Object value) {
190+
if (this.extraParams == null) {
191+
this.extraParams = new HashMap<>();
192+
}
193+
this.extraParams.put(key, value);
194+
return this;
195+
}
196+
197+
/**
198+
* Add all map key/value pairs to `extraParams` map. A map is initialized for the first
199+
* `put/putAll` call, and subsequent calls add additional key/value pairs to the original map.
200+
* See {@link CreditNotePreviewParams#extraParams} for the field documentation.
201+
*/
202+
public Builder putAllExtraParam(Map<String, Object> map) {
203+
if (this.extraParams == null) {
204+
this.extraParams = new HashMap<>();
205+
}
206+
this.extraParams.putAll(map);
207+
return this;
208+
}
209+
210+
/** ID of the invoice. */
211+
public Builder setInvoice(String invoice) {
212+
this.invoice = invoice;
213+
return this;
214+
}
215+
216+
/** The credit note's memo appears on the credit note PDF. */
217+
public Builder setMemo(String memo) {
218+
this.memo = memo;
219+
return this;
220+
}
221+
222+
/**
223+
* Add a key/value pair to `metadata` map. A map is initialized for the first `put/putAll` call,
224+
* and subsequent calls add additional key/value pairs to the original map. See {@link
225+
* CreditNotePreviewParams#metadata} for the field documentation.
226+
*/
227+
public Builder putMetadata(String key, String value) {
228+
if (this.metadata == null) {
229+
this.metadata = new HashMap<>();
230+
}
231+
this.metadata.put(key, value);
232+
return this;
233+
}
234+
235+
/**
236+
* Add all map key/value pairs to `metadata` map. A map is initialized for the first
237+
* `put/putAll` call, and subsequent calls add additional key/value pairs to the original map.
238+
* See {@link CreditNotePreviewParams#metadata} for the field documentation.
239+
*/
240+
public Builder putAllMetadata(Map<String, String> map) {
241+
if (this.metadata == null) {
242+
this.metadata = new HashMap<>();
243+
}
244+
this.metadata.putAll(map);
245+
return this;
246+
}
247+
248+
/** The integer amount in **%s** representing the amount that is credited outside of Stripe. */
249+
public Builder setOutOfBandAmount(Long outOfBandAmount) {
250+
this.outOfBandAmount = outOfBandAmount;
251+
return this;
252+
}
253+
254+
/**
255+
* Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or
256+
* `product_unsatisfactory`.
257+
*/
258+
public Builder setReason(Reason reason) {
259+
this.reason = reason;
260+
return this;
261+
}
262+
263+
/** ID of an existing refund to link this credit note to. */
264+
public Builder setRefund(String refund) {
265+
this.refund = refund;
266+
return this;
267+
}
268+
269+
/**
270+
* The integer amount in **%s** representing the amount to refund. If set, a refund will be
271+
* created for the charge associated with the invoice.
272+
*/
273+
public Builder setRefundAmount(Long refundAmount) {
274+
this.refundAmount = refundAmount;
275+
return this;
276+
}
277+
}
278+
279+
public enum Reason implements ApiRequestParams.EnumParam {
280+
@SerializedName("duplicate")
281+
DUPLICATE("duplicate"),
282+
283+
@SerializedName("fraudulent")
284+
FRAUDULENT("fraudulent"),
285+
286+
@SerializedName("order_change")
287+
ORDER_CHANGE("order_change"),
288+
289+
@SerializedName("product_unsatisfactory")
290+
PRODUCT_UNSATISFACTORY("product_unsatisfactory");
291+
292+
@Getter(onMethod_ = {@Override})
293+
private final String value;
294+
295+
Reason(String value) {
296+
this.value = value;
297+
}
298+
}
299+
}

src/main/java/com/stripe/param/issuing/CardCreateParams.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ public class CardCreateParams extends ApiRequestParams {
5151
@SerializedName("replacement_for")
5252
String replacementFor;
5353

54-
/**
55-
* If `replacement_for` is specified, this should indicate why that card is being replaced. One of
56-
* `damage`, `expiration`, `loss`, or `theft`.
57-
*/
54+
/** If `replacement_for` is specified, this should indicate why that card is being replaced. */
5855
@SerializedName("replacement_reason")
5956
ReplacementReason replacementReason;
6057

@@ -250,10 +247,7 @@ public Builder setReplacementFor(String replacementFor) {
250247
return this;
251248
}
252249

253-
/**
254-
* If `replacement_for` is specified, this should indicate why that card is being replaced. One
255-
* of `damage`, `expiration`, `loss`, or `theft`.
256-
*/
250+
/** If `replacement_for` is specified, this should indicate why that card is being replaced. */
257251
public Builder setReplacementReason(ReplacementReason replacementReason) {
258252
this.replacementReason = replacementReason;
259253
return this;

0 commit comments

Comments
 (0)