Submits the request to the GiroCheckout API by using the given request method. Uses all given and needed
params in the correct order.

@return boolean
@throws GiroCheckout_SDK_Exception_helper
173621
public function submit() {
    $Config = GiroCheckout_SDK_Config::getInstance();

    if ($Config->getConfig('DEBUG_MODE')) {
      GiroCheckout_SDK_Debug_helper::getInstance()->logParamsSet($this->params);
    }

    if( empty($this->secret) ) {
      throw new GiroCheckout_SDK_Exception_helper('Secret may not be empty');
    }

    try {
      $submitParams = $this->requestMethod->getSubmitParams($this->params);

      // Some special validations
      $strError = "";
      if( !$this->requestMethod->validateParams( $submitParams, $strError ) ) {
        throw new GiroCheckout_SDK_Exception_helper('Paydirekt parameter error: '. $strError);
      }

      if ($this->requestMethod->needsHash()) {
        $submitParams['hash'] = GiroCheckout_SDK_Hash_helper::getHMACMD5Hash($this->secret, $submitParams);
      }

      $submitParams['sourceId'] = $this->getHostSourceId() . ';' . $this->getSDKSourceId() . ';';

      if (isset($this->params['sourceId'])) {
        $submitParams['sourceId'] .= $this->params['sourceId'];
      }
      else {
        $submitParams['sourceId'] .= ';';
      }

      // Send additional info fields for support reasons
      if (isset($_SERVER['HTTP_USER_AGENT'])) {
        $submitParams['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
      }
      if (isset($this->params['orderId'])) {
        $submitParams['orderId'] = $this->params['orderId'];
      }
      if (isset($this->params['customerId'])) {
        $submitParams['customerId'] = $this->params['customerId'];
      }

      list($header, $body) = GiroCheckout_SDK_Curl_helper::submit($this->requestMethod->getRequestURL(), $submitParams);
      $this->responseRaw = print_r($header, TRUE) . "\n$body";

      $response = GiroCheckout_SDK_Curl_helper::getJSONResponseToArray($body);

      if ($response['rc'] == 5000 || $response['rc'] == 5001) {
        throw new GiroCheckout_SDK_Exception_helper('Authentication failure, please double-check your project settings', $response['rc'] );
      }
      elseif (!isset($header['hash'])) {
        throw new GiroCheckout_SDK_Exception_helper('Hash in response is missing', 5002);
      }
      elseif (isset($header['hash']) && $header['hash'] !== GiroCheckout_SDK_Hash_helper::getHMACMD5HashString($this->secret, $body)) {
        throw new GiroCheckout_SDK_Exception_helper('Hash mismatch in response', 5002);
      }
      else {
        $this->response = $this->requestMethod->checkResponse($response);
        if ($Config->getConfig('DEBUG_MODE')) {
          GiroCheckout_SDK_Debug_helper::getInstance()->logReplyParams($this->response);
        }
      }
    }
    catch (Exception $e) {
      if ($e instanceof GiroCheckout_SDK_Exception_helper) {
         throw $e;
      }
      else {
        throw new GiroCheckout_SDK_Exception_helper( 'Failure: ' . $e->getMessage() );
      }
    }

    return TRUE;
  }
735778
public function handle(Request $request)
    {
        //get the correct method
        if ($this->method === 'GET') {
            $values = $request->query->all();
        } else {
            $values = $request->request->all();
        }

        // The form is submitted if at least one field is present
        if (count(array_intersect_key($values, $this->rows)) > 0) {
            return $this->submitForm($values);
        }
    }
1060103
protected final function doRequest()
    {
        $stepId = count($this->results);
        $request = $this->steps[$stepId]($this->results);
        $response = $this->requestor->doRequest($request);
        $this->checkGotResponse($response);
        $this->saveResult($stepId, $response);
    }
283097
public function submit(Request $request)
    {
        try {
            $response = $this->browser->call(
                $this->buildUrl($request),
                $request->getMethod(),
                $request->getHeaders(),
                $request->getData()
                );
              
            $response = ResponseFactory::createResponse($response, $request);
            return $response;
        } catch(\Exception $e) {
            throw new Exception\OpenSearchServerException('Error while connecting to OpenSearchServer: ' . $e->getMessage(), 1);
        } 
    }
320598
public function method()
    {
        if (isset($this->parameters->post()['_method'])) {
            $method = strtoupper($this->parameters->post()['_method']);
            if (in_array($method, self::$allowedHackMethods)) {
                return $method;
            }
        }
        return $this->getParam('REQUEST_METHOD');
    }
268343
def submit(self, method, method_args=(), method_kwargs={}, done_callback=None, done_kwargs={}, loop=None):
        '''
        
        '''
        _future = self.pool.submit(method, *method_args, **method_kwargs)
        self.current_id += 1
        if done_callback:
            _future.add_done_callback(lambda _f:done_callback(_f,loop,**done_kwargs))#done kwargs, hardcoded kwargs
        self.request_pool[self.current_id] = _future
        return self.current_id, _future
787230
protected function _checkRequestMethods()
    {
        if ($this->_request()->is('put')) {
            throw new BadRequestException('JSON API does not support the PUT method, use PATCH instead');
        }

        if (!$this->_request()->contentType()) {
            return true;
        }

        $jsonApiMimeType = $this->_response()->getMimeType('jsonapi');

        if ($this->_request()->contentType() !== $jsonApiMimeType) {
            throw new BadRequestException("JSON API requests with data require the \"$jsonApiMimeType\" Content-Type header");
        }

        return true;
    }
215792
protected function submitEditCheckout()
    {
        $this->setSubmitted('order');

        $this->setAddressFormCheckout();
        $this->submitAddAddressCheckout();

        if ($this->isPosted('checkout_login') && empty($this->uid)) {
            $this->show_login_form = true;
        }

        $this->same_payment_address = (bool) $this->getPosted('same_payment_address', true, false, 'bool');

        if ($this->isPosted('update')) {
            $this->setMessage($this->text('Form has been updated'), 'success', false);
        }

        $this->submitLoginCheckout();

        if ($this->isPosted('checkout_anonymous')) {
            $this->show_login_form = false;
        }

        $this->validateCouponCheckout();
        $this->submitCartCheckout();
        $this->submitOrderCheckout();
    }
1297910
public function process()
        {
            try {
                $controllerName = $this->getController();
                if(null == $controllerName) {
                    throw new Exception('Method not allowed', 405);
                }
                $controller = new \ReflectionClass($controllerName);
                if(!$controller->isInstantiable()) {
                    throw new Exception('Bad Request', 400);
                }
                try {
                    $method = $controller->getMethod($this->request['method']);
                } catch(ReflectionException $re) {
                    throw new Exception('Unsupported HTTP method ' . $this->request['method'], 405);
                }
                if(!$method->isStatic()) {
                    $controller = $controller->newInstance($this->request);
                    if(!$controller->checkAuth()) {
                        throw new Exception('Unauthorized', 401);
                    }
                    $method->invoke($controller);
                    $this->response = $controller->getResponse();
                    $this->responseStatus = $controller->getResponseStatus();
                } else {
                    throw new Exception('Static methods not supported in Controllers', 500);
                }
                if(is_null($this->response)) {
                    throw new Exception('Method not allowed', 405);
                }
            } catch (Exception $re) {
                $this->responseStatus = $re->getCode();
                $this->response = array('ErrorCode' => $re->getCode(), 'ErrorMessage' => $re->getMessage());
            }
            $this->response()->send();
        }
993599
public function execute() {
        global $CFG, $PAGE, $SITE;

        require_once($CFG->dirroot . "/{$CFG->admin}/tool/dataprivacy/lib.php");

        if (!isset($this->get_custom_data()->requestid)) {
            throw new coding_exception('The custom data \'requestid\' is required.');
        }
        $requestid = $this->get_custom_data()->requestid;

        $requestpersistent = new data_request($requestid);
        $request = $requestpersistent->to_record();

        // Check if this request still needs to be processed. e.g. The user might have cancelled it before this task has run.
        $status = $requestpersistent->get('status');
        if (!api::is_active($status)) {
            mtrace("Request {$requestid} with status {$status} doesn't need to be processed. Skipping...");
            return;
        }

        if (!\tool_dataprivacy\data_registry::defaults_set()) {
            // Warn if no site purpose is defined.
            mtrace('Warning: No purpose is defined at the system level. Deletion will delete all.');
        }

        // Grab the manager.
        // We set an observer against it to handle failures.
        $manager = new \core_privacy\manager();
        $manager->set_observer(new \tool_dataprivacy\manager_observer());

        // Get the user details now. We might not be able to retrieve it later if it's a deletion processing.
        $foruser = core_user::get_user($request->userid);

        // Update the status of this request as pre-processing.
        mtrace('Pre-processing request...');
        api::update_request_status($requestid, api::DATAREQUEST_STATUS_PROCESSING);
        $contextlistcollection = $manager->get_contexts_for_userid($requestpersistent->get('userid'));

        mtrace('Fetching approved contextlists from collection');
        $approvedclcollection = api::get_approved_contextlist_collection_for_collection(
                $contextlistcollection, $foruser, $request->type);

        mtrace('Processing request...');
        $completestatus = api::DATAREQUEST_STATUS_COMPLETE;
        $deleteuser = false;

        if ($request->type == api::DATAREQUEST_TYPE_EXPORT) {
            // Get the user context.
            $usercontext = \context_user::instance($foruser->id, IGNORE_MISSING);
            if (!$usercontext) {
                mtrace("Request {$requestid} cannot be processed due to a missing user context instance for the user
                    with ID {$foruser->id}. Skipping...");
                return;
            }

            // Export the data.
            $exportedcontent = $manager->export_user_data($approvedclcollection);

            $fs = get_file_storage();
            $filerecord = new \stdClass;
            $filerecord->component = 'tool_dataprivacy';
            $filerecord->contextid = $usercontext->id;
            $filerecord->userid    = $foruser->id;
            $filerecord->filearea  = 'export';
            $filerecord->filename  = 'export.zip';
            $filerecord->filepath  = '/';
            $filerecord->itemid    = $requestid;
            $filerecord->license   = $CFG->sitedefaultlicense;
            $filerecord->author    = fullname($foruser);
            // Save somewhere.
            $thing = $fs->create_file_from_pathname($filerecord, $exportedcontent);
            $completestatus = api::DATAREQUEST_STATUS_DOWNLOAD_READY;
        } else if ($request->type == api::DATAREQUEST_TYPE_DELETE) {
            // Delete the data.
            $manager = new \core_privacy\manager();
            $manager->set_observer(new \tool_dataprivacy\manager_observer());

            $manager->delete_data_for_user($approvedclcollection);
            $completestatus = api::DATAREQUEST_STATUS_DELETED;
            $deleteuser = !$foruser->deleted;
        }

        // When the preparation of the metadata finishes, update the request status to awaiting approval.
        api::update_request_status($requestid, $completestatus);
        mtrace('The processing of the user data request has been completed...');

        // Create message to notify the user regarding the processing results.
        $dpo = core_user::get_user($request->dpo);
        $message = new message();
        $message->courseid = $SITE->id;
        $message->component = 'tool_dataprivacy';
        $message->name = 'datarequestprocessingresults';
        $message->userfrom = $dpo;
        $message->replyto = $dpo->email;
        $message->replytoname = fullname($dpo->email);

        $typetext = null;
        // Prepare the context data for the email message body.
        $messagetextdata = [
            'username' => fullname($foruser)
        ];

        $output = $PAGE->get_renderer('tool_dataprivacy');
        $emailonly = false;
        $notifyuser = true;
        switch ($request->type) {
            case api::DATAREQUEST_TYPE_EXPORT:
                // Check if the user is allowed to download their own export. (This is for
                // institutions which centrally co-ordinate subject access request across many
                // systems, not just one Moodle instance, so we don't want every instance emailing
                // the user.)
                if (!api::can_download_data_request_for_user($request->userid, $request->requestedby, $request->userid)) {
                    $notifyuser = false;
                }

                $typetext = get_string('requesttypeexport', 'tool_dataprivacy');
                // We want to notify the user in Moodle about the processing results.
                $message->notification = 1;
                $datarequestsurl = new moodle_url('/admin/tool/dataprivacy/mydatarequests.php');
                $message->contexturl = $datarequestsurl;
                $message->contexturlname = get_string('datarequests', 'tool_dataprivacy');
                // Message to the recipient.
                $messagetextdata['message'] = get_string('resultdownloadready', 'tool_dataprivacy', $SITE->fullname);
                // Prepare download link.
                $downloadurl = moodle_url::make_pluginfile_url($usercontext->id, 'tool_dataprivacy', 'export', $thing->get_itemid(),
                    $thing->get_filepath(), $thing->get_filename(), true);
                $downloadlink = new action_link($downloadurl, get_string('download', 'tool_dataprivacy'));
                $messagetextdata['downloadlink'] = $downloadlink->export_for_template($output);
                break;
            case api::DATAREQUEST_TYPE_DELETE:
                $typetext = get_string('requesttypedelete', 'tool_dataprivacy');
                // No point notifying a deleted user in Moodle.
                $message->notification = 0;
                // Message to the recipient.
                $messagetextdata['message'] = get_string('resultdeleted', 'tool_dataprivacy', $SITE->fullname);
                // Message will be sent to the deleted user via email only.
                $emailonly = true;
                break;
            default:
                throw new moodle_exception('errorinvalidrequesttype', 'tool_dataprivacy');
        }

        $subject = get_string('datarequestemailsubject', 'tool_dataprivacy', $typetext);
        $message->subject           = $subject;
        $message->fullmessageformat = FORMAT_HTML;
        $message->userto = $foruser;

        // Render message email body.
        $messagehtml = $output->render_from_template('tool_dataprivacy/data_request_results_email', $messagetextdata);
        $message->fullmessage = html_to_text($messagehtml);
        $message->fullmessagehtml = $messagehtml;

        // Send message to the user involved.
        if ($notifyuser) {
            $messagesent = false;
            if ($emailonly) {
                // Do not sent an email if the user has been deleted. The user email has been previously deleted.
                if (!$foruser->deleted) {
                    $messagesent = email_to_user($foruser, $dpo, $subject, $message->fullmessage, $messagehtml);
                }
            } else {
                $messagesent = message_send($message);
            }

            if ($messagesent) {
                mtrace('Message sent to user: ' . $messagetextdata['username']);
            }
        }

        // Send to requester as well in some circumstances.
        if ($foruser->id != $request->requestedby) {
            $sendtorequester = false;
            switch ($request->type) {
                case api::DATAREQUEST_TYPE_EXPORT:
                    // Send to the requester as well if they can download it, unless they are the
                    // DPO. If we didn't notify the user themselves (because they can't download)
                    // then send to requester even if it is the DPO, as in that case the requester
                    // needs to take some action.
                    if (api::can_download_data_request_for_user($request->userid, $request->requestedby, $request->requestedby)) {
                        $sendtorequester = !$notifyuser || !api::is_site_dpo($request->requestedby);
                    }
                    break;
                case api::DATAREQUEST_TYPE_DELETE:
                    // Send to the requester if they are not the DPO and if they are allowed to
                    // create data requests for the user (e.g. Parent).
                    $sendtorequester = !api::is_site_dpo($request->requestedby) &&
                            api::can_create_data_request_for_user($request->userid, $request->requestedby);
                    break;
                default:
                    throw new moodle_exception('errorinvalidrequesttype', 'tool_dataprivacy');
            }

            // Ensure the requester has the capability to make data requests for this user.
            if ($sendtorequester) {
                $requestedby = core_user::get_user($request->requestedby);
                $message->userto = $requestedby;
                $messagetextdata['username'] = fullname($requestedby);
                // Render message email body.
                $messagehtml = $output->render_from_template('tool_dataprivacy/data_request_results_email', $messagetextdata);
                $message->fullmessage = html_to_text($messagehtml);
                $message->fullmessagehtml = $messagehtml;

                // Send message.
                if ($emailonly) {
                    email_to_user($requestedby, $dpo, $subject, $message->fullmessage, $messagehtml);
                } else {
                    message_send($message);
                }
                mtrace('Message sent to requester: ' . $messagetextdata['username']);
            }
        }

        if ($deleteuser) {
            // Delete the user.
            delete_user($foruser);
        }
    }
449788
public function methodWather()
  {
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
      if (!isset($_POST['csrf_token'])) {
        $this->errors[] = 'CSRF token not found!';
      } elseif (!hash_equals($_POST['csrf_token'], $_SESSION['csrf_token'])) {
        $this->errors[] = 'CSRF token not valid!';
      }
      if (!empty($this->errors)) {
        exit(array_shift($this->errors));
      }
    }
  }
652296
public function processRequest()
    {
        if(!$this->canProcessRequest())
        {
            return false;
        }

        // Find the requested method
        $xCallableObject = $this->xRepository->getCallableObject($this->sRequestedClass);
        if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
        {
            // Unable to find the requested object or method
            throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid',
                ['class' => $this->sRequestedClass, 'method' => $this->sRequestedMethod]));
        }

        // Call the requested method
        $jaxon = jaxon();
        $aArgs = $jaxon->getRequestHandler()->processArguments();
        $xResponse = $xCallableObject->call($this->sRequestedMethod, $aArgs);
        if(($xResponse))
        {
            $jaxon->getResponseManager()->append($xResponse);
        }
        return true;
    }
