Generate yookassa client via openapi tool ogen
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user