Skip to content

Commit f65e5e7

Browse files
Merge pull request #2081 from stripe/latest-codegen-beta
Update generated code for beta
2 parents c81732b + 56d5f49 commit f65e5e7

File tree

113 files changed

+8200
-575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+8200
-575
lines changed

API_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0de52cdca31a7c51c6d11187fc88ab23ea3a1c5b
1+
577fcb57736b925392ea563c0284df9002c75ac9

OPENAPI_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2031
1+
v2099

src/main/java/com/stripe/events/V2BillingBillSettingUpdatedEvent.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/main/java/com/stripe/events/V2BillingBillSettingUpdatedEventNotification.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/java/com/stripe/events/V2MoneyManagementTransactionCreatedEvent.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,22 @@
77
import com.stripe.model.v2.core.Event.RelatedObject;
88
import com.stripe.model.v2.moneymanagement.Transaction;
99
import lombok.Getter;
10+
import lombok.Setter;
1011

1112
@Getter
1213
public final class V2MoneyManagementTransactionCreatedEvent extends Event {
14+
/** Data for the v2.money_management.transaction.created event. */
15+
@SerializedName("data")
16+
V2MoneyManagementTransactionCreatedEvent.EventData data;
17+
18+
@Getter
19+
@Setter
20+
public static final class EventData {
21+
/** Id of the v1 Transaction corresponding to this Transaction. */
22+
@SerializedName("v1_id")
23+
String v1Id;
24+
}
25+
1326
@SerializedName("related_object")
1427

1528
/** Object containing the reference to API resource relevant to the event. */

src/main/java/com/stripe/examples/EventNotificationWebhookHandler.java

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.stripe.events.V1BillingMeterErrorReportTriggeredEventNotification;
77
import com.stripe.exception.StripeException;
88
import com.stripe.model.billing.Meter;
9-
import com.stripe.model.v2.core.Event;
109
import com.stripe.model.v2.core.EventNotification;
1110
import com.sun.net.httpserver.HttpExchange;
1211
import com.sun.net.httpserver.HttpHandler;
@@ -67,33 +66,39 @@ public void handle(HttpExchange exchange) throws IOException {
6766
String sigHeader = exchange.getRequestHeaders().getFirst("Stripe-Signature");
6867

6968
try {
70-
EventNotification eventNotif =
69+
EventNotification notif =
7170
client.parseEventNotification(webhookBody, sigHeader, WEBHOOK_SECRET);
7271

73-
// determine what sort of event you have
74-
if (eventNotif instanceof V1BillingMeterErrorReportTriggeredEventNotification) {
72+
if (notif instanceof V1BillingMeterErrorReportTriggeredEventNotification) {
7573
V1BillingMeterErrorReportTriggeredEventNotification eventNotification =
76-
(V1BillingMeterErrorReportTriggeredEventNotification) eventNotif;
74+
(V1BillingMeterErrorReportTriggeredEventNotification) notif;
7775

78-
// after casting, can fetch the related object (which is correctly typed)
79-
Meter meter = eventNotification.fetchRelatedObject();
80-
System.out.println(meter.getId());
76+
// there's basic info about the related object in the notification
77+
System.out.println(
78+
"Meter w/ id " + eventNotification.getRelatedObject().getId() + " had a problem");
8179

80+
// or you can fetch the full object form the API for more details
81+
Meter meter = eventNotification.fetchRelatedObject();
82+
StringBuilder sb = new StringBuilder();
83+
sb.append("Meter ")
84+
.append(meter.getDisplayName())
85+
.append(" (")
86+
.append(meter.getId())
87+
.append(") had a problem");
88+
System.out.println(sb.toString());
89+
90+
// And you can always fetch the full event:
8291
V1BillingMeterErrorReportTriggeredEvent event = eventNotification.fetchEvent();
83-
System.out.println(event.getData().getDeveloperMessageSummary());
84-
85-
// add additional logic
86-
}
87-
// ... check other event types you know about
88-
else if (eventNotif instanceof UnknownEventNotification) {
89-
UnknownEventNotification unknownEvent = (UnknownEventNotification) eventNotif;
90-
System.out.println("Received unknown event: " + unknownEvent.getId());
91-
// can keep matching on the "type" field
92-
// other helper methods still work, but you'll have to handle types yourself
92+
System.out.println("More info: " + event.getData().getDeveloperMessageSummary());
93+
} else if (notif instanceof UnknownEventNotification) {
94+
// Events that were introduced after this SDK version release are
95+
// represented as `UnknownEventNotification`s.
96+
// They're valid, the SDK just doesn't have corresponding classes for them.
97+
// You must match on the "type" property instead.
98+
UnknownEventNotification unknownEvent = (UnknownEventNotification) notif;
9399
if (unknownEvent.getType().equals("some.new.event")) {
94-
Event event = unknownEvent.fetchEvent();
95-
System.out.println(event.getReason());
96-
// handle
100+
// you can still `.fetchEvent()` and `.fetchRelatedObject()`, but the latter may
101+
// return `null` if that event type doesn't have a related object.
97102
}
98103
}
99104

src/main/java/com/stripe/exception/AlreadyCanceledException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.stripe.model.StripeObject;
77
import com.stripe.net.StripeResponseGetter;
88

9-
/** Information about the error that occurred. */
9+
/** Error returned when user tries to cancel an OutboundPayment that was already canceled. */
1010
public final class AlreadyCanceledException extends ApiException {
1111
private static final long serialVersionUID = 2L;
1212

src/main/java/com/stripe/exception/AlreadyExistsException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.stripe.model.StripeObject;
77
import com.stripe.net.StripeResponseGetter;
88

9-
/** Information about the error that occurred. */
9+
/** The resource already exists. */
1010
public final class AlreadyExistsException extends ApiException {
1111
private static final long serialVersionUID = 2L;
1212

src/main/java/com/stripe/exception/BlockedByStripeException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.stripe.model.StripeObject;
77
import com.stripe.net.StripeResponseGetter;
88

9-
/** Information about the error that occurred. */
9+
/** Returned when the bank account cannot be added due to previous suspicious activity. */
1010
public final class BlockedByStripeException extends ApiException {
1111
private static final long serialVersionUID = 2L;
1212

src/main/java/com/stripe/exception/ControlledByDashboardException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
import com.stripe.model.StripeObject;
77
import com.stripe.net.StripeResponseGetter;
88

9-
/** Information about the error that occurred. */
9+
/**
10+
* Returned when the PayoutMethodBankAccount object is controlled by the Stripe Dashboard, and
11+
* cannot be archived.
12+
*/
1013
public final class ControlledByDashboardException extends ApiException {
1114
private static final long serialVersionUID = 2L;
1215

0 commit comments

Comments
 (0)