-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add Webhook Simulation resources #49
Conversation
* feat(Simulations): narrow down simulation payload types * refactor(Simulations): rename event map * fix(Simulations): Include scenarios in union * refactor(Simulations): rename DiscriminatedEventResponse
5536e93
export type DiscriminatedSimulationEventResponse<Base> = { | ||
[K in keyof SimulationEventPayloadMap]: Base & { | ||
type: K; | ||
payload?: K extends IEventName ? Partial<SimulationEventPayloadMap[K]['data']> | null : null; |
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.
Would it be possible to map directly to the notification entity? e.g. something like this:
payload?: K extends IEventName ? Partial<SimulationEventPayloadMap[K]['data']> | null : null; | |
payload?: K extends IEventName ? Partial<SimulationEventPayloadMap[K]> | null : null; |
e.g. AddressNotification
interface SimulationEventPayloadMap {
'address.created': AddressNotification;
'address.updated': AddressNotification;
'address.imported': AddressNotification;
.......
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.
I had this conversation with Sam as well, essentially the event often changes the type i.e.
public override readonly data: Omit<SubscriptionNotification, 'transactionId'>
so it uses that instead of the raw Notification
this.notificationSettingId = simulationResponse.notification_setting_id; | ||
this.name = simulationResponse.name; | ||
this.type = simulationResponse.type; | ||
this.payload = simulationResponse.payload ?? null; |
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.
Should we also create a notification entity here?
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.
The Notification
follows this pattern
this.payload = Webhooks.fromJson(notificationResponse.payload);
could apply that here as well
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.
It seems like the notification payload is a little different though and only cares about the data
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.
🚀
Simulation resources
Simulation Types
Relevant docs: https://developer.paddle.com/api-reference/simulation-types/overview
Retrieve a list of available simulation types
Simulations
Relevant docs: https://developer.paddle.com/api-reference/simulations/overview
Retrieve a list of simulations
Create a new simulation
Fetch a single simulation
Update a simulation
Simulation Runs
Relevant docs: https://developer.paddle.com/api-reference/simulation-runs/overview
Retrieve a list of simulation runs
Create a new simulation run
Fetch a single simulation run
Simulation Run Event
https://developer.paddle.com/api-reference/simulation-events/overview
Retrieve a list of simulation runs
Fetch a single simulation run event
Replay a simulation run event