<?php
/**
 * Created by PhpStorm.
 * Damian Banaszkiewicz <dbanaszkiewicz@unicorn.net.pl>
 * 22.08.18 11:14
 */

namespace FCA\StockApi\Document\Offer;

use FCA\StockApi\Document\Base;

class Model extends Base
{
    /**
     * @var string
     */
    protected $code;

    /**
     * @var string
     */
    protected $commercialCode;

    /**
     * @var string
     */
    protected $name;

    /**
     * @var array
     */
    protected $groups;

    /**
     * Model constructor.
     * @param $model
     * @throws \FCA\StockApi\Exception\ApiException
     */
    public function __construct($model)
    {
        $required_keys = ['code', 'commercial_code', 'name', 'groups'];
        $this->checkKeys($required_keys, $model);

        $this->code = $model['code'];
        $this->commercialCode = $model['commercial_code'];
        $this->name = $model['name'];
        $this->groups = (array)$model['groups'];
    }

    /**
     * @return string
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * @return string
     */
    public function getCommercialCode()
    {
        return $this->commercialCode;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @return array
     */
    public function getGroups()
    {
        return $this->groups;
    }
}
