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

package reviewsservice

import (
	"context"
	reviews "github.com/cloudwego/biz-demo/bookinfo/kitex_gen/cwg/bookinfo/reviews"
	client "github.com/cloudwego/kitex/client"
	kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
)

func serviceInfo() *kitex.ServiceInfo {
	return reviewsServiceServiceInfo
}

var reviewsServiceServiceInfo = NewServiceInfo()

func NewServiceInfo() *kitex.ServiceInfo {
	serviceName := "ReviewsService"
	handlerType := (*reviews.ReviewsService)(nil)
	methods := map[string]kitex.MethodInfo{
		"ReviewProduct": kitex.NewMethodInfo(reviewProductHandler, newReviewsServiceReviewProductArgs, newReviewsServiceReviewProductResult, false),
	}
	extra := map[string]interface{}{
		"PackageName": "reviews",
	}
	svcInfo := &kitex.ServiceInfo{
		ServiceName:     serviceName,
		HandlerType:     handlerType,
		Methods:         methods,
		PayloadCodec:    kitex.Thrift,
		KiteXGenVersion: "v0.4.2",
		Extra:           extra,
	}
	return svcInfo
}

func reviewProductHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*reviews.ReviewsServiceReviewProductArgs)
	realResult := result.(*reviews.ReviewsServiceReviewProductResult)
	success, err := handler.(reviews.ReviewsService).ReviewProduct(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newReviewsServiceReviewProductArgs() interface{} {
	return reviews.NewReviewsServiceReviewProductArgs()
}

func newReviewsServiceReviewProductResult() interface{} {
	return reviews.NewReviewsServiceReviewProductResult()
}

type kClient struct {
	c client.Client
}

func newServiceClient(c client.Client) *kClient {
	return &kClient{
		c: c,
	}
}

func (p *kClient) ReviewProduct(ctx context.Context, req *reviews.ReviewReq) (r *reviews.ReviewResp, err error) {
	var _args reviews.ReviewsServiceReviewProductArgs
	_args.Req = req
	var _result reviews.ReviewsServiceReviewProductResult
	if err = p.c.Call(ctx, "ReviewProduct", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}
