1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/services/wallet_service.rb

21 lines
684 B
Ruby

class WalletService
def initialize(user: nil, wallet: nil)
@user = user
@wallet = wallet
end
def credit(amount)
if @wallet.credit(amount)
transaction = WalletTransaction.create(user: @user, wallet: @wallet, transaction_type: 'credit', amount: amount)
NotificationCenter.call type: 'notify_user_wallet_is_credited',
receiver: @wallet.user,
attached_object: transaction
NotificationCenter.call type: 'notify_admin_user_wallet_is_credited',
receiver: User.admins,
attached_object: transaction
return true
end
end
end