1222191
public static function handleRequest() {
        $response = get_response();
        try {
            $routes = self::$routes->getRoutes();
            if (!empty($routes)) {
                $beforeRoutes = self::$beforeRoutes->getRoutes();
                if (!empty($beforeRoutes)) {
                    foreach ($beforeRoutes as $beforeRoute) {
                        self::executeAction($beforeRoute->getAction(), array_merge($_REQUEST, $beforeRoute->getParameters()));
                    }
                }

                try {
                    foreach ($routes as $route) {
                        $routeResult = self::executeAction($route->getAction(), array_merge($_REQUEST, $route->getParameters()));
                        if (isset($routeResult)) {
                            $response->content($routeResult);
                        }
                    }
                    $afterRoutes = self::$afterRoutes->getRoutes();
                    if (!empty($afterRoutes)) {
                        foreach ($afterRoutes as $afterRoute) {
                            $routeResult = self::executeAction($afterRoute->getAction(), array_merge($_REQUEST, $afterRoute->getParameters()));
                            if (isset($routeResult)) {
                                $response->content($routeResult);
                            }
                        }
                    }
                    $response->send();
                }
                catch (ActionNotFoundException $notFoundException) {
                    self::handleRequestNotFound();
                }
            }
            else {
                self::handleRequestNotFound();
            }
        }
        catch (Throwable $ex) {
            self::handleRequestException($ex);
        }
    }
