public function create($owner, $repo, $ref, $task = '', $autoMerge = true, $requiredContexts = null, $payload = '', $environment = '',
		$description = ''
	)
	{
		// Build the request path.
		$path = "/repos/$owner/$repo/deployments";

		$data = array(
			'ref'        => $ref,
			'auto_merge' => $autoMerge,
		);

		if ($task)
		{
			$data['task'] = $task;
		}

		if (\is_array($requiredContexts))
		{
			$data['required_contexts'] = $requiredContexts;
		}

		if ($payload)
		{
			$data['payload'] = $payload;
		}

		if ($environment)
		{
			$data['environment'] = $environment;
		}

		if ($description)
		{
			$data['description'] = $description;
		}

		$response = $this->client->post($this->fetchUrl($path), json_encode($data));

		switch ($response->code)
		{
			case 201 :
				// The deployment was successful
				return json_decode($response->body);

			case 409 :
				// There was a merge conflict or a status check failed.
				$body    = json_decode($response->body);
				$message = isset($body->message) ? $body->message : 'Invalid response received from GitHub.';

				throw new \RuntimeException($message, $response->code);

			default :
				throw new \UnexpectedValueException('Unexpected response code: ' . $response->code);
		}
	}