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

Add webhook v3 types #533

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add webhook v3 types #533

wants to merge 1 commit into from

Conversation

icholy
Copy link
Contributor

@icholy icholy commented Jun 17, 2024

I originally had this function too, but I didn't find it very useful.

// ParseEventData parses the event data into the correct type.
func ParseEventData(e Event) (any, error) {
	var data any
	switch e.EventType {
	case "incident.acknowledged", "incident.annotated", "incident.delegated",
		"incident.escalated", "incident.priority_updated", "incident.reassigned",
		"incident.reopened", "incident.triggered", "incident.unacknowledged":
		data = &IncidentData{}
	case "incident.conference_bridge.updated":
		data = &IncidentConferenceBridgeData{}
	case "incident.custom_field_values.updated":
		data = &IncidentFieldValuesData{}
	case "incident.responder.added", "incident.responder.replied":
		data = &IncidentResponderData{}
	case "incident.status_update_published":
		data = &IncidentStatusUpdateData{}
	case "incident.workflow.started", "incident.workflow.completed":
		data = &IncidentWorkflowInstanceData{}
	case "pagey.ping":
		data = &PageyData{}
	default:
		return nil, fmt.Errorf("unrecognized event type: %q", e.EventType)
	}
	if err := json.Unmarshal(e.Data, data); err != nil {
		return nil, err
	}
	return data, nil
}

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

Successfully merging this pull request may close these issues.

None yet

1 participant