856023
public function isSuccess()
    {
        $statuscode = $this->response->getStatusCode();

        if(!in_array($statuscode, [200, 204], true))
        {
            throw new Exception('HTTP Code ' . $statuscode . ' ' . $this->response->getBody());
        }

        return true;
    }
102919
public function initAuth()
    {
        if ($this->_verified)
            return true;

        $output = $this->postRequest(
            'identification/bankid/mobile',
            [
                'useEasyLogin'        => false,
                'generateEasyLoginId' => false,
                'userId'              => $this->_username,
            ]);

        if ($output->status != 'USER_SIGN')
            throw new Exception('Unable to use Mobile BankID. Check if the user have enabled Mobile BankID.', 10);

        $this->saveSession();

        return true;
    }
877964
public function send()
    {
        $req = radius_send_request($this->res);
        if (!$req) {
            throw new Auth_RADIUS_Exception('Error sending request: ' . $this->getError());
        }

        switch($req) {
            case RADIUS_ACCESS_ACCEPT:
                if (is_subclass_of($this, 'auth_radius_acct')) {
                    throw new Auth_RADIUS_Exception('RADIUS_ACCESS_ACCEPT is unexpected for accounting');
                }
                return true;

            case RADIUS_ACCESS_REJECT:
                return false;

            case RADIUS_ACCOUNTING_RESPONSE:
                if (is_subclass_of($this, 'auth_radius_pap')) {
                    throw new Auth_RADIUS_Exception('RADIUS_ACCOUNTING_RESPONSE is unexpected for authentication');
                }
                return true;

            default:
                throw new Auth_RADIUS_Exception("Unexpected return value: $req");
        }

    }
64193
public function run() {

        foreach ( $this->requests as $request ) {

            if ( isset($request['ERROR_CODE']) && isset($request['ERROR_MESSAGE']) ) {

                $this->logger->warning("Invalid request ".$request['ID']);

                $result = self::packJsonError($request['ERROR_CODE'], $request['ERROR_MESSAGE'], $request['ID']);

                if ( !is_null($result) ) $this->results[] = $result;

            } else {

                try {

                    $this->logger->debug("Serving request ".$request['METHOD']."(".$request['ID'].")");

                    $response = $this->runSingleRequest($request['METHOD'], $request['PARAMETERS']);

                    $result = self::packJsonSuccess($response, $request['ID']);

                } catch (RpcException $re) {

                    $this->logger->warning("Error handling request ".$request['ID'].": ".$re->getMessage());

                    $result = self::packJsonError($re->getCode(), $re->getMessage(), $request['ID']);

                } catch (Exception $e) {

                    $this->logger->error($e->getMessage());

                    throw $e;

                }

                if ( !is_null($result) ) $this->results[] = $result;

            }


        }

        if ( empty($this->results) ) {

            return null;

        } else if ( $this->is_batch_request ) {

            return $this->results;

        } else {

            return $this->results[0];

        }

    }