// NOTE this is a generated file! do not edit!

package channel_points_custom_reward

import (
	"context"

	"github.com/golang/protobuf/proto"

	eventbus "code.justin.tv/eventbus/client"
)

const (
	UpdateEventType = "ChannelPointsCustomRewardUpdate"
)

type Update = ChannelPointsCustomRewardUpdate

type ChannelPointsCustomRewardUpdateHandler func(context.Context, *eventbus.Header, *ChannelPointsCustomRewardUpdate) error

func (h ChannelPointsCustomRewardUpdateHandler) Handler() eventbus.Handler {
	return func(ctx context.Context, message eventbus.RawMessage) error {
		dst := &ChannelPointsCustomRewardUpdate{}
		err := proto.Unmarshal(message.Payload, dst)
		if err != nil {
			return err
		}
		return h(ctx, message.Header, dst)
	}
}

func RegisterChannelPointsCustomRewardUpdateHandler(mux *eventbus.Mux, f ChannelPointsCustomRewardUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f ChannelPointsCustomRewardUpdateHandler) {
	RegisterChannelPointsCustomRewardUpdateHandler(mux, f)
}

func (*ChannelPointsCustomRewardUpdate) EventBusName() string {
	return UpdateEventType
}
