package service

import (
	"context"
	"time"

	"git.gocasts.ir/ebhomengo/niki/domain/wallet/entity"
	"git.gocasts.ir/ebhomengo/niki/domain/wallet/param"
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)

func (s Service) CreateTransaction(ctx context.Context, request param.CreateTransactionRequest) (param.InsertTransactionResponse, error) {

	const op = richerror.Op("wallet.service.CreateTransaction")

	transaction := entity.Transaction{
		ID:         0,
		UserID:     request.UserID,
		Amount:     request.Amount,
		Currency:   request.Currency,
		ActionType: request.ActionType,
		Timestamp:  time.Now(),
	}
	err := s.repo.InsertTransaction(ctx, transaction)
	if err != nil {
		return param.InsertTransactionResponse{}, err
	}

	return param.InsertTransactionResponse{}, nil

}
