Returns an array of fields we want from Stripe's response objects


@param object $response A successful response object from this component.
@return array The desired fields from the response object as an array.
332829
protected function _formatResult($response) {
		$result = array();
		foreach ($this->fields as $local => $stripe) {
			if (is_array($stripe)) {
				foreach ($stripe as $obj => $field) {
					if (isset($response->$obj->$field)) {
						$result[$local] = $response->$obj->$field;
					}
				}
			} else {
				if (isset($response->$stripe)) {
					$result[$local] = $response->$stripe;
				}
			}
		}
		// if no local fields match, return the default stripe_id
		if (empty($result)) {
			$result['stripe_id'] = $response->id;
		}
		return $result;
	}
1248642
public function getUserFromTokenResponse($response)
    {
        $user = $this->mapUserToObject($this->getUserByToken(
            $token = $this->parseAccessToken($response)
        ));

        $this->credentialsResponseBody = $response;

        if ($user instanceof User) {
            $user->setAccessTokenResponseBody($this->credentialsResponseBody);
        }

        return $user->setToken($token)
            ->setRefreshToken($this->parseRefreshToken($response))
            ->setExpiresIn($this->parseExpiresIn($response));
    }
880174
private static function getHeaderAndBody($response) {
    $header = self::http_parse_headers(substr($response, 0, strrpos($response,"\r\n\r\n")));
    $body = substr($response, strrpos($response,"\r\n\r\n")+4);

    return array($header,$body);
  }
919727
protected function getResultFromResponse(Response $response)
    {
        $result = [];

        foreach ($response->getData() as $element) {
            $attributes = $this->getAttributes($element);
            $attributes['type'] = $element['type'];

            $result[] = $attributes;
        }

        return $result;
    }
877000
private function buildResults(Response $response): array
    {
        $data = $response->getData();
        $results = [];

        if (!isset($data['hits']['hits'])) {
            return $results;
        }

        foreach ($data['hits']['hits'] as $hit) {
            $results[] = new Result($hit);
        }

        return $results;
    }
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;
    }
1195612
protected function prepareResponse($response)
    {
        $header_size = curl_getinfo($this->request, CURLINFO_HEADER_SIZE);
        $headers = substr($response, 0, $header_size);
        $body = substr($response, $header_size);

        return [$headers, $body];
    }
478198
protected function respond($response)
    {
        if ($response === null) {
            return $this->mapResponse(true, []);
        }

        if (!empty($response) && !isset($response[0])) {
            $success = null === Arr::get($response, 'error_code');

            return $this->mapResponse($success, $response);
        }

        $responses = [];

        foreach ($response as $responseItem) {
            $success = null === Arr::get($responseItem, 'error_code');

            $responses[] = $this->mapResponse($success, $responseItem);
        }

        return $responses;
    }
900934
public function format($response)
    {
        $this->isNew = false;
        $responseObject = new Response();
        $responseObject->setRawResponse($response);

        if ($responseObject->containsResults()) {
            $this->extractResults($response);
            $this->prepareResultSet();
            $this->prepareNodesByLabels();
            $this->prepareRelationshipsByType();
            $this->processIdentification($response);
        }

        if ($responseObject->containsRows()) {
            $rows = $this->formatRows($response);
            $responseObject->setRows($rows);

            if ($responseObject->containsResults()) {
                foreach ($responseObject->geRows() as $k => $v) {
                    if (!$this->result->hasIdentifier($k)) {
                        $this->result->addIdentifierValue($k, $v);
                    }
                }
            }
        }

        if (is_array($responseObject->geRows())) {
            $this->processTableFormat($responseObject->geRows());
        }
        $responseObject->setResult($this->result);

        $this->reset();

        return $responseObject;
    }
1027765
public function getCustomFields($object)
    {
        $customFields = [];
        foreach ($object->getCustomFields() as $field) {
            $customFields[$field->getInternalFieldName()] = $field->getValue();
        }

        return $customFields;
    }
96668
protected function parse_result( $response ) {
		if ( is_wp_error( $response ) ) {
			return (object) [
				'success' => false,
				'version' => false,
				'error'   => $response->get_error_code(),
				'message' => $response->get_error_message(),
			];
		} else {
			$result = json_decode( $response );
			if ( is_null( $result ) ) {
				return (object) [
					'success' => false,
					'version' => false,
					'error'   => '500',
					'message' => 'Parser Error',
				];
			} else {
				return $result;
			}
		}
	}
806212
protected function getAuthorization($response)
    {
        $method = Arr::get($response, 'method');

        if ('card' == $method) {
            return Arr::get($response, 'authorization');
        }

        if ('bank_account' == $method) {
            $payment = Arr::get($response, 'payment_method', []);

            return Arr::get($payment, 'clabe');
        }

        if ('store' == $method) {
            $payment = Arr::get($response, 'payment_method', []);

            return Arr::get($payment, 'barcode_url');
        }
    }
283856
public function map(array $response, ResultObjectInterface $result)
    {
        foreach ($response as $field => $value) {
            $method = $this->getSetterName($field);

            if (!method_exists($result, $method)) {
                continue;
            }

            if ($field == 'payment_instrument') {
                $value = $this->transformPaymentInstrumentValue($value, $response['payment_method']);
            } elseif ($field == 'authorization_information') {
                $value = $this->transformAuthorizationInformationValue($value);
            }

            $result->$method($value);
        }

        return $result;
    }
226590
protected function decode($response)
    {
        $lines = array_slice(explode("\n", trim($response)), 1);

        $result = [];
        foreach ($lines as $line) {
            if ($line[0] == '-') {
                $result[] = trim(ltrim($line, '- '));
            } else {
                $key = strtok($line, ': ');
                if ($key) {
                    $value = ltrim(trim(strtok('')), ' ');

                    if (is_numeric($value)) {
                        $value = $value + 0;
                    }

                    $result[$key] = $value;
                }
            }
        }

        return $result;
    }
912337
protected function _withCustomHeaders($response)
    {
        foreach ((array)$this->getConfig('headers') as $key => $value) {
            $response = $response->withHeader($key, $value);
        }

        return $response;
    }
808342
protected function getBatchResponses(ResponseInterface $response)
    {
        $results = JsonRpc\json_decode((string) $response->getBody(), true);

        return array_map(function (array $result) use ($response) {
            return $this->messageFactory->createResponse(
                $response->getStatusCode(),
                $response->getHeaders(),
                $result
            );
        }, $results);
    }
1181502
public static function response($response)
    {
        $result = [];
        if (is_numeric($response)) {
            header('HTTP/1.1 '.$response);
            $result['status'] = $response;
            $result['status_message'] = self::toResponse($response);
            $result['data'] = [];
        } else {
            header('HTTP/1.1 '. 200);
            $result['status'] = 200;
            $result['status_message'] = 'Success';
            $result['data'] = self::superEncode($response);
        }

        $json_response = json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
        $json_response = str_replace('\\\\', '', $json_response);

        return $json_response;
    }