<?php

namespace App\Classes\Modules\Wallets\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
use App\Models\WalletTransaction;

class CreatesWalletTransaction extends AbstractUpdateRecord
{
    /**
     * @param WalletTransactionObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(WalletTransactionObject $object) {
        $model = new WalletTransaction();
        $model->wallet_id = $object->getWalletId();
        $model->bill_no = $object->getBillNo();
        $model->trans_type = $object->getTransType();
        $model->amount = $object->getAmount();
        $model->currency_id = $object->getCurrency();
        $model->original_amount = $object->getOriginalAmount();
        $model->original_currency_id = $object->getOriginalCurrency();
        $model->currency_rate = $object->getCurrencyRate();

        return $this->handler($model);

    }
}