Skip to content

Commit 7b1df46

Browse files
Merge pull request #2085 from stripe/latest-codegen-private-preview
Update generated code for private-preview
2 parents dc97c3e + 770eb43 commit 7b1df46

File tree

46 files changed

+19818
-9413
lines changed

Some content is hidden

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

46 files changed

+19818
-9413
lines changed

API_VERSION

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

OPENAPI_VERSION

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

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

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// File generated from our OpenAPI spec
2+
package com.stripe.events;
3+
4+
import com.google.gson.annotations.SerializedName;
5+
import com.stripe.exception.StripeException;
6+
import com.stripe.model.v2.core.Account;
7+
import com.stripe.model.v2.core.Event;
8+
import com.stripe.model.v2.core.Event.RelatedObject;
9+
import lombok.Getter;
10+
import lombok.Setter;
11+
12+
@Getter
13+
public final class V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEvent
14+
extends Event {
15+
/** Data for the v2.core.account[configuration.card_creator].capability_status_updated event. */
16+
@SerializedName("data")
17+
V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEvent.EventData data;
18+
19+
@Getter
20+
@Setter
21+
public static final class EventData {
22+
/**
23+
* Open Enum. The capability which had its status updated.
24+
*
25+
* <p>One of {@code commercial.celtic.charge_card}, {@code commercial.celtic.spend_card}, {@code
26+
* commercial.cross_river_bank.charge_card}, {@code commercial.cross_river_bank.spend_card},
27+
* {@code commercial.stripe.charge_card}, or {@code commercial.stripe.prepaid_card}.
28+
*/
29+
@SerializedName("updated_capability")
30+
String updatedCapability;
31+
}
32+
33+
@SerializedName("related_object")
34+
35+
/** Object containing the reference to API resource relevant to the event. */
36+
RelatedObject relatedObject;
37+
38+
/** Retrieves the related object from the API. Make an API request on every call. */
39+
public Account fetchRelatedObject() throws StripeException {
40+
return (Account) super.fetchRelatedObject(this.relatedObject);
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// File generated from our OpenAPI spec
2+
package com.stripe.events;
3+
4+
import com.google.gson.annotations.SerializedName;
5+
import com.stripe.exception.StripeException;
6+
import com.stripe.model.v2.core.Account;
7+
import com.stripe.model.v2.core.Event.RelatedObject;
8+
import com.stripe.model.v2.core.EventNotification;
9+
import lombok.Getter;
10+
11+
@Getter
12+
public final
13+
class V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEventNotification
14+
extends EventNotification {
15+
@SerializedName("related_object")
16+
17+
/** Object containing the reference to API resource relevant to the event. */
18+
RelatedObject relatedObject;
19+
20+
/** Retrieves the related object from the API. Make an API request on every call. */
21+
public Account fetchRelatedObject() throws StripeException {
22+
return (Account) super.fetchRelatedObject(this.relatedObject);
23+
}
24+
/** Retrieve the corresponding full event from the Stripe API. */
25+
@Override
26+
public V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEvent fetchEvent()
27+
throws StripeException {
28+
return (V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEvent)
29+
super.fetchEvent();
30+
}
31+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// File generated from our OpenAPI spec
2+
package com.stripe.events;
3+
4+
import com.google.gson.annotations.SerializedName;
5+
import com.stripe.exception.StripeException;
6+
import com.stripe.model.v2.core.Account;
7+
import com.stripe.model.v2.core.Event;
8+
import com.stripe.model.v2.core.Event.RelatedObject;
9+
import lombok.Getter;
10+
11+
@Getter
12+
public final class V2CoreAccountIncludingConfigurationCardCreatorUpdatedEvent extends Event {
13+
@SerializedName("related_object")
14+
15+
/** Object containing the reference to API resource relevant to the event. */
16+
RelatedObject relatedObject;
17+
18+
/** Retrieves the related object from the API. Make an API request on every call. */
19+
public Account fetchRelatedObject() throws StripeException {
20+
return (Account) super.fetchRelatedObject(this.relatedObject);
21+
}
22+
}

src/main/java/com/stripe/events/V2BillingBillSettingUpdatedEventNotification.java renamed to src/main/java/com/stripe/events/V2CoreAccountIncludingConfigurationCardCreatorUpdatedEventNotification.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@
33

44
import com.google.gson.annotations.SerializedName;
55
import com.stripe.exception.StripeException;
6-
import com.stripe.model.v2.billing.BillSetting;
6+
import com.stripe.model.v2.core.Account;
77
import com.stripe.model.v2.core.Event.RelatedObject;
88
import com.stripe.model.v2.core.EventNotification;
99
import lombok.Getter;
1010

1111
@Getter
12-
public final class V2BillingBillSettingUpdatedEventNotification extends EventNotification {
12+
public final class V2CoreAccountIncludingConfigurationCardCreatorUpdatedEventNotification
13+
extends EventNotification {
1314
@SerializedName("related_object")
1415

1516
/** Object containing the reference to API resource relevant to the event. */
1617
RelatedObject relatedObject;
1718

1819
/** Retrieves the related object from the API. Make an API request on every call. */
19-
public BillSetting fetchRelatedObject() throws StripeException {
20-
return (BillSetting) super.fetchRelatedObject(this.relatedObject);
20+
public Account fetchRelatedObject() throws StripeException {
21+
return (Account) super.fetchRelatedObject(this.relatedObject);
2122
}
2223
/** Retrieve the corresponding full event from the Stripe API. */
2324
@Override
24-
public V2BillingBillSettingUpdatedEvent fetchEvent() throws StripeException {
25-
return (V2BillingBillSettingUpdatedEvent) super.fetchEvent();
25+
public V2CoreAccountIncludingConfigurationCardCreatorUpdatedEvent fetchEvent()
26+
throws StripeException {
27+
return (V2CoreAccountIncludingConfigurationCardCreatorUpdatedEvent) super.fetchEvent();
2628
}
2729
}

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

0 commit comments

Comments
 (0)