@@ 55-67 (lines=13) @@ | ||
52 | * |
|
53 | * @return string |
|
54 | */ |
|
55 | public function getXML($class, $id, $relation = false, $username = null, $password = null) |
|
56 | { |
|
57 | $this->authenticate($username, $password); |
|
58 | ||
59 | $response = Director::test( |
|
60 | $this->buildRestfulURL($class, $id, $relation, 'xml'), |
|
61 | null, |
|
62 | null, |
|
63 | 'GET' |
|
64 | ); |
|
65 | ||
66 | return ($response->isError()) ? $this->getErrorMessage($response) : $response->getBody(); |
|
67 | } |
|
68 | ||
69 | /** |
|
70 | * Used to emulate RESTful GET requests with JSON data. |
|
@@ 80-92 (lines=13) @@ | ||
77 | * |
|
78 | * @return string |
|
79 | */ |
|
80 | public function getJSON($class, $id, $relation = false, $username = null, $password = null) |
|
81 | { |
|
82 | $this->authenticate($username, $password); |
|
83 | ||
84 | $response = Director::test( |
|
85 | $this->buildRestfulURL($class, $id, $relation, 'json'), |
|
86 | null, |
|
87 | null, |
|
88 | 'GET' |
|
89 | ); |
|
90 | ||
91 | return ($response->isError()) ? $this->getErrorMessage($response) : $response->getBody(); |
|
92 | } |
|
93 | ||
94 | /** |
|
95 | * Used to emulate RESTful POST and PUT requests with XML data. |
|
@@ 106-119 (lines=14) @@ | ||
103 | * |
|
104 | * @return string |
|
105 | */ |
|
106 | public function putXML($class, $id = false, $relation = false, $data, $username = null, $password = null) |
|
107 | { |
|
108 | $this->authenticate($username, $password); |
|
109 | ||
110 | $response = Director::test( |
|
111 | $this->buildRestfulURL($class, $id, $relation, 'xml'), |
|
112 | array(), |
|
113 | null, |
|
114 | ($id) ? 'PUT' : 'POST', |
|
115 | $data |
|
116 | ); |
|
117 | ||
118 | return ($response->isError()) ? $this->getErrorMessage($response) : $response->getBody(); |
|
119 | } |
|
120 | ||
121 | /** |
|
122 | * Used to emulate RESTful POST and PUT requests with JSON data. |
|
@@ 133-146 (lines=14) @@ | ||
130 | * |
|
131 | * @return string |
|
132 | */ |
|
133 | public function putJSON($class = false, $id = false, $relation = false, $data, $username = null, $password = null) |
|
134 | { |
|
135 | $this->authenticate($username, $password); |
|
136 | ||
137 | $response = Director::test( |
|
138 | $this->buildRestfulURL($class, $id, $relation, 'json'), |
|
139 | array(), |
|
140 | null, |
|
141 | ($id) ? 'PUT' : 'POST', |
|
142 | $data |
|
143 | ); |
|
144 | ||
145 | return ($response->isError()) ? $this->getErrorMessage($response) : $response->getBody(); |
|
146 | } |
|
147 | ||
148 | /** |
|
149 | * Used to emulate RESTful DELETE requests. |
|
@@ 159-171 (lines=13) @@ | ||
156 | * |
|
157 | * @return string |
|
158 | */ |
|
159 | public function deleteXML($class, $id, $relation = false, $username = null, $password = null) |
|
160 | { |
|
161 | $this->authenticate($username, $password); |
|
162 | ||
163 | $response = Director::test( |
|
164 | $this->buildRestfulURL($class, $id, $relation, 'xml'), |
|
165 | null, |
|
166 | null, |
|
167 | 'DELETE' |
|
168 | ); |
|
169 | ||
170 | return ($response->isError()) ? $this->getErrorMessage($response) : $response->getBody(); |
|
171 | } |
|
172 | ||
173 | /** |
|
174 | * Used to emulate RESTful DELETE requests. |
|
@@ 184-196 (lines=13) @@ | ||
181 | * |
|
182 | * @return string |
|
183 | */ |
|
184 | public function deleteJSON($class, $id, $relation = false, $username = null, $password = null) |
|
185 | { |
|
186 | $this->authenticate($username, $password); |
|
187 | ||
188 | $response = Director::test( |
|
189 | $this->buildRestfulURL($class, $id, $relation, 'json'), |
|
190 | null, |
|
191 | null, |
|
192 | 'DELETE' |
|
193 | ); |
|
194 | ||
195 | return ($response->isError()) ? $this->getErrorMessage($response) : $response->getBody(); |
|
196 | } |
|
197 | ||
198 | /** |
|
199 | * Faking an HTTP Basicauth login in the PHP environment |