예제 #1
0
 /**
  * This will update all fields of a table record, issuing a PUT request to the record endpoint. Any fields that are not included will be cleared ().
  *
  * @param string $table
  * @param array  $criteria
  * @param array  $fields
  */
 public function setRecord($table, array $criteria = [], array $fields)
 {
     $record = $this->findRecord($table, $criteria);
     /** @var Response $response */
     $response = $this->browser->put($this->getEndpoint($table, $record->getId()), ["content-type" => "application/json"], json_encode(["fields" => $fields]));
     $this->guardResponse($table, $response);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function put($url, array $headers = array(), $content = '')
 {
     $response = $this->browser->put($url, $headers, $content);
     if (!$response->isSuccessful()) {
         throw $this->handleResponse($response);
     }
     return $response->getContent();
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function put($url, $content = '')
 {
     $headers = [];
     if (is_array($content)) {
         $content = json_encode($content);
         $headers[] = 'Content-Type: application/json';
     }
     $response = $this->browser->put($url, $headers, $content);
     $this->handleResponse($response);
     return $response->getContent();
 }
예제 #4
0
 /**
  * Common put request for all API calls
  *
  * @param string $resource The path to the resource wanted. For example v2/room
  * @param array $content Parameters be putted for example:
  *                              array(
  *                                'name'                => 'Example name',
  *                                'privacy'             => 'private',
  *                                'is_archived'         => 'false',
  *                                'is_guest_accessible' => 'false',
  *                                'topic'               => 'New topic',
  *                              )
  *
  * @return array Decoded array containing response
  * @throws Exception\RequestException
  */
 public function put($resource, $content = array())
 {
     $url = $this->baseUrl . $resource;
     $headers = array('Content-Type' => 'application/json', 'Authorization' => $this->auth->getCredential());
     $response = $this->browser->put($url, $headers, json_encode($content));
     if ($this->browser->getLastResponse()->getStatusCode() > 299) {
         throw new RequestException(json_decode($this->browser->getLastResponse()->getContent(), true));
     }
     return json_decode($response->getContent(), true);
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function put($url, $content = '')
 {
     $response = $this->browser->put($url, [], $content);
     $this->handleResponse($response);
     return $response->getContent();
 }
 /**
  * @param string $uri
  * @param string $data
  * @return bool
  */
 public function send($uri, $data)
 {
     $response = $this->browser->put($uri, [], $data);
     $statusCode = $response->getStatusCode();
     return $statusCode >= 200 && $statusCode < 300;
 }