forked from Furgas/php-api-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kyRESTClientInterface.php
100 lines (92 loc) · 3.17 KB
/
kyRESTClientInterface.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
96
97
98
99
100
<?php
/**
* Interface of REST client.
*
* If you want to use another REST client than the default, make a class
* implementing this interface and pass its instance to
* @see kyConfig::setRESTClient() method.
*
* @author Tomasz Sawicki (https://github.com/Furgas)
* @package Common\REST
*/
interface kyRESTClientInterface {
/**
* HTTP verb - GET. For getting objects.
* @var string
*/
const METHOD_GET = "GET";
/**
* HTTP verb - POST. For creating object.
* @var string
*/
const METHOD_POST = "POST";
/**
* HTTP verb - PUT. For updating objects.
* @var string
*/
const METHOD_PUT = "PUT";
/**
* HTTP verb - DELETE. For deleting objects.
* @var string
*/
const METHOD_DELETE = "DELETE";
/**
* Configuration injector.
*
* @param kyConfig $config Library configuration.
*/
public function setConfig(kyConfig $config);
/**
* Should send GET request to the server and return parsed data.
*
* @param string $controller Kayako controller to call.
* @param array $parameters Optional. List of additional parameters (like object identifiers or search parameters).
* @return array XML parsed to array in @see ky_xml_to_array() style.
*/
public function get($controller, $parameters = array());
/**
* Should create object on the server by sending POST request and return its data.
*
* Format of $files parameter:
* <pre>
* array(
* '<parameter name>' =>
* array('file_name' => '<file name>', 'contents' => '<file contents>'),
* ...repeat...
* )
* </pre>
*
* @param string $controller Kayako controller to call.
* @param array $parameters Optional. List of additional parameters (like object identifiers or search parameters).
* @param array $data Optional. Data array with parameter name as key and parameter value as value.
* @param array $files Optional. Array of files.
* @return array XML parsed to array in @see ky_xml_to_array() style.
*/
public function post($controller, $parameters = array(), $data = array(), $files = array());
/**
* Should update object on the server by sending PUT request and return its new data.
*
* Format of $files parameter:
* <pre>
* array(
* '<parameter name>' =>
* array('file_name' => '<file name>', 'contents' => '<file contents>'),
* ...repeat...
* )
* </pre>
*
* @param string $controller Kayako controller to call.
* @param array $parameters Optional. List of additional parameters (like object identifiers or search parameters).
* @param array $data Optional. Data array with parameter name as key and parameter value as value.
* @param array $files Optional. Array of files in form of: array('<parameter name>' => array('file_name' => '<file name>', 'contents' => '<file contents>'), ...).
* @return array XML parsed to array in @see ky_xml_to_array() style.
*/
public function put($controller, $parameters = array(), $data = array(), $files = array());
/**
* Should delete object from server by sending DELETE request.
*
* @param string $controller Kayako controller to call.
* @param array $parameters List of additional parameters (like object identifiers or search parameters).
*/
public function delete($controller, $parameters = array());
}