Attempts to INSERT this Endpoint object, using the class's annotated information via a HTTP POST Request.

@return self Returns an Endpoint of the same child object that called this method.

@throws \Exception
167597
public function insert(): self
    {
        /** @var self $data */
        $data = $this;

        if(!$this->validate("post", $missing))
        {
            throw new \Exception("[MVQN\REST\Endpoints\Endpoint] Annotations for the '".get_class($this)."' class require valid values be set ".
                "on all of the following properties before attempting an insert():\n> ".implode("\n> ", $missing)."\n");
        }

        /** @var self $endpoint */
        $endpoint = self::post($data);
        return $endpoint;
    }
571926
public function fulfillRequest()
    {
        if (! $this->supportsMethod($this->request->method)) {
            throw new Exception(
                'Method not allowed',
                static::ERROR_SCOPE | static::ERROR_HTTP_METHOD_NOT_ALLOWED,
                BaseResponse::HTTP_METHOD_NOT_ALLOWED
            );
        }

        $methodName = static::methodHandlerName($this->request->method);
        $models = $this->{$methodName}($this->request);

        if (is_null($models)) {
            throw new Exception(
                'Unknown ID',
                static::ERROR_SCOPE | static::ERROR_UNKNOWN_ID,
                BaseResponse::HTTP_NOT_FOUND
            );
        }

        if ($models instanceof Response) {
            $response = $models;
        } elseif ($models instanceof LengthAwarePaginator) {
            $items = new Collection($models->items());
            foreach ($items as $model) {
                $this->loadRelatedModels($model);
            }

            $response = new Response($items, static::successfulHttpStatusCode($this->request->method));

            $response->links = $this->getPaginationLinks($models);
            $response->included = $this->getIncludedModels($items);
            $response->errors = $this->getNonBreakingErrors();
        } else {
            if ($models instanceof Collection) {
                foreach ($models as $model) {
                    $this->loadRelatedModels($model);
                }
            } else {
                $this->loadRelatedModels($models);
            }

            $response = new Response($models, static::successfulHttpStatusCode($this->request->method, $models));

            $response->included = $this->getIncludedModels($models);
            $response->errors = $this->getNonBreakingErrors();
        }

        return $response;
    }
307928
public function execute()
    {
        if ($this->executed) {
            return;
        }
        
        $request = new Request(Request::POST);
        $request->setHost($this->app->getHost())
            ->setEndpoint(self::ENDPOINT)
            ->setCredentials($this->app->getAppId(), $this->app->getSecretKey());
        
        $result = $request->send(
            [
                "request_id" => $this->requestId,
                "scope" => $this->scope,
                "return_url" => $this->returnUrl
            ]
        );
        
        $data = $result->getData();
        
        if (!(isset($data["connect_id"]) && isset($data["gateway"]))) {
            throw new EndpointException("Invalid result structure: " . $result->getBody());
        }
        
        $this->connectId = $data["connect_id"];
        $this->gatewayUrl = $data["gateway"];
        $this->executed = true;
    }
78183
protected function create()
    {
        if ($this->executed) {
            return;
        }
        
        $request = new Request(Request::POST);
        $request->setHost($this->app->getHost())
            ->setEndpoint(self::ENDPOINT)
            ->setCredentials($this->app->getAppId(), $this->app->getSecretKey());
        
        $result = $request->send(
            [
                "email" => $this->email,
                "locale" => $this->locale
            ]
        );
        
        $data = $result->getData();
        
        if (!(isset($data["reference_id"]))) {
            throw new EndpointException("Invalid result structure: " . $result->getBody());
        }
        
        $this->status = $data["status"];
        $this->referenceId = $data["reference_id"];
        $this->executed = true;
    }
768037
public function insert()
    {
        Observer::dispatch(Observer::EVENT_ITEM_INSERT_BEFORE, array(
            'item' => $this
        ));

        $this->{static::DATEADDFIELD} = DateData::now();
        $insert = new Insert($this->_dbContainer);
        $insert->addFields($this->_fields);
        $insert->commit();
        $this->setId($insert->getId());
        $this->_origFields = $this->_fields;

        Observer::dispatch(Observer::EVENT_ITEM_INSERT_AFTER, array(
            'item' => $this
        ));

        return $this;
    }
165040
public function addInstance()
    {
        if (!$this->isXmlHttpRequest()) {
            throw new common_exception_BadRequest('wrong request mode');
        }

        $id = $this->getRequestParameter('id');

        $this->validateInstanceRoot($id);

        $this->signatureValidator->checkSignature(
            $this->getRequestParameter('signature'),
            $id
        );

        $response = [];

        $clazz = $this->getClass($id);
        $label = $this->getClassService()->createUniqueLabel($clazz);

        $instance = $this->getClassService()->createInstance($clazz, $label);

        if(!is_null($instance) && $instance instanceof core_kernel_classes_Resource){
            $response = [
                'label' => $instance->getLabel(),
                'uri'   => $instance->getUri()
            ];
        }

        $this->returnJson($response);
    }
