function makeRequest($method, $url, $apiRequest = null, $queryString = null)
	{
		$urlEndPoint = $this->config->getEndpoint() . '/' . $url;

		//we want to see the url being called
		$this->climate->out($this->config->getLoggerPrefix() . 'URL: ' . $urlEndPoint);

		$data = [
			'headers' => [
				'Authorization' => 'Bearer ' . $this->config->getAccessToken(),
			],
			'json'    => $apiRequest,
			'query'   => $queryString,
		];


		try
		{
			switch ($method)
			{
				case 'post':
					$response = $this->guzzle->post($urlEndPoint, $data);
					break;
				case 'put':
					$response = $this->guzzle->put($urlEndPoint, $data);
					break;
				case 'delete':
					$response = $this->guzzle->delete($urlEndPoint, $data);
					break;
				case 'get':
					$response = $this->guzzle->get($urlEndPoint, $data);
					break;
				default:
					throw new \Exception($this->config->getLoggerPrefix() . 'Missing request method!');

			}

			$this->climate->info($this->config->getLoggerPrefix() . 'Request successful.');

			if (in_array(current($response->getHeader('Content-Type')), ['image/png', 'image/jpg']))
			{
				$result = $response->getBody()->getContents();
			}
			else
			{
				$result = json_decode($response->getBody());
				if (is_null($result))
				{
					// may not be json, return as string
					$result = (string) $response->getBody();
				}
			}

			return $result;

		}
		catch (ConnectException $c)
		{
			$this->climate->error($this->config->getLoggerPrefix() . 'Error connecting to endpoint: ' . $c->getMessage());
			throw $c;
		}
		catch (RequestException $e)
		{
			$this->climate->error($this->config->getLoggerPrefix() . 'Request failed with status code ' . $e->getResponse()->getStatusCode());
			$this->printError($e);
			throw $e;
		}
	}
function makeRequest($method, $url, $apiRequest = null, $queryString = null)
	{
		$urlEndPoint = $this->config->getEndpoint() . '/' . $url;

		//we want to see the url being called
		$this->climate->out($this->config->getLoggerPrefix() . 'URL: ' . $urlEndPoint);

		$data = [
			'headers' => [
				'Authorization' => 'Bearer ' . $this->config->getAccessToken(),
			],
			'json'    => $apiRequest,
			'query'   => $queryString,
		];


		try
		{
			switch ($method)
			{
				case 'post':
					$response = $this->guzzle->post($urlEndPoint, $data);
					break;
				case 'put':
					$response = $this->guzzle->put($urlEndPoint, $data);
					break;
				case 'delete':
					$response = $this->guzzle->delete($urlEndPoint, $data);
					break;
				case 'get':
					$response = $this->guzzle->get($urlEndPoint, $data);
					break;
				default:
					throw new \Exception($this->config->getLoggerPrefix() . 'Missing request method!');

			}

			$this->climate->info($this->config->getLoggerPrefix() . 'Request successful.');

			if (in_array(current($response->getHeader('Content-Type')), ['image/png', 'image/jpg']))
			{
				$result = $response->getBody()->getContents();
			}
			else
			{
				$result = json_decode($response->getBody());
				if (is_null($result))
				{
					// may not be json, return as string
					$result = (string) $response->getBody();
				}
			}

			return $result;

		}
		catch (ConnectException $c)
		{
			$this->climate->error($this->config->getLoggerPrefix() . 'Error connecting to endpoint: ' . $c->getMessage());
			throw $c;
		}
		catch (RequestException $e)
		{
			$this->climate->error($this->config->getLoggerPrefix() . 'Request failed with status code ' . $e->getResponse()->getStatusCode());
			$this->printError($e);
			throw $e;
		}
	}
function makeRequest ( $ method , $ url , $ apiRequest = null , $ queryString = null ) { $ urlEndPoint = $ this -> config -> getEndpoint ( ) . '/' . $ url ; //we want to see the url being called $ this -> climate -> out ( $ this -> config -> getLoggerPrefix ( ) . 'URL: ' . $ urlEndPoint ) ; $ data = [ 'headers' => [ 'Authorization' => 'Bearer ' . $ this -> config -> getAccessToken ( ) , ] , 'json' => $ apiRequest , 'query' => $ queryString , ] ; try { switch ( $ method ) { case 'post' : $ response = $ this -> guzzle -> post ( $ urlEndPoint , $ data ) ; break ; case 'put' : $ response = $ this -> guzzle -> put ( $ urlEndPoint , $ data ) ; break ; case 'delete' : $ response = $ this -> guzzle -> delete ( $ urlEndPoint , $ data ) ; break ; case 'get' : $ response = $ this -> guzzle -> get ( $ urlEndPoint , $ data ) ; break ; default : throw new \ Exception ( $ this -> config -> getLoggerPrefix ( ) . 'Missing request method!' ) ; } $ this -> climate -> info ( $ this -> config -> getLoggerPrefix ( ) . 'Request successful.' ) ; if ( in_array ( current ( $ response -> getHeader ( 'Content-Type' ) ) , [ 'image/png' , 'image/jpg' ] ) ) { $ result = $ response -> getBody ( ) -> getContents ( ) ; } else { $ result = json_decode ( $ response -> getBody ( ) ) ; if ( is_null ( $ result ) ) { // may not be json, return as string $ result = ( string ) $ response -> getBody ( ) ; } } return $ result ; } catch ( ConnectException $ c ) { $ this -> climate -> error ( $ this -> config -> getLoggerPrefix ( ) . 'Error connecting to endpoint: ' . $ c -> getMessage ( ) ) ; throw $ c ; } catch ( RequestException $ e ) { $ this -> climate -> error ( $ this -> config -> getLoggerPrefix ( ) . 'Request failed with status code ' . $ e -> getResponse ( ) -> getStatusCode ( ) ) ; $ this -> printError ( $ e ) ; throw $ e ; } }
Make a request to the API using Guzzle

@param      $method      string The HTTP VERB to use for this request
@param      $url         string The relative URL after the hostname
@param null $apiRequest  array The contents of the api body
@param null $queryString array Data to add as a queryString to the url

@return mixed
@throws UnauthorizedMerchantException
@throws \Exception
Make a request to the API using Guzzle