![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/braintree/braintree_php/lib/Braintree/ |
<?php namespace Braintree; use finfo; /** * Braintree GraphQL service * process GraphQL requests using curl */ class GraphQL extends Http { // phpcs:ignore PEAR.Commenting.FunctionComment.Missing public function __construct($config) { parent::__construct($config); } /** * Sets headers for requests via GraphQL * * @return array request headers */ public function graphQLHeaders() { return [ 'Accept: application/json', 'Braintree-Version: ' . Configuration::GRAPHQL_API_VERSION, 'Content-Type: application/json', 'User-Agent: Braintree PHP Library ' . Version::get(), 'X-ApiVersion: ' . Configuration::API_VERSION ]; } /** * Makes the API request to GraphQL API * * @param mixed $definition containing GraphQL query * @param mixed $variables optional, any variables to be included in GraphQL request * * @return object result */ public function request($definition, $variables = null) { $graphQLRequest = ["query" => $definition]; if ($variables) { $graphQLRequest["variables"] = $variables; } // phpcs:ignore Generic.Files.LineLength $response = $this->_doUrlRequest('POST', $this->_config->graphQLBaseUrl(), json_encode($graphQLRequest), null, $this->graphQLHeaders()); $result = json_decode($response["body"], true); Util::throwGraphQLResponseException($result); return $result; } }