// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.8.0
// - protoc             v3.12.4
// source: svapi/file.proto

package svapi

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 OperationFileServicePreSignUploadingPublicFile = "/svapi.FileService/PreSignUploadingPublicFile"
const OperationFileServiceReportPublicFileUploaded = "/svapi.FileService/ReportPublicFileUploaded"

type FileServiceHTTPServer interface {
	PreSignUploadingPublicFile(context.Context, *PreSignUploadPublicFileRequest) (*PreSignUploadPublicFileResponse, error)
	ReportPublicFileUploaded(context.Context, *ReportPublicFileUploadedRequest) (*ReportPublicFileUploadedResponse, error)
}

func RegisterFileServiceHTTPServer(s *http.Server, srv FileServiceHTTPServer) {
	r := s.Route("/")
	r.POST("file", _FileService_PreSignUploadingPublicFile0_HTTP_Handler(srv))
	r.POST("file/report", _FileService_ReportPublicFileUploaded0_HTTP_Handler(srv))
}

func _FileService_PreSignUploadingPublicFile0_HTTP_Handler(srv FileServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in PreSignUploadPublicFileRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationFileServicePreSignUploadingPublicFile)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.PreSignUploadingPublicFile(ctx, req.(*PreSignUploadPublicFileRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

func _FileService_ReportPublicFileUploaded0_HTTP_Handler(srv FileServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in ReportPublicFileUploadedRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationFileServiceReportPublicFileUploaded)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.ReportPublicFileUploaded(ctx, req.(*ReportPublicFileUploadedRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

type FileServiceHTTPClient interface {
	PreSignUploadingPublicFile(ctx context.Context, req *PreSignUploadPublicFileRequest, opts ...http.CallOption) (rsp *PreSignUploadPublicFileResponse, err error)
	ReportPublicFileUploaded(ctx context.Context, req *ReportPublicFileUploadedRequest, opts ...http.CallOption) (rsp *ReportPublicFileUploadedResponse, err error)
}

type FileServiceHTTPClientImpl struct {
	cc *http.Client
}

func NewFileServiceHTTPClient(client *http.Client) FileServiceHTTPClient {
	return &FileServiceHTTPClientImpl{client}
}

func (c *FileServiceHTTPClientImpl) PreSignUploadingPublicFile(ctx context.Context, in *PreSignUploadPublicFileRequest, opts ...http.CallOption) (*PreSignUploadPublicFileResponse, error) {
	var out PreSignUploadPublicFileResponse
	pattern := "file"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationFileServicePreSignUploadingPublicFile))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, nil
}

func (c *FileServiceHTTPClientImpl) ReportPublicFileUploaded(ctx context.Context, in *ReportPublicFileUploadedRequest, opts ...http.CallOption) (*ReportPublicFileUploadedResponse, error) {
	var out ReportPublicFileUploadedResponse
	pattern := "file/report"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationFileServiceReportPublicFileUploaded))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, nil
}
