-
Notifications
You must be signed in to change notification settings - Fork 586
add event handler class #3250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: beta
Are you sure you want to change the base?
add event handler class #3250
Changes from all commits
3e3987b
8e523d0
12752f4
513e659
2c14ecf
05217ff
adf492b
13d1651
c1e8899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| namespace Stripe | ||
| { | ||
| using System; | ||
|
|
||
| /// <summary> | ||
| /// EventArgs for Stripe webhook event notifications. | ||
| /// Contains the strongly-typed EventNotification and the StripeClient instance. | ||
| /// </summary> | ||
| /// <typeparam name="TEventNotification">The type of EventNotification.</typeparam> | ||
| public class StripeEventNotificationEventArgs<TEventNotification> : EventArgs | ||
| where TEventNotification : V2.Core.EventNotification | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="StripeEventNotificationEventArgs{TEventNotification}"/> class. | ||
| /// </summary> | ||
| /// <param name="eventNotification">The event notification instance.</param> | ||
| /// <param name="client">The StripeClient instance.</param> | ||
| public StripeEventNotificationEventArgs(TEventNotification eventNotification, StripeClient client) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will this ever get constructed outside of our SDK code? If not, I would consider changing this constructor to be internal
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't users need it for tests? Like, if they write their function and want to test it in isolation, that function takes these args and they'd nee to be able to construct it? |
||
| { | ||
| this.EventNotification = eventNotification ?? throw new ArgumentNullException(nameof(eventNotification)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its a small nit, but can you pull the null check and throw into a separate line/conditional? I find that easier to read |
||
| this.Client = client ?? throw new ArgumentNullException(nameof(client)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the event notification instance. | ||
| /// </summary> | ||
| public TEventNotification EventNotification { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the StripeClient instance that can be used to make API requests. | ||
| /// </summary> | ||
| public StripeClient Client { get; } | ||
| } | ||
| } | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| namespace Stripe | ||
| { | ||
| using System; | ||
|
|
||
| /// <summary> | ||
| /// EventArgs for Stripe webhook event notifications. | ||
| /// Contains the strongly-typed EventNotification and the StripeClient instance. | ||
| /// </summary> | ||
| public class StripeUnhandledEventNotificationEventArgs : EventArgs | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="StripeUnhandledEventNotificationEventArgs"/> class. | ||
| /// </summary> | ||
| /// <param name="eventNotification">The event notification instance.</param> | ||
| /// <param name="client">The StripeClient instance.</param> | ||
| /// <param name="details">Details about the unhandled notification.</param> | ||
| public StripeUnhandledEventNotificationEventArgs(V2.Core.EventNotification eventNotification, StripeClient client, UnhandledNotificationDetails details) | ||
| { | ||
| this.EventNotification = eventNotification ?? throw new ArgumentNullException(nameof(eventNotification)); | ||
| this.Client = client ?? throw new ArgumentNullException(nameof(client)); | ||
| this.Details = details ?? throw new ArgumentNullException(nameof(details)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the event notification instance. | ||
| /// </summary> | ||
| public V2.Core.EventNotification EventNotification { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the StripeClient instance that can be used to make API requests. | ||
| /// </summary> | ||
| public StripeClient Client { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets details about the unhandled notification. | ||
| /// </summary> | ||
| public UnhandledNotificationDetails Details { get; } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| namespace Stripe | ||
| { | ||
| /// <summary> | ||
| /// EventArgs for Stripe webhook event notifications. | ||
| /// Contains the strongly-typed EventNotification and the StripeClient instance. | ||
| /// </summary> | ||
| public class UnhandledNotificationDetails | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="UnhandledNotificationDetails"/> class. | ||
| /// </summary> | ||
| public UnhandledNotificationDetails(bool isKnownEventType) | ||
| { | ||
| this.IsKnownEventType = isKnownEventType; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the StripeClient instance that can be used to make API requests. | ||
| /// </summary> | ||
| public bool IsKnownEventType { get; } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Env isn't shared between recipes, so this doesn't work if you don't have the root set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may want to fail if DOTNET_ROOT isnt set here; iirc a lot of stuff doesnt work right if that env var isn't already set.