-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApi_Version1.php
95 lines (79 loc) · 1.89 KB
/
Api_Version1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
include_once 'AbstractWebservice.php';
/**
* Api version 1
*
* @author AckimWilliams
* @see ./problem_description
*/
class Api_Version1 extends AbstractWebservice
{
protected $_api_version = "v1";
/**
* (non-PHPdoc)
* @see \Webservice\AbstractWebservice::authenticate()
*/
public function authenticate( $username, $password )
{
throw new \Exception( "Method not supported." );
}
/**
* Delete records
*
* @param string $key
* @throws \Exception
* @return Response
*/
public function delete( $key )
{
$requestUri = $this->_webserviceRoot . "/" . $this->_api_version . "/key?" .
"key=" . $key;
return $this->execute( $requestUri, AbstractWebservice::API_METHOD_DELETE );
}
/**
* List records
*
* GET /v1/list
* HTTP/1.1 200 OK
* {"status": "ok", "keys": ["mykey"]}
*
* @throws \Exception
* @return Response
*/
public function getList()
{
$requestUri = $this->_webserviceRoot . "/" . $this->_api_version . "/list";
return $this->execute( $requestUri, AbstractWebservice::API_METHOD_GET );
}
/**
* Get record
*
* @param string $key
* @throws \Exception
* @return Response
*/
public function get( $key )
{
$requestUri = $this->_webserviceRoot . "/" . $this->_api_version . "/key?" .
"key=" . $key;
return $this->execute( $requestUri, AbstractWebservice::API_METHOD_GET );
}
/**
* Update record
*
* This method only allows you to set a single value of
* a single key
*
* @param string $key
* @param string $value
* @throws \Exception
* @return Response
*/
public function put( $key, $value )
{
$requestUri = $this->_webserviceRoot . "/" . $this->_api_version . "/key?" .
"key=" . $key .
"&value=" . $value;
return $this->execute( $requestUri, AbstractWebservice::API_METHOD_PUT );
}
}