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

package favoriteservice

import (
	"context"
	favorite "github.com/PICOF/simple-tiktok/kitex_gen/favorite"
	client "github.com/cloudwego/kitex/client"
	kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
)

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

var favoriteServiceServiceInfo = NewServiceInfo()

func NewServiceInfo() *kitex.ServiceInfo {
	serviceName := "FavoriteService"
	handlerType := (*favorite.FavoriteService)(nil)
	methods := map[string]kitex.MethodInfo{
		"LikeAction":  kitex.NewMethodInfo(likeActionHandler, newFavoriteServiceLikeActionArgs, newFavoriteServiceLikeActionResult, false),
		"GetLikeList": kitex.NewMethodInfo(getLikeListHandler, newFavoriteServiceGetLikeListArgs, newFavoriteServiceGetLikeListResult, false),
	}
	extra := map[string]interface{}{
		"PackageName": "favorite",
	}
	svcInfo := &kitex.ServiceInfo{
		ServiceName:     serviceName,
		HandlerType:     handlerType,
		Methods:         methods,
		PayloadCodec:    kitex.Thrift,
		KiteXGenVersion: "v0.4.4",
		Extra:           extra,
	}
	return svcInfo
}

func likeActionHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*favorite.FavoriteServiceLikeActionArgs)
	realResult := result.(*favorite.FavoriteServiceLikeActionResult)
	success, err := handler.(favorite.FavoriteService).LikeAction(ctx, realArg.Request)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newFavoriteServiceLikeActionArgs() interface{} {
	return favorite.NewFavoriteServiceLikeActionArgs()
}

func newFavoriteServiceLikeActionResult() interface{} {
	return favorite.NewFavoriteServiceLikeActionResult()
}

func getLikeListHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*favorite.FavoriteServiceGetLikeListArgs)
	realResult := result.(*favorite.FavoriteServiceGetLikeListResult)
	success, err := handler.(favorite.FavoriteService).GetLikeList(ctx, realArg.Request)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newFavoriteServiceGetLikeListArgs() interface{} {
	return favorite.NewFavoriteServiceGetLikeListArgs()
}

func newFavoriteServiceGetLikeListResult() interface{} {
	return favorite.NewFavoriteServiceGetLikeListResult()
}

type kClient struct {
	c client.Client
}

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

func (p *kClient) LikeAction(ctx context.Context, request *favorite.LikeRequest) (r *favorite.LikeResponse, err error) {
	var _args favorite.FavoriteServiceLikeActionArgs
	_args.Request = request
	var _result favorite.FavoriteServiceLikeActionResult
	if err = p.c.Call(ctx, "LikeAction", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) GetLikeList(ctx context.Context, request *favorite.LikeListRequest) (r *favorite.LikeListResponse, err error) {
	var _args favorite.FavoriteServiceGetLikeListArgs
	_args.Request = request
	var _result favorite.FavoriteServiceGetLikeListResult
	if err = p.c.Call(ctx, "GetLikeList", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}
