Art-of-WiFi / UniFi-API-browser

Tool to browse data exposed by Ubiquiti's UniFi Controller API
MIT License
1.1k stars 150 forks source link

Adopt Function #18

Closed nelsencd closed 7 years ago

nelsencd commented 7 years ago

I have created an adoption function that you could add to you API.

     if (!$this->is_loggedin) return FALSE;
     $mac             = strtolower($mac);
     $return          = FALSE;
     $json            = json_encode(array('mac' => $mac, 'cmd' => 'adopt'));
     $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/devmgr','json='.$json));
     if (isset($content_decoded->meta->rc)) {
        if ($content_decoded->meta->rc == 'ok') {
           $return = TRUE;
        }
     }
       return $return;
  }
malle-pietje commented 7 years ago

Thanks for this!

I'll add it to the next release but I'm thinking of dropping $site_id as a parameter. Since we always are operating within the scope of a specific site within the class instance, adoption of an AP to the current site ($this->site) make most sense. Also, you don't appear to be using it within the function/method. Do you agree?

nelsencd commented 7 years ago

I have another php script that I use to call this function to run it. That's also why I have the $site_id parameter.

malle-pietje commented 7 years ago

Ah, I see, would not be necessary in the public version then. Thanks again for the contribution!

malle-pietje commented 7 years ago

published with API client class version 1.0.13