<?php

namespace App\Classes\Modules\Contacts\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
use App\Models\Contact;

class CreatesContact extends AbstractUpdateRecord
{
    /**
     * @param ContactObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(ContactObject $object) 
    {
        $model = new Contact();
        $model->country_id = $object->getCountryId();
        $model->company_id = $object->getCompanyId();
        $model->reference = $object->getReference();
        $model->phone = $object->getPhone();
        $model->email = $object->getEmail();
        $model->wechat_id = $object->getWechatId();
        
        return $this->handler($model);
    }
}