Generate yookassa client via openapi tool ogen

This commit is contained in:
2026-03-12 01:07:37 +03:00
parent 968c030939
commit 95b1b867db
27 changed files with 116035 additions and 15 deletions

View File

@@ -1,13 +1,42 @@
package yookassa
import "payouts/internal/service/yookassa/config"
import (
"context"
"payouts/internal/service/yookassa/config"
"payouts/internal/service/yookassa/gen"
"github.com/ogen-go/ogen/ogenerrors"
)
type yookassaService struct {
conf config.YooKassa
conf config.YooKassa
payClient *gen.Client
}
// BasicAuth implements [gen.SecuritySource].
func (y *yookassaService) BasicAuth(ctx context.Context, operationName gen.OperationName) (gen.BasicAuth, error) {
return gen.BasicAuth{
Username: y.conf.ApiPaymentKey,
Password: y.conf.ApiBaseSecret,
}, nil
}
// OAuth2 implements [gen.SecuritySource].
func (y *yookassaService) OAuth2(ctx context.Context, operationName gen.OperationName) (gen.OAuth2, error) {
return gen.OAuth2{}, ogenerrors.ErrSkipClientSecurity
}
func NewYookassaService(conf config.YooKassa) (Service, error) {
return &yookassaService{
svc := &yookassaService{
conf: conf,
}, nil
}
payClient, err := gen.NewClient(conf.BaseUrl, svc)
if err != nil {
return nil, err
}
svc.payClient = payClient
// payClient.PaymentsPost()
return svc, nil
}