Populates the properties with the response from the list rules request.

@param string $response The body of the response of the list rules request
182668
public function parseXml($response)
    {
        parent::parseXml($response);
        $listRulesResultXml = new \SimpleXMLElement($response);
        $this->_ruleInfos = [];

        foreach ($listRulesResultXml->entry as $entry) {
            $ruleInfo = new RuleInfo();
            $ruleInfo->parseXml($entry->asXML());
            $this->_ruleInfos[] = $ruleInfo;
        }
    }
544868
protected function addServerTimingHeaders(Response $response)
    {
        if ($this->hasCollector('time')) {
            $collector = $this->getCollector('time');

            $headers = [];
            foreach ($collector->collect()['measures'] as $k => $m) {
                $headers[] = sprintf('%d=%F; "%s"', $k, $m['duration'] * 1000, str_replace('"', "'", $m['label']));
            }

            $response->headers->set('Server-Timing', $headers, false);
        }
    }
997124
function parseRateLimit(Response $response) {
        $newRateLimit = \GithubService\RateLimit::createFromResponse($response);
        if ($newRateLimit != null) {
            $this->rateLimit = $newRateLimit;
        }
    }
468866
function process_response($request, $response)
    {
        if (! $request->user->isAnonymous()) {
            $request->session->setData($this->session_key, $request->user->id);
        }
        return $response;
    }
588514
protected function processResponseType($response = null)
	{
		if ($response instanceof Response) {
			$this->response = $response;
		}
		elseif (is_string($response) || is_numeric($response)) {
			$this->response->setContent($response);
		}
		elseif (is_array($response)) {
			$this->response = new JsonResponse($response);
		}
		else {
			throw new \Exception("App cannot process this response type");
		}
	}
296007
function build(iHttpResponse $response)
    {
        ($this->version       === null) ?: $response->setVersion($this->version);
        ($this->status_code   === null) ?: $response->setStatusCode($this->status_code);
        ($this->status_reason === null) ?: $response->setStatusReason($this->status_reason);
        ($this->headers       === null) ?: $response->setHeaders($this->headers);
        ($this->body          === null) ?: $response->setBody($this->body);
    }
438690
private function makeSession($response)
    {
        $this->session()->setData([
            'pagseguro_payment' => ['payment_link' => $response->getPaymentLink(),
                'payment_type'  => strtolower(Boleto::class),
                'order_id'      => $this->lastRealOrderId(),
            ]
        ]);
    }
387149
protected function populate(stdClass $response)
    {
        $entry = clone $this;

        $entry->data->id = $this->getIfSet('id', $response);
        $entry->data->status = $this->getIfSet('status', $response);
        $entry->data->operation = $this->getIfSet('operation', $response);

        if (isset($response->amount)) {
            $entry->data->amount->total = $this->getIfSet('total', $response->amount);
            $entry->data->amount->fee = $this->getIfSet('fee', $response->amount);
            $entry->data->amount->liquid = $this->getIfSet('liquid', $response->amount);
            $entry->data->amount->currency = $this->getIfSet('currency', $response->amount);
        }

        if (isset($response->details)) {
            $entry->data->details = $this->getIfSet('details', $response);
        }

        if (isset($response->{'parent'}) && isset($response->{'parent'}->payments)) {
            $payments = new Payment($entry->moip);
            $payments->populate($response->{'parent'}->payments);

            $entry->data->parentPayments = $payments;
        }

        return $entry;
    }
214571
public function format($response)
	{
		$response->getHeaders()->set('Content-Type', 'application/pdf');
		$response->content = $this->formatPdf($response);
	}
