Example #1
0
 /**
  *  Update Edge
  *
  *  Request to update a edge in the collection
  *
  * @param array/Edge  $data - Array of the data for edge / Edge Object to replace .
  * @param string  $collection - specify the collectionID to update the edge from.
  * @param string  $id - specify the edge ID to update the edge.
  * @param array  $param - Array of parameters to send to the database as a options for edge request.
  *
  * @return array/Edge $response/$data - Return a response array of the request/Edge object.
  */
 public function UpdateEdge($data, $collection = NULL, $id = NULL, $param = NULL)
 {
     $option = array();
     if (isset($param['waitForSync'])) {
         $option['waitForSync'] = $param['waitForSync'];
     }
     if (isset($param['keepNull'])) {
         $option['keepNull'] = $param['keepNull'];
     }
     if (isset($param['mergeObjects'])) {
         $option['mergeObjects'] = $param['mergeObjects'];
     }
     if (isset($param['rev'])) {
         $option['rev'] = $param['rev'];
     }
     if (isset($param['policy'])) {
         $option['policy'] = $param['policy'];
     }
     $header = array();
     if (isset($param['ifmatch'])) {
         $header['If-Match'] = $param['ifmatch'];
     }
     if ($data instanceof Edge) {
         $jdata = $data->getData();
         $collection = $data->getCollectionID();
         $id = $data->getID();
         $response = $this->patch('edge/' . $collection . '/' . $id, $jdata, 'json', $option, $header);
         if ($response->code == '201' or $response->code == '202' or $response->code == '200') {
             $data->setData($response);
             return $data;
         } else {
             return $response;
         }
     } else {
         $jdata = $data;
         $response = $this->patch('edge/' . $collection . '/' . $id, $jdata, 'json', $option, $header);
         return $response;
     }
 }