mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
34 lines
883 B
Go
34 lines
883 B
Go
package powens
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/hanzo-fi/go-libs/v5/pkg/types/pointer"
|
|
"github.com/hanzo-fi/payments/pkg/domain/models"
|
|
)
|
|
|
|
func (p *Plugin) createUser(ctx context.Context, req models.CreateUserRequest) (models.CreateUserResponse, error) {
|
|
createUserResponse, err := p.client.CreateUser(ctx)
|
|
if err != nil {
|
|
return models.CreateUserResponse{}, err
|
|
}
|
|
|
|
expiresAt := time.Time{}
|
|
if createUserResponse.ExpiresIn > 0 {
|
|
expiresAt = time.Now().Add(time.Duration(createUserResponse.ExpiresIn) * time.Second)
|
|
}
|
|
|
|
return models.CreateUserResponse{
|
|
PermanentToken: &models.Token{
|
|
Token: createUserResponse.AuthToken,
|
|
ExpiresAt: expiresAt,
|
|
},
|
|
PSPUserID: pointer.For(strconv.Itoa(createUserResponse.IdUser)),
|
|
Metadata: map[string]string{
|
|
ExpiresInMetadataKey: strconv.FormatInt(createUserResponse.ExpiresIn, 10),
|
|
},
|
|
}, nil
|
|
}
|