@@ 165-175 (lines=11) @@ | ||
162 | * @throws RestClientException |
|
163 | * @throws RestException |
|
164 | */ |
|
165 | public function post($path, $data, $parameters = []) |
|
166 | { |
|
167 | $parameters['json'] = $data; |
|
168 | try { |
|
169 | return $this->executeRequest('POST', $this->baseUrl . $path, $parameters); |
|
170 | } catch (ClientException $e) { |
|
171 | throw new RestClientException('Cannot create resource', $path, [], 3, $e); |
|
172 | } catch (TransferException $e) { |
|
173 | throw new RestException('Error while posting resource', $path, [], 4, $e); |
|
174 | } |
|
175 | } |
|
176 | ||
177 | /** |
|
178 | * @param string $path |
|
@@ 185-195 (lines=11) @@ | ||
182 | * @throws RestClientException |
|
183 | * @throws RestException |
|
184 | */ |
|
185 | public function put($path, $data, $parameters = []) |
|
186 | { |
|
187 | $parameters['json'] = $data; |
|
188 | ||
189 | try { |
|
190 | return $this->executeRequest('PUT', $this->baseUrl . $path, $parameters); |
|
191 | } catch (ClientException $e) { |
|
192 | throw new RestClientException('Cannot update resource', $path, [], 5, $e); |
|
193 | } catch (TransferException $e) { |
|
194 | throw new RestException('Error while puting resource', $path, [], 6, $e); |
|
195 | } |
|
196 | } |
|
197 | ||
198 | /** |