529543
public function create() {
		$ssoServer = new \Flowpack\SingleSignOn\Server\Domain\Model\SsoServer();
		if ((string)$this->serverServiceBaseUri === '') {
			throw new Exception('Missing Flowpack.SingleSignOn.Server.server.serviceBaseUri setting', 1354805519);
		}
		$ssoServer->setServiceBaseUri($this->serverServiceBaseUri);
		if ((string)$this->serverKeyPairFingerprint === '') {
			throw new Exception('Missing Flowpack.SingleSignOn.Server.server.keyPairFingerprint setting', 1351699834);
		}
		$ssoServer->setKeyPairFingerprint($this->serverKeyPairFingerprint);
		return $ssoServer;
	}
163970
public function addprovider() {
		// Providers are ALWAYS at the root
		$parent = 0;

		$name = (isset($_REQUEST['Name'])) ? basename($_REQUEST['Name']) : _t('ExternalContent.NEWCONNECTOR', "New Connector");

		$type = $_REQUEST['ProviderType'];
		$providerClasses = ClassInfo::subclassesFor(self::$tree_class);

		if (!in_array($type, $providerClasses)) {
			throw new Exception("Invalid connector type");
		}

		$parentObj = null;

		// Create object
		$record = new $type();
		$record->ParentID = $parent;
		$record->Name = $record->Title = $name;

		// if (isset($_REQUEST['returnID'])) {
		// 	return $p->ID;
		// } else {
		// 	return $this->returnItemToUser($p);
		// }

		try {
			$record->write();
		} catch(ValidationException $ex) {
			$form->sessionMessage($ex->getResult()->message(), 'bad');
			return $this->getResponseNegotiator()->respond($this->request);
		}

		singleton('CMSPageEditController')->setCurrentPageID($record->ID);

		Session::set(
			"FormInfo.Form_EditForm.formError.message",
			sprintf(_t('ExternalContent.SourceAdded', 'Successfully created %s'), $type)
		);
		Session::set("FormInfo.Form_EditForm.formError.type", 'good');

		$msg = "New " . FormField::name_to_label($type) . " created";
		$this->response->addHeader('X-Status', rawurlencode(_t('ExternalContent.PROVIDERADDED', $msg)));
		return $this->getResponseNegotiator()->respond($this->request);
	}
537106
public function create(): self
    {
        $this->payload = null;
        $this->isPayloadDetached = false;
        $this->signatures = [];
        $this->isPayloadEncoded = null;

        return $this;
    }
789434
public function create()
	{
		try
		{
			$this->client->send(new Request($this->uri->withPath($this->uri->getPath().'resources')
				->withQuery(http_build_query([
					'path' => $this->getPath()
				], null, '&')), 'PUT'));
			$this->setContents([]);
		}
		catch (\Exception $exc)
		{
			throw $exc;
		}

		return $this;
	}
593735
public function createRequest()
    {
        if ($this->request == null){
            $this->request = Request::fromPhpContext($this);
        }

        return $this->request;
    }
450359
public function create()
    {
        //try to save all the fields we allow
        {
            if ($this->model->save($this->request->getPost(), $this->createFields)) {
                return $this->response($this->model->toArray());
            } else {
                //if not thorw exception
                throw new Exception($this->model->getMessages()[0]);
            }
        }
    }
229371
public function handleRequest()
    {
        try {
            $rtn = parent::handleRequest();

            if (extension_loaded('newrelic')) {
                $site = $this->toPhpName($this->config->get('site.name'));
                $controller = $this->toPhpName($this->route['controller']);
                $action = $this->toPhpName($this->route['action']);

                newrelic_name_transaction($site . '.' . $controller . '.' . $action);
            }
        } catch (HttpException\NotFoundException $ex) {
            $rtn = $this->handleHttpError($ex->getErrorCode());
        } catch (HttpException $ex) {
            if ((defined('CMS_ENV') && CMS_ENV == 'development') || array_key_exists('ex', $_GET)) {
                throw $ex;
            }

            $rtn = $this->handleHttpError($ex->getErrorCode());
        } catch (Exception $ex) {
            if ((defined('CMS_ENV') && CMS_ENV == 'development') || array_key_exists('ex', $_GET)) {
                throw $ex;
            }

            $rtn = $this->handleHttpError(500);
        }

        return $rtn;
    }
989503
protected function _insert()
    {
        $iInsertTime = time();
        $now = date('Y-m-d H:i:s', $iInsertTime);
        $this->oxorderarticles__oxtimestamp = new \OxidEsales\Eshop\Core\Field($now);

        return parent::_insert();
    }
1361588
function commit() {
		$this->savepoint--;

		if ($this->savepoint == 0) {
			$this->dbh->commit();
		}
		else { // not finished with transaction yet
			$this->dbh->exec('RELEASE SAVEPOINT save'.$this->savepoint);
		}

		return $this;
	}
991610
public function registerEndpoint()
    {
        $this->app->bind('endpoint', function ($app) {
            return new Endpoint($app['hook.factory']);
        });

        $this->app->alias('endpoint', Endpoint::class);
    }
587812
public function add()
    {
        $post = $this->Posts->newEntity();

        if ($this->request->is('post')) {
            //Only admins and managers can add posts on behalf of other users
            if (!$this->Auth->isGroup(['admin', 'manager'])) {
                $this->request = $this->request->withData('user_id', $this->Auth->user('id'));
            }

            $post = $this->Posts->patchEntity($post, $this->request->getData());

            if ($this->Posts->save($post)) {
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('post'));
    }