// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.7.1
// - protoc             (unknown)
// source: user/api/auth/v1/idp.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 OperationWeChatAuthServiceMiniProgramCode = "/user.api.auth.v1.WeChatAuthService/MiniProgramCode"
const OperationWeChatAuthServiceMiniProgramPhoneCode = "/user.api.auth.v1.WeChatAuthService/MiniProgramPhoneCode"

type WeChatAuthServiceHTTPServer interface {
	MiniProgramCode(context.Context, *WechatMiniProgramCodeReq) (*WeChatLoginReply, error)
	MiniProgramPhoneCode(context.Context, *WechatMiniProgramPhoneCodeReq) (*WeChatLoginReply, error)
}

func RegisterWeChatAuthServiceHTTPServer(s *http.Server, srv WeChatAuthServiceHTTPServer) {
	r := s.Route("/")
	r.POST("/v1/auth/wechat/mini/code", _WeChatAuthService_MiniProgramCode0_HTTP_Handler(srv))
	r.POST("/v1/auth/wechat/mini/phone-code", _WeChatAuthService_MiniProgramPhoneCode0_HTTP_Handler(srv))
}

func _WeChatAuthService_MiniProgramCode0_HTTP_Handler(srv WeChatAuthServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in WechatMiniProgramCodeReq
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationWeChatAuthServiceMiniProgramCode)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.MiniProgramCode(ctx, req.(*WechatMiniProgramCodeReq))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		reply := out.(*WeChatLoginReply)
		return ctx.Result(200, reply)
	}
}

func _WeChatAuthService_MiniProgramPhoneCode0_HTTP_Handler(srv WeChatAuthServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in WechatMiniProgramPhoneCodeReq
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationWeChatAuthServiceMiniProgramPhoneCode)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.MiniProgramPhoneCode(ctx, req.(*WechatMiniProgramPhoneCodeReq))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		reply := out.(*WeChatLoginReply)
		return ctx.Result(200, reply)
	}
}

type WeChatAuthServiceHTTPClient interface {
	MiniProgramCode(ctx context.Context, req *WechatMiniProgramCodeReq, opts ...http.CallOption) (rsp *WeChatLoginReply, err error)
	MiniProgramPhoneCode(ctx context.Context, req *WechatMiniProgramPhoneCodeReq, opts ...http.CallOption) (rsp *WeChatLoginReply, err error)
}

type WeChatAuthServiceHTTPClientImpl struct {
	cc *http.Client
}

func NewWeChatAuthServiceHTTPClient(client *http.Client) WeChatAuthServiceHTTPClient {
	return &WeChatAuthServiceHTTPClientImpl{client}
}

func (c *WeChatAuthServiceHTTPClientImpl) MiniProgramCode(ctx context.Context, in *WechatMiniProgramCodeReq, opts ...http.CallOption) (*WeChatLoginReply, error) {
	var out WeChatLoginReply
	pattern := "/v1/auth/wechat/mini/code"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationWeChatAuthServiceMiniProgramCode))
	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
}

func (c *WeChatAuthServiceHTTPClientImpl) MiniProgramPhoneCode(ctx context.Context, in *WechatMiniProgramPhoneCodeReq, opts ...http.CallOption) (*WeChatLoginReply, error) {
	var out WeChatLoginReply
	pattern := "/v1/auth/wechat/mini/phone-code"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationWeChatAuthServiceMiniProgramPhoneCode))
	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
}
