Skip to content
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

Typed models for working with webhooks #28

Open
NathanBaulch opened this issue May 26, 2021 · 1 comment
Open

Typed models for working with webhooks #28

NathanBaulch opened this issue May 26, 2021 · 1 comment

Comments

@NathanBaulch
Copy link

Not a huge deal but it would be nice if this package included typed models for easier webhook processing.

For example, I'd like to process the payload data in a video.live_stream.created webhook event however there are incompatible differences with the near-identical muxgo.LiveStream struct.

var payload struct {
    Type string           `json:"type"`
    Data muxgo.LiveStream `json:"data"`
}
if err := resty.Unmarshalc(resty.New(), "application/json", body, &payload); err != nil {
    panic("json: cannot unmarshal number into Go struct field LiveStream.data.created_at of type string")
}

In this particular case, the webhook uses integer dates whereas the API model uses RFC3339 dates.

@philcluff
Copy link
Contributor

Hey @NathanBaulch, thanks for the feedback here, really appreciate it. We're aware of this issue and that it limits the usability of the SDK for receiving webhooks.

I don't have a timeline on addressing this as resolving it would require a breaking change to our API, or a lot of code duplication, but we are aware of this and working towards a solution.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants