/*
 * Copyright 2024 CloudWeGo Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Code generated by Kitex v0.9.1. DO NOT EDIT.

package mock

import (
	"context"
	client "github.com/cloudwego/kitex/client"
	callopt "github.com/cloudwego/kitex/client/callopt"
	"github.com/cloudwego/kitex/client/callopt/streamcall"
	"github.com/cloudwego/kitex/client/streamclient"
	streaming "github.com/cloudwego/kitex/pkg/streaming"
	transport "github.com/cloudwego/kitex/transport"
)

// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework.
type Client interface {
	UnaryTest(ctx context.Context, Req *MockReq, callOptions ...callopt.Option) (r *MockResp, err error)
	ClientStreamingTest(ctx context.Context, callOptions ...callopt.Option) (stream Mock_ClientStreamingTestClient, err error)
	ServerStreamingTest(ctx context.Context, Req *MockReq, callOptions ...callopt.Option) (stream Mock_ServerStreamingTestClient, err error)
	BidirectionalStreamingTest(ctx context.Context, callOptions ...callopt.Option) (stream Mock_BidirectionalStreamingTestClient, err error)
}

// StreamClient is designed to provide Interface for Streaming APIs.
type StreamClient interface {
	ClientStreamingTest(ctx context.Context, callOptions ...streamcall.Option) (stream Mock_ClientStreamingTestClient, err error)
	ServerStreamingTest(ctx context.Context, Req *MockReq, callOptions ...streamcall.Option) (stream Mock_ServerStreamingTestClient, err error)
	BidirectionalStreamingTest(ctx context.Context, callOptions ...streamcall.Option) (stream Mock_BidirectionalStreamingTestClient, err error)
}

type Mock_ClientStreamingTestClient interface {
	streaming.Stream
	Send(*MockReq) error
	CloseAndRecv() (*MockResp, error)
}

type Mock_ServerStreamingTestClient interface {
	streaming.Stream
	Recv() (*MockResp, error)
}

type Mock_BidirectionalStreamingTestClient interface {
	streaming.Stream
	Send(*MockReq) error
	Recv() (*MockResp, error)
}

// NewClient creates a client for the service defined in IDL.
func NewClient(destService string, opts ...client.Option) (Client, error) {
	var options []client.Option
	options = append(options, client.WithDestService(destService))

	options = append(options, client.WithTransportProtocol(transport.GRPC))

	options = append(options, opts...)

	kc, err := client.NewClient(serviceInfo(), options...)
	if err != nil {
		return nil, err
	}
	return &kMockClient{
		kClient: newServiceClient(kc),
	}, nil
}

// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs.
func MustNewClient(destService string, opts ...client.Option) Client {
	kc, err := NewClient(destService, opts...)
	if err != nil {
		panic(err)
	}
	return kc
}

type kMockClient struct {
	*kClient
}

func (p *kMockClient) UnaryTest(ctx context.Context, Req *MockReq, callOptions ...callopt.Option) (r *MockResp, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.UnaryTest(ctx, Req)
}

func (p *kMockClient) ClientStreamingTest(ctx context.Context, callOptions ...callopt.Option) (stream Mock_ClientStreamingTestClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.ClientStreamingTest(ctx)
}

func (p *kMockClient) ServerStreamingTest(ctx context.Context, Req *MockReq, callOptions ...callopt.Option) (stream Mock_ServerStreamingTestClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.ServerStreamingTest(ctx, Req)
}

func (p *kMockClient) BidirectionalStreamingTest(ctx context.Context, callOptions ...callopt.Option) (stream Mock_BidirectionalStreamingTestClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.BidirectionalStreamingTest(ctx)
}

// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL.
func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) {
	var options []client.Option
	options = append(options, client.WithDestService(destService))
	options = append(options, client.WithTransportProtocol(transport.GRPC))
	options = append(options, streamclient.GetClientOptions(opts)...)

	kc, err := client.NewClient(serviceInfoForStreamClient(), options...)
	if err != nil {
		return nil, err
	}
	return &kMockStreamClient{
		kClient: newServiceClient(kc),
	}, nil
}

// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL.
// It panics if any error occurs.
func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient {
	kc, err := NewStreamClient(destService, opts...)
	if err != nil {
		panic(err)
	}
	return kc
}

type kMockStreamClient struct {
	*kClient
}

func (p *kMockStreamClient) ClientStreamingTest(ctx context.Context, callOptions ...streamcall.Option) (stream Mock_ClientStreamingTestClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions))
	return p.kClient.ClientStreamingTest(ctx)
}

func (p *kMockStreamClient) ServerStreamingTest(ctx context.Context, Req *MockReq, callOptions ...streamcall.Option) (stream Mock_ServerStreamingTestClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions))
	return p.kClient.ServerStreamingTest(ctx, Req)
}

func (p *kMockStreamClient) BidirectionalStreamingTest(ctx context.Context, callOptions ...streamcall.Option) (stream Mock_BidirectionalStreamingTestClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions))
	return p.kClient.BidirectionalStreamingTest(ctx)
}
