<?php

namespace ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Models;


use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Interfaces\AbstractModel;

/**
 *
 * Created by PhpStorm.
 * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
 * Date: 10.09.19
 * Time: 08:43
 * Class Account
 */
class Account extends AbstractModel
{
    /**
     * Account Attributes
     */
    const ATTR_FIRSTNAME        = 'givenName';
    const ATTR_LASTNAME         = 'sn';
    const ATTR_PHONE            = 'telephoneNumber';
    const ATTR_MOBILE_PHONE     = 'mobile';
    const ATTR_FAX              = 'facsimileTelephoneNumber';
    const ATTR_PAGER            = 'pager';
    const ATTR_HOME_PHONE       = 'homePhone';
    const ATTR_COUNTRY          = 'co';
    const ATTR_STATE            = 'st';
    const ATTR_POSTAL_CODE      = 'postalCode';
    const ATTR_CITY             = 'l';
    const ATTR_STREET           = 'street';
    const ATTR_COMPANY          = 'company';
    const ATTR_PROF_TITLE       = 'title';
    const ATTR_ACCOUNT_STATUS   = 'zimbraAccountStatus';
    const ATTR_DISPLAY_NAME     = 'displayName';
    const ATTR_MAIL_QUOTA       = 'zimbraMailQuota';
    const ATTR_ALIAS            = 'zimbraMailAlias';
    const ATTR_CLASS_OF_SERVICE_ID = 'zimbraCOSId';

    protected $id;
    protected $name;
    protected $password;
    protected $attrs;
    protected $limit;
    protected $used;

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

    /**
     * @param $name
     * @return $this
     */
    public function setName($name)
    {
        $this->name = $name;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * @param $password
     * @return $this
     */
    public function setPassword($password)
    {
        $this->password = $password;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param $id
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getLimit()
    {
        return $this->limit;
    }

    /**
     * @param $limit
     * @return $this
     */
    public function setLimit($limit = 0)
    {
        $this->limit = $limit;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getUsed()
    {
        return $this->used;
    }

    /**
     * @param $used
     * @return $this
     */
    public function setUsed($used = 0)
    {
        $this->used = $used;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getAttrs()
    {
        return $this->attrs;
    }

    /**
     * @param $key
     * @param null $value
     * @return $this
     */
    public function setAttr($key, $value = null)
    {
        $this->attrs[$key] = $value;
        return $this;
    }

    /**
     * @param $key
     * @return mixed
     */
    public function getAttr($key)
    {
        return $this->attrs[$key];
    }

    /**
     * @param $attrs
     * @return $this
     */
    public function setAttrs($attrs = [])
    {
        $this->attrs = $attrs;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getCosId()
    {
        return $this->getDataResourceA(self::ATTR_CLASS_OF_SERVICE_ID);
    }

    /**
     * @return mixed
     */
    public function getAliases()
    {
        foreach($this->resources['a'] as $res)
        {
            if($res['N'] === self::ATTR_ALIAS)
            {
                $tmp[$res['DATA']] =  $res['DATA'];
            }
        }
        return $tmp;
    }

}