예제 #1
0
 /**
  * Create Previous Page from data we received
  *
  * @param array $options
  * @return ObjectInterface
  * @throws ApiException
  */
 function previousPage($options = [])
 {
     $uri = $this->object->getAttribute("uri");
     // Check if next page exists
     if (!array_key_exists("previousPage", $this->object->getAttribute("values"))) {
         throw new ApiException("There is no previous page!");
     }
     // Add page query to get next page
     $options["query"] = "page=" . $this->object->getAttribute("values")["previousPage"]["page"];
     // If Async is enabled, we use httpAsyncGet function to make requests
     if (!OpenCrest::$async) {
         $content = $this->http("get", $uri, $options);
         return $this->factory->create($this->object, $content, $this->response);
     }
     // We make Async request and return null as data isn't available yet
     $this->httpAsync("get", $uri, $options);
     return null;
 }
예제 #2
0
 /**
  * @param ObjectInterface       $object
  * @param ObjectInterface|array $data
  * @return ObjectInterface
  * @throws ApiException
  */
 public function modify(ObjectInterface $object, $data)
 {
     // Get pattern
     $pattern = $object->getPattern();
     // Go through pattern and replace values with values got from data
     // If data dosn't contain value, throw apiException
     $values = $this->patternSearch($pattern, $data);
     // return values
     return $values;
 }