// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.7.0
// - protoc             v3.21.12
// source: api/analytics/v1/analytics.proto

package v1

import (
	context "context"
	http "github.com/go-kratos/kratos/v2/transport/http"
	binding "github.com/go-kratos/kratos/v2/transport/http/binding"
)

// This is a compile-time assertion to ensure that this generated file
// is compatible with the kratos package it is being compiled against.
var _ = new(context.Context)
var _ = binding.EncodeURL

const _ = http.SupportPackageIsVersion1

const OperationAnalyticsEventAnalytics = "/api.analytics.v1.Analytics/EventAnalytics"

type AnalyticsHTTPServer interface {
	EventAnalytics(context.Context, *EventAnalyticsRequest) (*EventAnalyticReply, error)
}

func RegisterAnalyticsHTTPServer(s *http.Server, srv AnalyticsHTTPServer) {
	r := s.Route("/")
	r.POST("v1/api/analytics/event", _Analytics_EventAnalytics0_HTTP_Handler(srv))
}

func _Analytics_EventAnalytics0_HTTP_Handler(srv AnalyticsHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in EventAnalyticsRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationAnalyticsEventAnalytics)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.EventAnalytics(ctx, req.(*EventAnalyticsRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		reply := out.(*EventAnalyticReply)
		return ctx.Result(200, reply)
	}
}

type AnalyticsHTTPClient interface {
	EventAnalytics(ctx context.Context, req *EventAnalyticsRequest, opts ...http.CallOption) (rsp *EventAnalyticReply, err error)
}

type AnalyticsHTTPClientImpl struct {
	cc *http.Client
}

func NewAnalyticsHTTPClient(client *http.Client) AnalyticsHTTPClient {
	return &AnalyticsHTTPClientImpl{client}
}

func (c *AnalyticsHTTPClientImpl) EventAnalytics(ctx context.Context, in *EventAnalyticsRequest, opts ...http.CallOption) (*EventAnalyticReply, error) {
	var out EventAnalyticReply
	pattern := "v1/api/analytics/event"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationAnalyticsEventAnalytics))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, err
}
