// Code generated by Azure.Iot.Operations.ProtocolCompilerLib v0.10.0.0; DO NOT EDIT.
package counter

import (
	"context"

	"github.com/Azure/iot-operations-sdks/go/protocol"
)

type ResetCommandInvoker struct {
	*protocol.CommandInvoker[any, any]
}

func NewResetCommandInvoker(
	app *protocol.Application,
	client protocol.MqttClient,
	requestTopic string,
	opt ...protocol.CommandInvokerOption,
) (*ResetCommandInvoker, error) {
	var err error
	invoker := &ResetCommandInvoker{}

	var opts protocol.CommandInvokerOptions
	opts.Apply(
		opt,
		protocol.WithTopicTokens{
			"commandName": "reset",
		},
	)

	invoker.CommandInvoker, err = protocol.NewCommandInvoker(
		app,
		client,
		protocol.Empty{},
		protocol.Empty{},
		requestTopic,
		&opts,
	)

	return invoker, err
}

func (invoker ResetCommandInvoker) Reset(
	ctx context.Context,
	executorId string,
	opt ...protocol.InvokeOption,
) error {
	invokerOpts := []protocol.InvokeOption{
		protocol.WithTopicTokenNamespace("ex:"),
		protocol.WithTopicTokens{
			"executorId": executorId,
		},
	}

	var invokeOpts protocol.InvokeOptions
	invokeOpts.Apply(opt, invokerOpts...)

	_, err := invoker.Invoke(
		ctx,
		nil,
		&invokeOpts,
	)

	return err
}
