<?php

namespace App\Classes\Modules\Addresses\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
use App\Models\Address;

class CreatesAddress extends AbstractUpdateRecord
{

    /**
     * @param AddressObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(AddressObject $object) {
        $model = new Address();
        $model->company_id = $object->getCompanyId();
        $model->street_one = $object->getStreetOne();
        $model->street_two = $object->getStreetTwo();
        $model->city = $object->getCity();
        $model->state = $object->getState();
        $model->post_code = $object->getPostCode();
        $model->country = $object->getCountry();
        $model->default = $object->getDefault();
        $model->billing = $object->getBilling();

        return $this->handler($model);

    }
}