customer/internal/interface/swagger/api.gen.go

549 lines
22 KiB
Go
Raw Normal View History

2023-06-22 09:36:43 +00:00
// Package swagger provides primitives to interact with the openapi HTTP API.
//
2023-11-23 18:55:22 +00:00
// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.0.0 DO NOT EDIT.
2023-06-22 09:36:43 +00:00
package swagger
import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
"net/http"
"net/url"
"path"
"strings"
"github.com/getkin/kin-openapi/openapi3"
"github.com/labstack/echo/v4"
2023-09-14 10:07:28 +00:00
"github.com/oapi-codegen/runtime"
2023-06-22 09:36:43 +00:00
)
// ServerInterface represents all server handlers.
type ServerInterface interface {
// удалить собственный аккаунт
// (DELETE /account)
DeleteAccount(ctx echo.Context) error
// Получение текущего аккаунта юзера
// (GET /account)
GetAccount(ctx echo.Context) error
// Отредактировать аккаунт
// (PATCH /account)
ChangeAccount(ctx echo.Context) error
// Создать новый аккаунт
// (POST /account)
AddAccount(ctx echo.Context) error
// Удалить аккаунт по айди
// (DELETE /account/{userId})
DeleteDirectAccount(ctx echo.Context, userId string) error
// Получить аккаунт по ID пользователя системы единой авторизации
// (GET /account/{userId})
GetDirectAccount(ctx echo.Context, userId string) error
// Выставление статуса верификации
// (PATCH /account/{userId})
SetAccountVerificationStatus(ctx echo.Context, userId string) error
// списко аккаунтов с пагинацией
// (GET /accounts)
PaginationAccounts(ctx echo.Context, params PaginationAccountsParams) error
// Удаляем из корзины тариф
// (DELETE /cart)
RemoveFromCart(ctx echo.Context, params RemoveFromCartParams) error
// Добавляем в корзину тариф
// (PATCH /cart)
Add2cart(ctx echo.Context, params Add2cartParams) error
// оплатить козину
// (POST /cart/pay)
PayCart(ctx echo.Context) error
// получить список одобренных валют
// (GET /currencies)
GetCurrencies(ctx echo.Context) error
// обновляет список одобренных валют
// (PUT /currencies)
UpdateCurrencies(ctx echo.Context) error
// Получение лога событий связанных с аккаунтом
// (GET /history)
GetHistory(ctx echo.Context, params GetHistoryParams) error
2023-11-23 18:55:22 +00:00
// Получение недавних тарифов
// (GET /recent)
GetRecentTariffs(ctx echo.Context) error
2023-11-02 10:01:18 +00:00
// отправить акт проделанных работ на почту
// (POST /sendReport)
SendReport(ctx echo.Context) error
2023-06-22 09:36:43 +00:00
// Изменить валюту кошелька
// (PATCH /wallet)
ChangeCurrency(ctx echo.Context) error
// Запрос на получение ссылки на оплату
// (POST /wallet)
RequestMoney(ctx echo.Context) error
}
// ServerInterfaceWrapper converts echo contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
// DeleteAccount converts echo context to params.
func (w *ServerInterfaceWrapper) DeleteAccount(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.DeleteAccount(ctx)
return err
}
// GetAccount converts echo context to params.
func (w *ServerInterfaceWrapper) GetAccount(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.GetAccount(ctx)
return err
}
// ChangeAccount converts echo context to params.
func (w *ServerInterfaceWrapper) ChangeAccount(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.ChangeAccount(ctx)
return err
}
// AddAccount converts echo context to params.
func (w *ServerInterfaceWrapper) AddAccount(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.AddAccount(ctx)
return err
}
// DeleteDirectAccount converts echo context to params.
func (w *ServerInterfaceWrapper) DeleteDirectAccount(ctx echo.Context) error {
var err error
// ------------- Path parameter "userId" -------------
var userId string
err = runtime.BindStyledParameterWithLocation("simple", false, "userId", runtime.ParamLocationPath, ctx.Param("userId"), &userId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err))
}
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.DeleteDirectAccount(ctx, userId)
return err
}
// GetDirectAccount converts echo context to params.
func (w *ServerInterfaceWrapper) GetDirectAccount(ctx echo.Context) error {
var err error
// ------------- Path parameter "userId" -------------
var userId string
err = runtime.BindStyledParameterWithLocation("simple", false, "userId", runtime.ParamLocationPath, ctx.Param("userId"), &userId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err))
}
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.GetDirectAccount(ctx, userId)
return err
}
// SetAccountVerificationStatus converts echo context to params.
func (w *ServerInterfaceWrapper) SetAccountVerificationStatus(ctx echo.Context) error {
var err error
// ------------- Path parameter "userId" -------------
var userId string
err = runtime.BindStyledParameterWithLocation("simple", false, "userId", runtime.ParamLocationPath, ctx.Param("userId"), &userId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err))
}
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.SetAccountVerificationStatus(ctx, userId)
return err
}
// PaginationAccounts converts echo context to params.
func (w *ServerInterfaceWrapper) PaginationAccounts(ctx echo.Context) error {
var err error
// Parameter object where we will unmarshal all parameters from the context
var params PaginationAccountsParams
// ------------- Optional query parameter "page" -------------
err = runtime.BindQueryParameter("form", false, false, "page", ctx.QueryParams(), &params.Page)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter page: %s", err))
}
// ------------- Optional query parameter "limit" -------------
err = runtime.BindQueryParameter("form", false, false, "limit", ctx.QueryParams(), &params.Limit)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter limit: %s", err))
}
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.PaginationAccounts(ctx, params)
return err
}
// RemoveFromCart converts echo context to params.
func (w *ServerInterfaceWrapper) RemoveFromCart(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
// Parameter object where we will unmarshal all parameters from the context
var params RemoveFromCartParams
// ------------- Required query parameter "id" -------------
err = runtime.BindQueryParameter("form", true, true, "id", ctx.QueryParams(), &params.Id)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.RemoveFromCart(ctx, params)
return err
}
// Add2cart converts echo context to params.
func (w *ServerInterfaceWrapper) Add2cart(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
// Parameter object where we will unmarshal all parameters from the context
var params Add2cartParams
// ------------- Required query parameter "id" -------------
err = runtime.BindQueryParameter("form", true, true, "id", ctx.QueryParams(), &params.Id)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.Add2cart(ctx, params)
return err
}
// PayCart converts echo context to params.
func (w *ServerInterfaceWrapper) PayCart(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.PayCart(ctx)
return err
}
// GetCurrencies converts echo context to params.
func (w *ServerInterfaceWrapper) GetCurrencies(ctx echo.Context) error {
var err error
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.GetCurrencies(ctx)
return err
}
// UpdateCurrencies converts echo context to params.
func (w *ServerInterfaceWrapper) UpdateCurrencies(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.UpdateCurrencies(ctx)
return err
}
// GetHistory converts echo context to params.
func (w *ServerInterfaceWrapper) GetHistory(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
// Parameter object where we will unmarshal all parameters from the context
var params GetHistoryParams
// ------------- Optional query parameter "page" -------------
err = runtime.BindQueryParameter("form", false, false, "page", ctx.QueryParams(), &params.Page)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter page: %s", err))
}
// ------------- Optional query parameter "limit" -------------
err = runtime.BindQueryParameter("form", false, false, "limit", ctx.QueryParams(), &params.Limit)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter limit: %s", err))
}
2023-09-14 10:07:28 +00:00
// ------------- Optional query parameter "type" -------------
err = runtime.BindQueryParameter("form", false, false, "type", ctx.QueryParams(), &params.Type)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter type: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.GetHistory(ctx, params)
return err
}
2023-11-23 18:55:22 +00:00
// GetRecentTariffs converts echo context to params.
func (w *ServerInterfaceWrapper) GetRecentTariffs(ctx echo.Context) error {
2023-11-25 18:28:26 +00:00
var err error
ctx.Set(BearerScopes, []string{})
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetRecentTariffs(ctx)
return err
}
2023-11-02 10:01:18 +00:00
// SendReport converts echo context to params.
func (w *ServerInterfaceWrapper) SendReport(ctx echo.Context) error {
2023-11-23 18:55:22 +00:00
var err error
ctx.Set(BearerScopes, []string{})
// Invoke the callback with all the unmarshaled arguments
2023-11-02 10:01:18 +00:00
err = w.Handler.SendReport(ctx)
2023-11-23 18:55:22 +00:00
return err
}
2023-06-22 09:36:43 +00:00
// ChangeCurrency converts echo context to params.
func (w *ServerInterfaceWrapper) ChangeCurrency(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.ChangeCurrency(ctx)
return err
}
// RequestMoney converts echo context to params.
func (w *ServerInterfaceWrapper) RequestMoney(ctx echo.Context) error {
var err error
2023-08-02 14:28:31 +00:00
ctx.Set(BearerScopes, []string{})
2023-06-22 09:36:43 +00:00
2023-09-14 10:07:28 +00:00
// Invoke the callback with all the unmarshaled arguments
2023-06-22 09:36:43 +00:00
err = w.Handler.RequestMoney(ctx)
return err
}
// This is a simple interface which specifies echo.Route addition functions which
// are present on both echo.Echo and echo.Group, since we want to allow using
// either of them for path registration
type EchoRouter interface {
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}
// RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlers(router EchoRouter, si ServerInterface) {
RegisterHandlersWithBaseURL(router, si, "")
}
// Registers handlers, and prepends BaseURL to the paths, so that the paths
// can be served under a prefix.
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
wrapper := ServerInterfaceWrapper{
Handler: si,
}
router.DELETE(baseURL+"/account", wrapper.DeleteAccount)
router.GET(baseURL+"/account", wrapper.GetAccount)
router.PATCH(baseURL+"/account", wrapper.ChangeAccount)
router.POST(baseURL+"/account", wrapper.AddAccount)
router.DELETE(baseURL+"/account/:userId", wrapper.DeleteDirectAccount)
router.GET(baseURL+"/account/:userId", wrapper.GetDirectAccount)
router.PATCH(baseURL+"/account/:userId", wrapper.SetAccountVerificationStatus)
router.GET(baseURL+"/accounts", wrapper.PaginationAccounts)
router.DELETE(baseURL+"/cart", wrapper.RemoveFromCart)
router.PATCH(baseURL+"/cart", wrapper.Add2cart)
router.POST(baseURL+"/cart/pay", wrapper.PayCart)
router.GET(baseURL+"/currencies", wrapper.GetCurrencies)
router.PUT(baseURL+"/currencies", wrapper.UpdateCurrencies)
router.GET(baseURL+"/history", wrapper.GetHistory)
2023-11-23 18:55:22 +00:00
router.GET(baseURL+"/recent", wrapper.GetRecentTariffs)
2023-11-02 10:01:18 +00:00
router.POST(baseURL+"/sendReport", wrapper.SendReport)
2023-06-22 09:36:43 +00:00
router.PATCH(baseURL+"/wallet", wrapper.ChangeCurrency)
router.POST(baseURL+"/wallet", wrapper.RequestMoney)
}
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
2023-11-25 18:28:26 +00:00
"H4sIAAAAAAAC/+xcbW8byZH+K425+5DgxhKl1Z6z+mbLmzsfYGdhr70wLCEZkU1pYnKGnhnGqzMIiGRi",
"xZDWPucCnLG39t4mAe7bHUWJFiWR1F+o/keHqu55b0qULL/odhPAK5HT09XVVU89VV2tx0bRrdZchzuB",
"b8w/NvziKq9a9OOVYtGtOwH+WPPcGvcCm9MXv7ZL+B/+tVWtVbgxb/yicLk8U758eblY/sVMsXT5s8/m",
"PvmsMDNjmEawVsMn/MCznRWjYRpFywtSo+8fN3zMV7PGkmnYAa+SPLk51AeW51lrNKfHrYCXrtDEZder",
"WoExb5SsgF8K7CrXiVniFX7KIbZ/TQ5KLa9sVXwePb3suhVuOfi4Y1U5Pvn3Hi8b88bfTccbMa12Yfom",
"PtMwDT+wgrp/0tNqw27LhxumUa+VTrvuus+962+xvY+sSoUHJ0n6lXyq0TANjz+s2x4q7T4ZViSCMpXo",
"lUpjkTKiPTKSG5xc9FIkn7v8W14MUL60jnCZTr2KczsuzvAA/3W9lcTYeG1XLefBguWV8h5RtLzSqlsp",
"cQ9/K3G/6Nm1wHYdY96AlzAQzxl04RA6sAs9OBRb4gl0GBxAR6yLltg0zIS6r9+9cpPhP7+6q3Ugv6iZ",
"5FsYwS5buLswy6APh9BnC3fvzprsk/DXOSaa0IcBdGGEkpgMjqAnNqAjWtCBnmiJJoo5RMFGsC3W6Zsh",
"jGCfiaZowUiswwiG0BsneOFTnbz865rtrd1wnWBVI/d30MN5xR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sRX31KQT8iSgFmcL1HmM5lkKfl+qYHqsiYw2hbfEJscQD8D",
"7R05Y3SniH7MAnuqsCiajK79IRbKymn4RxvCZ9qp2wwEyUMKBKP0tYYI/jUXkHK4dUvC1A11Cex8UMuK",
"Lu7F+dOnhdmC7lLdcuLPbxxnmdGf6Tj2kuf127+6NDc7c5khZaX97xBdPPFWZ8VdsZ00ytJHvw64H+gG",
"1FZdh9+M/ixEPOzyZ4Xwf7pxHg/qnnPHq6RHrQZBzZ+fnvbtgE959Wl1sDL2ZvlxqkpeJc6GBZWYJ64B",
"qs16F2EibRUV23mgX/SK665UcNmTXJU+PqzkMqLEjUvU36fvJYr8kLyVlzo+kGdwQ9GGQ0b41odtzH5O",
"gZqaUwvd8XoIJf08kOiglDQtP8xR5mzftyryWFFHQW6EuhYp2nAUMtv0NWv1isgONe9IHFcQ+odD0DPG",
"PB4R0vhxtUDNgESST3UtNSDMJxpLjf8LAAD//wRwIcNHSwAA",
2023-06-22 09:36:43 +00:00
}
// GetSwagger returns the content of the embedded swagger specification file
// or error if failed to decode
func decodeSpec() ([]byte, error) {
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
if err != nil {
2023-09-14 10:07:28 +00:00
return nil, fmt.Errorf("error base64 decoding spec: %w", err)
2023-06-22 09:36:43 +00:00
}
zr, err := gzip.NewReader(bytes.NewReader(zipped))
if err != nil {
2023-09-14 10:07:28 +00:00
return nil, fmt.Errorf("error decompressing spec: %w", err)
2023-06-22 09:36:43 +00:00
}
var buf bytes.Buffer
_, err = buf.ReadFrom(zr)
if err != nil {
2023-09-14 10:07:28 +00:00
return nil, fmt.Errorf("error decompressing spec: %w", err)
2023-06-22 09:36:43 +00:00
}
return buf.Bytes(), nil
}
var rawSpec = decodeSpecCached()
// a naive cached of a decoded swagger spec
func decodeSpecCached() func() ([]byte, error) {
data, err := decodeSpec()
return func() ([]byte, error) {
return data, err
}
}
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
2023-09-14 10:07:28 +00:00
res := make(map[string]func() ([]byte, error))
2023-06-22 09:36:43 +00:00
if len(pathToFile) > 0 {
res[pathToFile] = rawSpec
}
return res
}
// GetSwagger returns the Swagger specification corresponding to the generated code
// in this file. The external references of Swagger specification are resolved.
// The logic of resolving external references is tightly connected to "import-mapping" feature.
// Externally referenced files must be embedded in the corresponding golang packages.
// Urls can be supported but this task was out of the scope.
func GetSwagger() (swagger *openapi3.T, err error) {
2023-09-14 10:07:28 +00:00
resolvePath := PathToRawSpec("")
2023-06-22 09:36:43 +00:00
loader := openapi3.NewLoader()
loader.IsExternalRefsAllowed = true
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
2023-09-14 10:07:28 +00:00
pathToFile := url.String()
2023-06-22 09:36:43 +00:00
pathToFile = path.Clean(pathToFile)
getSpec, ok := resolvePath[pathToFile]
if !ok {
err1 := fmt.Errorf("path not found: %s", pathToFile)
return nil, err1
}
return getSpec()
}
var specData []byte
specData, err = rawSpec()
if err != nil {
return
}
swagger, err = loader.LoadFromData(specData)
if err != nil {
return
}
return
}