<?php

namespace App\Classes\Modules\Groups\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Groups\DataTransferObjects\GroupObject;
use App\Models\Group;

class CreatesGroup extends AbstractUpdateRecord
{
    /**
     * @param GroupObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(GroupObject $object) {
        $model = new Group();
        $model->issuer                  = $object->getIssuer();
        $model->receiver                = $object->getReceiver();
        $model->amount                  = $object->getAmount();
        $model->original_amount         = $object->getOriginalAmount();
        $model->currency_id             = $object->getCurrencyId();
        $model->original_currency_id    = $object->getOriginalCurrencyId();
        $model->currency_rate           = $object->getCurrencyRate();
        $model->tax                     = $object->getTax();
        $model->service_charge          = $object->getServiceCharge();
        $model->status                  = $object->getStatus();
        $model->reference               = $object->getReference();
        $model->payment_method          = $object->getPaymentMethod();

        return $this->handler($model);
    }
}