600742
public function execute($response) {

        $ok = $this->check_tool_proxy(null, $response->get_request_data());
        if ($ok) {
            $toolproxy = $this->get_service()->get_tool_proxy();
        } else {
            $toolproxy = null;
            $response->set_code(401);
        }
        $tools = array();

        // Ensure all required elements are present in the Tool Proxy.
        if ($ok) {
            $toolproxyjson = json_decode($response->get_request_data());
            $ok = !empty($toolproxyjson);
            if (!$ok) {
                debugging('Tool proxy is not properly formed JSON');
            } else {
                $ok = isset($toolproxyjson->tool_profile->product_instance->product_info->product_family->vendor->code);
                $ok = $ok && isset($toolproxyjson->security_contract->shared_secret);
                $ok = $ok && isset($toolproxyjson->tool_profile->resource_handler);
                if (!$ok) {
                    debugging('One or more missing elements from tool proxy: vendor code, shared secret or resource handlers');
                }
            }
        }

        // Check all capabilities requested were offered.
        if ($ok) {
            $offeredcapabilities = explode("\n", $toolproxy->capabilityoffered);
            $resources = $toolproxyjson->tool_profile->resource_handler;
            $errors = array();
            foreach ($resources as $resource) {
                if (isset($resource->message)) {
                    foreach ($resource->message as $message) {
                        if (!in_array($message->message_type, $offeredcapabilities)) {
                            $errors[] = $message->message_type;
                        } else if (isset($resource->parameter)) {
                            foreach ($message->parameter as $parameter) {
                                if (isset($parameter->variable) && !in_array($parameter->variable, $offeredcapabilities)) {
                                    $errors[] = $parameter->variable;
                                }
                            }
                        }
                    }
                }
            }
            if (count($errors) > 0) {
                $ok = false;
                debugging('Tool proxy contains capabilities which were not offered: ' . implode(', ', $errors));
            }
        }

        // Check all services requested were offered (only tool services currently supported).
        if ($ok && isset($toolproxyjson->security_contract->tool_service)) {
            $contexts = lti_get_contexts($toolproxyjson);
            $profileservice = lti_get_service_by_name('profile');
            $profileservice->set_tool_proxy($toolproxy);
            $context = $profileservice->get_service_path() . $profileservice->get_resources()[0]->get_path() . '#';
            $offeredservices = explode("\n", $toolproxy->serviceoffered);
            $services = lti_get_services();
            $tpservices = $toolproxyjson->security_contract->tool_service;
            $errors = array();
            foreach ($tpservices as $service) {
                $fqid = lti_get_fqid($contexts, $service->service);
                if (substr($fqid, 0, strlen($context)) !== $context) {
                    $errors[] = $service->service;
                } else {
                    $id = explode('#', $fqid, 2);
                    $aservice = lti_get_service_by_resource_id($services, $id[1]);
                    $classname = explode('\\', get_class($aservice));
                    if (empty($aservice) || !in_array($classname[count($classname) - 1], $offeredservices)) {
                        $errors[] = $service->service;
                    }
                }
            }
            if (count($errors) > 0) {
                $ok = false;
                debugging('Tool proxy contains services which were not offered: ' . implode(', ', $errors));
            }
        }

        // Extract all launchable tools from the resource handlers.
        if ($ok) {
            $resources = $toolproxyjson->tool_profile->resource_handler;
            $messagetypes = [
                'basic-lti-launch-request',
                'ContentItemSelectionRequest',
            ];
            foreach ($resources as $resource) {
                $launchable = false;
                $messages = array();
                $tool = new \stdClass();

                $iconinfo = null;
                if (is_array($resource->icon_info)) {
                    $iconinfo = $resource->icon_info[0];
                } else {
                    $iconinfo = $resource->icon_info;
                }
                if (isset($iconinfo) && isset($iconinfo->default_location) && isset($iconinfo->default_location->path)) {
                    $tool->iconpath = $iconinfo->default_location->path;
                }

                foreach ($resource->message as $message) {
                    if (in_array($message->message_type, $messagetypes)) {
                        $launchable = $launchable || ($message->message_type === 'basic-lti-launch-request');
                        $messages[$message->message_type] = $message;
                    }
                }
                if (!$launchable) {
                    continue;
                }
                $tool->name = $resource->resource_name->default_value;
                $tool->messages = $messages;
                $tools[] = $tool;
            }
            $ok = count($tools) > 0;
            if (!$ok) {
                debugging('No launchable messages found in tool proxy');
            }
        }

        // Add tools and custom parameters.
        if ($ok) {
            $baseurl = '';
            if (isset($toolproxyjson->tool_profile->base_url_choice[0]->default_base_url)) {
                $baseurl = $toolproxyjson->tool_profile->base_url_choice[0]->default_base_url;
            }
            $securebaseurl = '';
            if (isset($toolproxyjson->tool_profile->base_url_choice[0]->secure_base_url)) {
                $securebaseurl = $toolproxyjson->tool_profile->base_url_choice[0]->secure_base_url;
            }
            foreach ($tools as $tool) {
                $messages = $tool->messages;
                $launchrequest = $messages['basic-lti-launch-request'];
                $config = new \stdClass();
                $config->lti_toolurl = "{$baseurl}{$launchrequest->path}";
                $config->lti_typename = $tool->name;
                $config->lti_coursevisible = 1;
                $config->lti_forcessl = 0;
                if (isset($messages['ContentItemSelectionRequest'])) {
                    $contentitemrequest = $messages['ContentItemSelectionRequest'];
                    $config->lti_contentitem = 1;
                    if ($launchrequest->path !== $contentitemrequest->path) {
                        $config->lti_toolurl_ContentItemSelectionRequest = $baseurl . $contentitemrequest->path;
                    }
                    $contentitemcapabilities = implode("\n", $contentitemrequest->enabled_capability);
                    $config->lti_enabledcapability_ContentItemSelectionRequest = $contentitemcapabilities;
                    $contentitemparams = self::lti_extract_parameters($contentitemrequest->parameter);
                    $config->lti_parameter_ContentItemSelectionRequest = $contentitemparams;
                }

                $type = new \stdClass();
                $type->state = LTI_TOOL_STATE_PENDING;
                $type->toolproxyid = $toolproxy->id;
                $type->enabledcapability = implode("\n", $launchrequest->enabled_capability);
                $type->parameter = self::lti_extract_parameters($launchrequest->parameter);

                if (!empty($tool->iconpath)) {
                    $type->icon = "{$baseurl}{$tool->iconpath}";
                    if (!empty($securebaseurl)) {
                        $type->secureicon = "{$securebaseurl}{$tool->iconpath}";
                    }
                }

                $ok = $ok && (lti_add_type($type, $config) !== false);
            }
            if (isset($toolproxyjson->custom)) {
                lti_set_tool_settings($toolproxyjson->custom, $toolproxy->id);
            }
        }

        if (!empty($toolproxy)) {
            if ($ok) {
                // If all went OK accept the tool proxy.
                $toolproxy->state = LTI_TOOL_PROXY_STATE_ACCEPTED;
                $toolproxy->toolproxy = $response->get_request_data();
                $toolproxy->secret = $toolproxyjson->security_contract->shared_secret;
                $toolproxy->vendorcode = $toolproxyjson->tool_profile->product_instance->product_info->product_family->vendor->code;

                $url = $this->get_endpoint();
                $body = <<< EOD
{
  "@context" : "http://purl.imsglobal.org/ctx/lti/v2/ToolProxyId",
  "@type" : "ToolProxy",
  "@id" : "{$url}",
  "tool_proxy_guid" : "{$toolproxy->guid}"
}
EOD;
                $response->set_code(201);
                $response->set_content_type('application/vnd.ims.lti.v2.toolproxy.id+json');
                $response->set_body($body);
            } else {
                // Otherwise reject the tool proxy.
                $toolproxy->state = LTI_TOOL_PROXY_STATE_REJECTED;
                $response->set_code(400);
            }
            lti_update_tool_proxy($toolproxy);
        } else {
            $response->set_code(400);
        }
    }
