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

package relationservice

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

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

var relationServiceServiceInfo = NewServiceInfo()

func NewServiceInfo() *kitex.ServiceInfo {
	serviceName := "RelationService"
	handlerType := (*relation.RelationService)(nil)
	methods := map[string]kitex.MethodInfo{
		"FollowAction":    kitex.NewMethodInfo(followActionHandler, newRelationServiceFollowActionArgs, newRelationServiceFollowActionResult, false),
		"GetFollowList":   kitex.NewMethodInfo(getFollowListHandler, newRelationServiceGetFollowListArgs, newRelationServiceGetFollowListResult, false),
		"GetFollowerList": kitex.NewMethodInfo(getFollowerListHandler, newRelationServiceGetFollowerListArgs, newRelationServiceGetFollowerListResult, false),
		"GetFriendList":   kitex.NewMethodInfo(getFriendListHandler, newRelationServiceGetFriendListArgs, newRelationServiceGetFriendListResult, false),
	}
	extra := map[string]interface{}{
		"PackageName": "relation",
	}
	svcInfo := &kitex.ServiceInfo{
		ServiceName:     serviceName,
		HandlerType:     handlerType,
		Methods:         methods,
		PayloadCodec:    kitex.Thrift,
		KiteXGenVersion: "v0.4.4",
		Extra:           extra,
	}
	return svcInfo
}

func followActionHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*relation.RelationServiceFollowActionArgs)
	realResult := result.(*relation.RelationServiceFollowActionResult)
	success, err := handler.(relation.RelationService).FollowAction(ctx, realArg.Request)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newRelationServiceFollowActionArgs() interface{} {
	return relation.NewRelationServiceFollowActionArgs()
}

func newRelationServiceFollowActionResult() interface{} {
	return relation.NewRelationServiceFollowActionResult()
}

func getFollowListHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*relation.RelationServiceGetFollowListArgs)
	realResult := result.(*relation.RelationServiceGetFollowListResult)
	success, err := handler.(relation.RelationService).GetFollowList(ctx, realArg.Request)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newRelationServiceGetFollowListArgs() interface{} {
	return relation.NewRelationServiceGetFollowListArgs()
}

func newRelationServiceGetFollowListResult() interface{} {
	return relation.NewRelationServiceGetFollowListResult()
}

func getFollowerListHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*relation.RelationServiceGetFollowerListArgs)
	realResult := result.(*relation.RelationServiceGetFollowerListResult)
	success, err := handler.(relation.RelationService).GetFollowerList(ctx, realArg.Request)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newRelationServiceGetFollowerListArgs() interface{} {
	return relation.NewRelationServiceGetFollowerListArgs()
}

func newRelationServiceGetFollowerListResult() interface{} {
	return relation.NewRelationServiceGetFollowerListResult()
}

func getFriendListHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*relation.RelationServiceGetFriendListArgs)
	realResult := result.(*relation.RelationServiceGetFriendListResult)
	success, err := handler.(relation.RelationService).GetFriendList(ctx, realArg.Request)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newRelationServiceGetFriendListArgs() interface{} {
	return relation.NewRelationServiceGetFriendListArgs()
}

func newRelationServiceGetFriendListResult() interface{} {
	return relation.NewRelationServiceGetFriendListResult()
}

type kClient struct {
	c client.Client
}

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

func (p *kClient) FollowAction(ctx context.Context, request *relation.FollowRequest) (r *relation.FollowResponse, err error) {
	var _args relation.RelationServiceFollowActionArgs
	_args.Request = request
	var _result relation.RelationServiceFollowActionResult
	if err = p.c.Call(ctx, "FollowAction", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) GetFollowList(ctx context.Context, request *relation.RelationListRequest) (r *relation.RelationListResponse, err error) {
	var _args relation.RelationServiceGetFollowListArgs
	_args.Request = request
	var _result relation.RelationServiceGetFollowListResult
	if err = p.c.Call(ctx, "GetFollowList", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) GetFollowerList(ctx context.Context, request *relation.RelationListRequest) (r *relation.RelationListResponse, err error) {
	var _args relation.RelationServiceGetFollowerListArgs
	_args.Request = request
	var _result relation.RelationServiceGetFollowerListResult
	if err = p.c.Call(ctx, "GetFollowerList", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) GetFriendList(ctx context.Context, request *relation.RelationListRequest) (r *relation.RelationListResponse, err error) {
	var _args relation.RelationServiceGetFriendListArgs
	_args.Request = request
	var _result relation.RelationServiceGetFriendListResult
	if err = p.c.Call(ctx, "GetFriendList", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}
