// Code generated by thriftrw-plugin-yarpc
// @generated

package matchingserviceclient

import (
	context "context"
	reflect "reflect"

	wire "go.uber.org/thriftrw/wire"
	yarpc "go.uber.org/yarpc"
	transport "go.uber.org/yarpc/api/transport"
	thrift "go.uber.org/yarpc/encoding/thrift"

	matching "github.com/uber/cadence/.gen/go/matching"
	shared "github.com/uber/cadence/.gen/go/shared"
)

// Interface is a client for the MatchingService service.
type Interface interface {
	AddActivityTask(
		ctx context.Context,
		AddRequest *matching.AddActivityTaskRequest,
		opts ...yarpc.CallOption,
	) error

	AddDecisionTask(
		ctx context.Context,
		AddRequest *matching.AddDecisionTaskRequest,
		opts ...yarpc.CallOption,
	) error

	CancelOutstandingPoll(
		ctx context.Context,
		Request *matching.CancelOutstandingPollRequest,
		opts ...yarpc.CallOption,
	) error

	DescribeTaskList(
		ctx context.Context,
		Request *matching.DescribeTaskListRequest,
		opts ...yarpc.CallOption,
	) (*shared.DescribeTaskListResponse, error)

	GetTaskListsByDomain(
		ctx context.Context,
		Request *shared.GetTaskListsByDomainRequest,
		opts ...yarpc.CallOption,
	) (*shared.GetTaskListsByDomainResponse, error)

	ListTaskListPartitions(
		ctx context.Context,
		Request *matching.ListTaskListPartitionsRequest,
		opts ...yarpc.CallOption,
	) (*shared.ListTaskListPartitionsResponse, error)

	PollForActivityTask(
		ctx context.Context,
		PollRequest *matching.PollForActivityTaskRequest,
		opts ...yarpc.CallOption,
	) (*shared.PollForActivityTaskResponse, error)

	PollForDecisionTask(
		ctx context.Context,
		PollRequest *matching.PollForDecisionTaskRequest,
		opts ...yarpc.CallOption,
	) (*matching.PollForDecisionTaskResponse, error)

	QueryWorkflow(
		ctx context.Context,
		QueryRequest *matching.QueryWorkflowRequest,
		opts ...yarpc.CallOption,
	) (*shared.QueryWorkflowResponse, error)

	RespondQueryTaskCompleted(
		ctx context.Context,
		Request *matching.RespondQueryTaskCompletedRequest,
		opts ...yarpc.CallOption,
	) error
}

// New builds a new client for the MatchingService service.
//
//	client := matchingserviceclient.New(dispatcher.ClientConfig("matchingservice"))
func New(c transport.ClientConfig, opts ...thrift.ClientOption) Interface {
	return client{
		c: thrift.New(thrift.Config{
			Service:      "MatchingService",
			ClientConfig: c,
		}, opts...),
		nwc: thrift.NewNoWire(thrift.Config{
			Service:      "MatchingService",
			ClientConfig: c,
		}, opts...),
	}
}

func init() {
	yarpc.RegisterClientBuilder(
		func(c transport.ClientConfig, f reflect.StructField) Interface {
			return New(c, thrift.ClientBuilderOptions(c, f)...)
		},
	)
}

type client struct {
	c   thrift.Client
	nwc thrift.NoWireClient
}

func (c client) AddActivityTask(
	ctx context.Context,
	_AddRequest *matching.AddActivityTaskRequest,
	opts ...yarpc.CallOption,
) (err error) {

	var result matching.MatchingService_AddActivityTask_Result
	args := matching.MatchingService_AddActivityTask_Helper.Args(_AddRequest)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	err = matching.MatchingService_AddActivityTask_Helper.UnwrapResponse(&result)
	return
}

func (c client) AddDecisionTask(
	ctx context.Context,
	_AddRequest *matching.AddDecisionTaskRequest,
	opts ...yarpc.CallOption,
) (err error) {

	var result matching.MatchingService_AddDecisionTask_Result
	args := matching.MatchingService_AddDecisionTask_Helper.Args(_AddRequest)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	err = matching.MatchingService_AddDecisionTask_Helper.UnwrapResponse(&result)
	return
}

