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

package cartservice

import (
	"context"
	client "github.com/cloudwego/kitex/client"
	callopt "github.com/cloudwego/kitex/client/callopt"
	cart "github.com/cqqqq777/go-kitex-mall/shared/kitex_gen/cart"
)

// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework.
type Client interface {
	AddProductToCart(ctx context.Context, req *cart.MallAddProductToCartRequest, callOptions ...callopt.Option) (r *cart.MallAddProductToCartResponse, err error)
	GetCart(ctx context.Context, req *cart.MallGetCartRequest, callOptions ...callopt.Option) (r *cart.MallGetCartResponse, err error)
	DelCartProduct(ctx context.Context, req *cart.MallDelCartProductRequest, callOptions ...callopt.Option) (r *cart.MallDelCartProductResponse, err 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, opts...)

	kc, err := client.NewClient(serviceInfo(), options...)
	if err != nil {
		return nil, err
	}
	return &kCartServiceClient{
		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 kCartServiceClient struct {
	*kClient
}

func (p *kCartServiceClient) AddProductToCart(ctx context.Context, req *cart.MallAddProductToCartRequest, callOptions ...callopt.Option) (r *cart.MallAddProductToCartResponse, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.AddProductToCart(ctx, req)
}

func (p *kCartServiceClient) GetCart(ctx context.Context, req *cart.MallGetCartRequest, callOptions ...callopt.Option) (r *cart.MallGetCartResponse, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.GetCart(ctx, req)
}

func (p *kCartServiceClient) DelCartProduct(ctx context.Context, req *cart.MallDelCartProductRequest, callOptions ...callopt.Option) (r *cart.MallDelCartProductResponse, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.DelCartProduct(ctx, req)
}
