// Code generated by protoc-gen-triple. DO NOT EDIT.
//
// Source: shippingservice.proto
package hipstershop

import (
	"context"
)

import (
	"dubbo.apache.org/dubbo-go/v3"
	"dubbo.apache.org/dubbo-go/v3/client"
	"dubbo.apache.org/dubbo-go/v3/common"
	"dubbo.apache.org/dubbo-go/v3/common/constant"
	"dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
	"dubbo.apache.org/dubbo-go/v3/server"
)

// This is a compile-time assertion to ensure that this generated file and the Triple package
// are compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of Triple newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of Triple or updating the Triple
// version compiled into your binary.
const _ = triple_protocol.IsAtLeastVersion0_1_0

const (
	// ShippingServiceName is the fully-qualified name of the ShippingService service.
	ShippingServiceName = "hipstershop.ShippingService"
)

// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
	// ShippingServiceGetQuoteProcedure is the fully-qualified name of the ShippingService's GetQuote RPC.
	ShippingServiceGetQuoteProcedure = "/hipstershop.ShippingService/GetQuote"
	// ShippingServiceShipOrderProcedure is the fully-qualified name of the ShippingService's ShipOrder RPC.
	ShippingServiceShipOrderProcedure = "/hipstershop.ShippingService/ShipOrder"
)

var (
	_ ShippingService = (*ShippingServiceImpl)(nil)
)

// ShippingService is a client for the hipstershop.ShippingService service.
type ShippingService interface {
	GetQuote(ctx context.Context, req *GetQuoteRequest, opts ...client.CallOption) (*GetQuoteResponse, error)
	ShipOrder(ctx context.Context, req *ShipOrderRequest, opts ...client.CallOption) (*ShipOrderResponse, error)
}

// NewShippingService constructs a client for the hipstershop.ShippingService service.
func NewShippingService(cli *client.Client, opts ...client.ReferenceOption) (ShippingService, error) {
	conn, err := cli.DialWithInfo("hipstershop.ShippingService", &ShippingService_ClientInfo, opts...)
	if err != nil {
		return nil, err
	}
	return &ShippingServiceImpl{
		conn: conn,
	}, nil
}

func SetConsumerShippingService(srv common.RPCService) {
	dubbo.SetConsumerServiceWithInfo(srv, &ShippingService_ClientInfo)
}

// ShippingServiceImpl implements ShippingService.
type ShippingServiceImpl struct {
	conn *client.Connection
}

func (c *ShippingServiceImpl) GetQuote(ctx context.Context, req *GetQuoteRequest, opts ...client.CallOption) (*GetQuoteResponse, error) {
	resp := new(GetQuoteResponse)
	if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "GetQuote", opts...); err != nil {
		return nil, err
	}
	return resp, nil
}

func (c *ShippingServiceImpl) ShipOrder(ctx context.Context, req *ShipOrderRequest, opts ...client.CallOption) (*ShipOrderResponse, error) {
	resp := new(ShipOrderResponse)
	if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "ShipOrder", opts...); err != nil {
		return nil, err
	}
	return resp, nil
}

var ShippingService_ClientInfo = client.ClientInfo{
	InterfaceName: "hipstershop.ShippingService",
	MethodNames:   []string{"GetQuote", "ShipOrder"},
	ConnectionInjectFunc: func(dubboCliRaw interface{}, conn *client.Connection) {
		dubboCli := dubboCliRaw.(*ShippingServiceImpl)
		dubboCli.conn = conn
	},
}

// ShippingServiceHandler is an implementation of the hipstershop.ShippingService service.
type ShippingServiceHandler interface {
	GetQuote(context.Context, *GetQuoteRequest) (*GetQuoteResponse, error)
	ShipOrder(context.Context, *ShipOrderRequest) (*ShipOrderResponse, error)
}

func RegisterShippingServiceHandler(srv *server.Server, hdlr ShippingServiceHandler, opts ...server.ServiceOption) error {
	return srv.Register(hdlr, &ShippingService_ServiceInfo, opts...)
}

func SetProviderShippingService(srv common.RPCService) {
	dubbo.SetProviderServiceWithInfo(srv, &ShippingService_ServiceInfo)
}

var ShippingService_ServiceInfo = server.ServiceInfo{
	InterfaceName: "hipstershop.ShippingService",
	ServiceType:   (*ShippingServiceHandler)(nil),
	Methods: []server.MethodInfo{
		{
			Name: "GetQuote",
			Type: constant.CallUnary,
			ReqInitFunc: func() interface{} {
				return new(GetQuoteRequest)
			},
			MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
				req := args[0].(*GetQuoteRequest)
				res, err := handler.(ShippingServiceHandler).GetQuote(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
		{
			Name: "ShipOrder",
			Type: constant.CallUnary,
			ReqInitFunc: func() interface{} {
				return new(ShipOrderRequest)
			},
			MethodFunc: func(ctx context.Context, args []interface{}, handler interface{}) (interface{}, error) {
				req := args[0].(*ShipOrderRequest)
				res, err := handler.(ShippingServiceHandler).ShipOrder(ctx, req)
				if err != nil {
					return nil, err
				}
				return triple_protocol.NewResponse(res), nil
			},
		},
	},
}