func (c client) CancelOutstandingPoll(
	ctx context.Context,
	_Request *matching.CancelOutstandingPollRequest,
	opts ...yarpc.CallOption,
) (err error) {

	var result matching.MatchingService_CancelOutstandingPoll_Result
	args := matching.MatchingService_CancelOutstandingPoll_Helper.Args(_Request)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	err = matching.MatchingService_CancelOutstandingPoll_Helper.UnwrapResponse(&result)
	return
}

func (c client) DescribeTaskList(
	ctx context.Context,
	_Request *matching.DescribeTaskListRequest,
	opts ...yarpc.CallOption,
) (success *shared.DescribeTaskListResponse, err error) {

	var result matching.MatchingService_DescribeTaskList_Result
	args := matching.MatchingService_DescribeTaskList_Helper.Args(_Request)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	success, err = matching.MatchingService_DescribeTaskList_Helper.UnwrapResponse(&result)
	return
}

func (c client) GetTaskListsByDomain(
	ctx context.Context,
	_Request *shared.GetTaskListsByDomainRequest,
	opts ...yarpc.CallOption,
) (success *shared.GetTaskListsByDomainResponse, err error) {

	var result matching.MatchingService_GetTaskListsByDomain_Result
	args := matching.MatchingService_GetTaskListsByDomain_Helper.Args(_Request)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	success, err = matching.MatchingService_GetTaskListsByDomain_Helper.UnwrapResponse(&result)
	return
}

func (c client) ListTaskListPartitions(
	ctx context.Context,
	_Request *matching.ListTaskListPartitionsRequest,
	opts ...yarpc.CallOption,
) (success *shared.ListTaskListPartitionsResponse, err error) {

	var result matching.MatchingService_ListTaskListPartitions_Result
	args := matching.MatchingService_ListTaskListPartitions_Helper.Args(_Request)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	success, err = matching.MatchingService_ListTaskListPartitions_Helper.UnwrapResponse(&result)
	return
}

func (c client) PollForActivityTask(
	ctx context.Context,
	_PollRequest *matching.PollForActivityTaskRequest,
	opts ...yarpc.CallOption,
) (success *shared.PollForActivityTaskResponse, err error) {

	var result matching.MatchingService_PollForActivityTask_Result
	args := matching.MatchingService_PollForActivityTask_Helper.Args(_PollRequest)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	success, err = matching.MatchingService_PollForActivityTask_Helper.UnwrapResponse(&result)
	return
}

func (c client) PollForDecisionTask(
	ctx context.Context,
	_PollRequest *matching.PollForDecisionTaskRequest,
	opts ...yarpc.CallOption,
) (success *matching.PollForDecisionTaskResponse, err error) {

	var result matching.MatchingService_PollForDecisionTask_Result
	args := matching.MatchingService_PollForDecisionTask_Helper.Args(_PollRequest)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	success, err = matching.MatchingService_PollForDecisionTask_Helper.UnwrapResponse(&result)
	return
}

func (c client) QueryWorkflow(
	ctx context.Context,
	_QueryRequest *matching.QueryWorkflowRequest,
	opts ...yarpc.CallOption,
) (success *shared.QueryWorkflowResponse, err error) {

	var result matching.MatchingService_QueryWorkflow_Result
	args := matching.MatchingService_QueryWorkflow_Helper.Args(_QueryRequest)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	success, err = matching.MatchingService_QueryWorkflow_Helper.UnwrapResponse(&result)
	return
}

func (c client) RespondQueryTaskCompleted(
	ctx context.Context,
	_Request *matching.RespondQueryTaskCompletedRequest,
	opts ...yarpc.CallOption,
) (err error) {

	var result matching.MatchingService_RespondQueryTaskCompleted_Result
	args := matching.MatchingService_RespondQueryTaskCompleted_Helper.Args(_Request)

	if c.nwc != nil && c.nwc.Enabled() {
		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
			return
		}
	} else {
		var body wire.Value
		if body, err = c.c.Call(ctx, args, opts...); err != nil {
			return
		}

		if err = result.FromWire(body); err != nil {
			return
		}
	}

	err = matching.MatchingService_RespondQueryTaskCompleted_Helper.UnwrapResponse(&result)
	return
}
