public static function factory(Nitrapi $api, array $options = array()) { $data = $api->dataGet("services/" . $options['id'], null); $type = $data['service']['type']; $class = "Nitrapi\\Services\\" . ucfirst($type) . "s\\" . ucfirst($type); if (!class_exists($class)) { throw new NitrapiServiceTypeNotFoundException("Class for Type " . $type . " not found"); } return new $class($api, $data['service']); }
public function __construct(Nitrapi $api, $token) { $this->api = $api; $this->data = $api->dataGet("user?access_token=" . $token, null); }