<?php

class Setup_hub_model extends Cf_Model
{
    /**
     * @return mixed
     */
    public function getStatus()
    {
        return json_decode($this->getRestClient()->get('/fr/hub-status'), JSON_OBJECT_AS_ARRAY);
    }

    public function isSuperHub()
    {
        $info = $this->getStatus();
        return isset($info['configured']) && $info['configured'] === true && $info['role'] === 'superhub';
    }

    /**
     * @return mixed
     */
    public function enable($role)
    {
        return json_decode($this->getRestClient()->post('/fr/setup-hub/' . $role), JSON_OBJECT_AS_ARRAY);
    }
}
