You are here

public function SiteClient::register in Lockr 7

Same name and namespace in other branches
  1. 7.2 vendor/lockr/lockr-client/src/SiteClient.php \Lockr\SiteClient::register()

Registers the site with Lockr.

Parameters

string $email The email to register with.:

string $pass (optional) The password for authentication.:

string $name (optional) The site name.:

Throws

ServerException if the server is unavailable or returns an error.

ClientException if there was an unexpected client error.

File

src/Lockr/SiteClient.php, line 71

Class

SiteClient
API for site management operations.

Namespace

Lockr

Code

public function register($email, $pass = null, $name = null) {
  $data = array(
    'email' => $email,
    'name' => $name,
  );
  if (null !== $pass) {
    $auth = "{$email}:{$pass}";
  }
  else {
    $auth = null;
  }
  list($status, $_) = $this->client
    ->post('/v1/site/register', $data, $auth);
  if ($status >= 500) {
    throw new ServerException();
  }
  if ($status >= 400) {
    throw new ClientException();
  }
}