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

package payservice

import (
	"context"
	client "github.com/cloudwego/kitex/client"
	kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
	pay "github.com/cqqqq777/go-kitex-mall/shared/kitex_gen/pay"
)

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

var payServiceServiceInfo = NewServiceInfo()

func NewServiceInfo() *kitex.ServiceInfo {
	serviceName := "PayService"
	handlerType := (*pay.PayService)(nil)
	methods := map[string]kitex.MethodInfo{
		"CreatePay": kitex.NewMethodInfo(createPayHandler, newPayServiceCreatePayArgs, newPayServiceCreatePayResult, false),
		"PayDetail": kitex.NewMethodInfo(payDetailHandler, newPayServicePayDetailArgs, newPayServicePayDetailResult, false),
		"PayReturn": kitex.NewMethodInfo(payReturnHandler, newPayServicePayReturnArgs, newPayServicePayReturnResult, false),
		"PayNotify": kitex.NewMethodInfo(payNotifyHandler, newPayServicePayNotifyArgs, newPayServicePayNotifyResult, false),
	}
	extra := map[string]interface{}{
		"PackageName": "pay",
	}
	svcInfo := &kitex.ServiceInfo{
		ServiceName:     serviceName,
		HandlerType:     handlerType,
		Methods:         methods,
		PayloadCodec:    kitex.Thrift,
		KiteXGenVersion: "v0.5.1",
		Extra:           extra,
	}
	return svcInfo
}

func createPayHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*pay.PayServiceCreatePayArgs)
	realResult := result.(*pay.PayServiceCreatePayResult)
	success, err := handler.(pay.PayService).CreatePay(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newPayServiceCreatePayArgs() interface{} {
	return pay.NewPayServiceCreatePayArgs()
}

func newPayServiceCreatePayResult() interface{} {
	return pay.NewPayServiceCreatePayResult()
}

func payDetailHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*pay.PayServicePayDetailArgs)
	realResult := result.(*pay.PayServicePayDetailResult)
	success, err := handler.(pay.PayService).PayDetail(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newPayServicePayDetailArgs() interface{} {
	return pay.NewPayServicePayDetailArgs()
}

func newPayServicePayDetailResult() interface{} {
	return pay.NewPayServicePayDetailResult()
}

func payReturnHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*pay.PayServicePayReturnArgs)
	realResult := result.(*pay.PayServicePayReturnResult)
	success, err := handler.(pay.PayService).PayReturn(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newPayServicePayReturnArgs() interface{} {
	return pay.NewPayServicePayReturnArgs()
}

func newPayServicePayReturnResult() interface{} {
	return pay.NewPayServicePayReturnResult()
}

func payNotifyHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*pay.PayServicePayNotifyArgs)
	realResult := result.(*pay.PayServicePayNotifyResult)
	success, err := handler.(pay.PayService).PayNotify(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newPayServicePayNotifyArgs() interface{} {
	return pay.NewPayServicePayNotifyArgs()
}

func newPayServicePayNotifyResult() interface{} {
	return pay.NewPayServicePayNotifyResult()
}

type kClient struct {
	c client.Client
}

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

func (p *kClient) CreatePay(ctx context.Context, req *pay.MallCreatePayRequest) (r *pay.MallCreatePayResponse, err error) {
	var _args pay.PayServiceCreatePayArgs
	_args.Req = req
	var _result pay.PayServiceCreatePayResult
	if err = p.c.Call(ctx, "CreatePay", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) PayDetail(ctx context.Context, req *pay.MallPayDetailRequest) (r *pay.MallPayDetailResponse, err error) {
	var _args pay.PayServicePayDetailArgs
	_args.Req = req
	var _result pay.PayServicePayDetailResult
	if err = p.c.Call(ctx, "PayDetail", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) PayReturn(ctx context.Context, req *pay.MallPayReturnRequest) (r *pay.MallPayReturnResponse, err error) {
	var _args pay.PayServicePayReturnArgs
	_args.Req = req
	var _result pay.PayServicePayReturnResult
	if err = p.c.Call(ctx, "PayReturn", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) PayNotify(ctx context.Context, req *pay.MallPayNotifyRequest) (r *pay.MallPayNotifyResponse, err error) {
	var _args pay.PayServicePayNotifyArgs
	_args.Req = req
	var _result pay.PayServicePayNotifyResult
	if err = p.c.Call(ctx, "PayNotify", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}
