Skip to content

Commit

Permalink
Merge pull request #8 from gfyrag/master
Browse files Browse the repository at this point in the history
Use in order keys to generate dir or keys
  • Loading branch information
joostfaassen committed Dec 30, 2015
2 parents 521ff1a + 5cf4501 commit e4be41b
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,58 @@ public function getKeysValue($root = '/', $recursive = true, $key = null)
}
return $this->values;
}

/**
* create a new directory with auto generated id
*
* @param string $dir
* @param int $ttl
* @return array $body
*/
public function mkdirWithInOrderKey($dir, $ttl = 0)
{
$data = array(
'dir' => 'true'
);

if ($ttl) {
$data['ttl'] = $ttl;
}
$request = $this->guzzleclient->post(
$this->buildKeyUri($dir),
null,
$data
);

$response = $request->send();
$body = $response->json();

return $body;
}

/**
* create a new key in a directory with auto generated id
*
* @param string $dir
* @param string $value
* @param int $ttl
* @param array $condition
* @return array $body
*/
public function setWithInOrderKey($dir, $value, $ttl = 0, $condition = array())
{
$data = array('value' => $value);

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

$request = $this->guzzleclient->post($this->buildKeyUri($dir), null, $data, array(
'query' => $condition
));
$response = $request->send();
$body = $response->json();
return $body;
}

}

0 comments on commit e4be41b

Please sign in to comment.