/** * Return the log body * @return array */ public function getBody() { $body = ApiHelper::toArray($this); if (isset($this->options['body'])) { return array_merge_recursive(['options' => ['raw_body' => $this->options['body']]], $body); } return $body; }
/** * Run a request on the api * @param $queryType * @return mixed * @throws ApiException * @throws RateLimitException */ public function request($queryType) { //Prepare the request $this->_request = new Request(ApiHelper::getMethod($queryType), $this->_owner->getRoute() . '/' . $this->_getUri($queryType)); $this->beforeRequest($queryType); //Run the request $this->_response = App::getInstance()->getClient()->send($this->_request, $this->_options); //Do administration $this->afterRequest($queryType); return $this->_result; }
/** * Return the attributes of this class in an assoc array * @return array */ public function getBody() { $body = []; foreach ($this->_attributes as $key => $attribute) { if ($attribute instanceof ArrayList) { foreach ($attribute as $objectKey => $object) { $body[$key][$objectKey] = $object->getBody(); } } else { if ($attribute instanceof Link || $attribute instanceof Model) { $body[$key] = $attribute->getBody(); } else { $body[$key] = ApiHelper::toArray($attribute); } } } return $body; }
/** * Returns the current namespace * @return string */ public function getNameSpace() { return ApiHelper::getNameSpace(get_called_class()); }
/** * Return the name of the webhook model based on the model parameter in the * called url * @return Model * @throws WebhookException */ public static function getWebhookModel() { if (isset($_GET['model']) && $_SERVER['REQUEST_METHOD'] === 'POST') { $model = ApiHelper::getModelPath($_GET['model']); if (class_exists($model)) { $webhook = new $model(); if (method_exists($webhook, 'loadModel')) { $webhook->loadModel(); return $webhook; } throw new WebhookException('Model [' . $model . '] is no webhook model'); } throw new WebhookException('Model [' . $model . '] not found'); } throw new WebhookException('No model given'); }