1342986
public function setResponse($response)
    {
        $allowed_values = array('accepted', 'declined', 'tentative');
        if ((!in_array($response, $allowed_values))) {
            throw new \InvalidArgumentException("Invalid value for 'response', must be one of 'accepted', 'declined', 'tentative'");
        }
        $this->container['response'] = $response;

        return $this;
    }
843939
public function format($response)
    {
        if (stripos($this->contentType, 'charset') === false) {
            $this->contentType .= '; charset=' . $response->encoding;
        }
        $response->setHeader('Content-Type', $this->contentType);
        if ($response->data !== null) {
            $response->content = $response->data;
        }
    }
200697
private function parseDiscoveryResponse($response)
    {
        $body = json_decode($response->getBody(), true);

        $this->authorization_endpoint = $body['authorization_endpoint'];
        $this->token_endpoint = $body['token_endpoint'];
        $this->end_session_endpoint = $body['end_session_endpoint'];
        $this->userinfo_endpoint = $body['userinfo_endpoint'];
        $this->jwks_uri = $body['jwks_uri'];

        $this->scopes_supported = $body['scopes_supported'];
    }
916281
public function prepareForResponse(\n2n\web\http\Response $response) {
		$response->setStatus($this->statusCode);
		foreach ($this->headers as $header) {
			$response->setHeader($header);
		}

		$response->setHttpCacheControl($this->httpCacheControl);

	}
223342
protected function populate(stdClass $response)
    {
        $balances = clone $this;
        $balances->data->unavailable = $this->getIfSet('unavailable', $response) ?: [];
        $balances->data->future = $this->getIfSet('future', $response) ?: [];
        $balances->data->current = $this->getIfSet('current', $response) ?: [];

        return $balances;
    }
300937
public function prepareForResponse(Response $response) {
		$response->setStatus($this->httpStatus);
		$response->setHeader('Content-Type: text/html; charset=' . N2N::CHARSET);
		$response->setHeader('Location: ' . $this->httpLocation);
	}
1266033
protected function populate(stdClass $response)
    {
        $keys = clone $this;

        $resp = $response->keys;
        $keys->data->basicAuth = $this->getIfSet('basicAuth', $resp);
        $keys->data->encryption = $this->getIfSet('encryption', $resp);

        return $keys;
    }