src/Api/Client.php
public function getAvailablePrivateTags($organisations = null, $as_simple_array = false)
    {
        $orgs_ids = $organisations ? array_keys($organisations) : json_decode($this->orgs_ids);
        if (!$orgs_ids) {
            //No organisations configured
            $this->handleException(new \Exception("You need at least 1 Hail Organisation configured to be able to fetch private tags"));
            return false;
        }
        $tag_list = [];
        foreach ($orgs_ids as $org_id) {
            //Get Org Name
            if ($organisations) {
                $org_name = isset($organisations[$org_id]) ? $organisations[$org_id] : '';
            } else {
                $org = DataObject::get_one(Organisation::class, ['HailID' => $org_id]);
                $org_name = $org ? $org->Title : "";
            }

            $results = $this->get('organisations/' . $org_id . '/private-tags');
            //If simple array is true, we send back an array with [id] => [name] instead of the full list
            if ($as_simple_array) {
                foreach ($results as $result) {
                    $tag_title = $result['name'];
                    //Add organisation name on tag title if more than 1 org
                    if (count($orgs_ids) > 1) {
                        $tag_title = $org_name . " - " . $tag_title;
                    }
                    $tag_list[$result['id']] = $tag_title;
                }
            } else {
                $tag_list = array_merge($results, $tag_list);
            }
        }
        asort($tag_list);

        return $tag_list;
    }
public function getAvailablePrivateTags($organisations = null, $as_simple_array = false)
    {
        $orgs_ids = $organisations ? array_keys($organisations) : json_decode($this->orgs_ids);
        if (!$orgs_ids) {
            //No organisations configured
            $this->handleException(new \Exception("You need at least 1 Hail Organisation configured to be able to fetch private tags"));
            return false;
        }
        $tag_list = [];
        foreach ($orgs_ids as $org_id) {
            //Get Org Name
            if ($organisations) {
                $org_name = isset($organisations[$org_id]) ? $organisations[$org_id] : '';
            } else {
                $org = DataObject::get_one(Organisation::class, ['HailID' => $org_id]);
                $org_name = $org ? $org->Title : "";
            }

            $results = $this->get('organisations/' . $org_id . '/private-tags');
            //If simple array is true, we send back an array with [id] => [name] instead of the full list
            if ($as_simple_array) {
                foreach ($results as $result) {
                    $tag_title = $result['name'];
                    //Add organisation name on tag title if more than 1 org
                    if (count($orgs_ids) > 1) {
                        $tag_title = $org_name . " - " . $tag_title;
                    }
                    $tag_list[$result['id']] = $tag_title;
                }
            } else {
                $tag_list = array_merge($results, $tag_list);
            }
        }
        asort($tag_list);

        return $tag_list;
    }
public function getAvailablePrivateTags ( $ organisations = null , $ as_simple_array = false ) { $ orgs_ids = $ organisations ? array_keys ( $ organisations ) : json_decode ( $ this -> orgs_ids ) ; if ( ! $ orgs_ids ) { //No organisations configured
 $ this -> handleException ( new \ Exception ( "You need at least 1 Hail Organisation configured to be able to fetch private tags" ) ) ; return false ; } $ tag_list = [ ] ; foreach ( $ orgs_ids as $ org_id ) { //Get Org Name
 if ( $ organisations ) { $ org_name = isset ( $ organisations [ $ org_id ] ) ? $ organisations [ $ org_id ] : '' ; } else { $ org = DataObject :: get_one ( Organisation :: class , [ 'HailID' => $ org_id ] ) ; $ org_name = $ org ? $ org -> Title : "" ; } $ results = $ this -> get ( 'organisations/' . $ org_id . '/private-tags' ) ; //If simple array is true, we send back an array with [id] => [name] instead of the full list
 if ( $ as_simple_array ) { foreach ( $ results as $ result ) { $ tag_title = $ result [ 'name' ] ; //Add organisation name on tag title if more than 1 org
 if ( count ( $ orgs_ids ) > 1 ) { $ tag_title = $ org_name . " - " . $ tag_title ; } $ tag_list [ $ result [ 'id' ] ] = $ tag_title ; } } else { $ tag_list = array_merge ( $ results , $ tag_list ) ; } } asort ( $ tag_list ) ; return $ tag_list ; }
Get all available Private Tags from the Hail API
Will get all tags from all configured organisations unless specified otherwise

@param array|null $organisations Pass an array of organisations (HailID => Organisation Name) to get the tag for, if null will get all configured organisation
@param boolean $as_simple_array Return a simple associative array (ID => Tile )instead of the full objects

@return array|boolean
@throws
Get all available Private Tags from the Hail API Will get all tags from all configured organisations unless specified otherwise