title: Argument 1 passed to __construct() must be an instance of GuzzleHttp\Client
body: <p>I'm trying to "use" a vendor script to connect to feefo api (an online reviews service) but when I try and use the script it gives me this error:</p>
  
  <pre><code>Type error: Argument 1 passed to 
  BlueBayTravel\Feefo\Feefo::__construct() must be an instance of 
  GuzzleHttp\Client, null given, called in/Users/webuser1/Projects/_websites/domain.co.uk/plugins/gavinfoster/feefo/components/Feedback.php on line 47
  </code></pre>
  
  <p>Here is the vendor code I'm using:</p>
  
  <p>
  
  <pre><code>/*
   * This file is part of Feefo.
   *
   * (c) Blue Bay Travel &lt;developers@bluebaytravel.co.uk&gt;
   *
   * For the full copyright and license information, please view the LICENSE
   * file that was distributed with this source code.
   */
  
  namespace BlueBayTravel\Feefo;
  
  use ArrayAccess;
  use Countable;
  use Exception;
  use GuzzleHttp\Client;
  use Illuminate\Contracts\Config\Repository;
  use Illuminate\Contracts\Support\Arrayable;
  use SimpleXMLElement;
  
  /**
   * This is the feefo class.
   *
   * @author James Brooks &lt;james@bluebaytravel.co.uk&gt;
   */
  class Feefo implements Arrayable, ArrayAccess, Countable
  {
      /**
       * The guzzle client.
       *
       * @var \GuzzleHttp\Client
       */
      protected $client;
  
      /**
       * The config repository.
       *
       * @var \Illuminate\Contracts\Config\Repository
       */
      protected $config;
  
      /**
       * The review items.
       *
       * @var array
       */
      protected $data;
  
      /**
       * Create a new feefo instance.
       *
       * @param \GuzzleHttp\Client                      $client
       * @param \Illuminate\Contracts\Config\Repository $config
       *
       * @return void
       */
      public function __construct(Client $client, Repository $config)
      {
          $this-&gt;client = $client;
          $this-&gt;config = $config;
      }
  
      /**
       * Fetch feedback.
       *
       * @param array|null $params
       *
       * @return \BlueBayTravel\Feefo\Feefo
       */
      public function fetch($params = null)
      {
          if ($params === null) {
              $params['json'] = true;
              $params['mode'] = 'both';
          }
  
          $params['logon'] = $this-&gt;config-&gt;get('feefo.logon');
          $params['password'] = $this-&gt;config-&gt;get('feefo.password');
  
          try {
              $body = $this-&gt;client-&gt;get($this-&gt;getRequestUrl($params));
  
              return $this-&gt;parse((string) $body-&gt;getBody());
          } catch (Exception $e) {
              throw $e; // Re-throw the exception
          }
      }
  
      /**
       * Parses the response.
       *
       * @param string $data
       *
       * @return \Illuminate\Support\Collection
       */
      protected function parse($data)
      {
          $xml = new SimpleXMLElement($data);
  
          foreach ((array) $xml as $items) {
              if (isset($items-&gt;TOTALRESPONSES)) {
                  continue;
              }
  
              foreach ($items as $item) {
                  $this-&gt;data[] = new FeefoItem((array) $item);
              }
          }
  
          return $this;
      }
  
      /**
       * Assigns a value to the specified offset.
       *
       * @param mixed $offset
       * @param mixed $value
       *
       * @return void
       */
      public function offsetSet($offset, $value)
      {
          if (is_null($offset)) {
              $this-&gt;data[] = $value;
          } else {
              $this-&gt;data[$offset] = $value;
          }
      }
  
      /**
       * Whether or not an offset exists.
       *
       * @param mixed $offset
       *
       * @return bool
       */
      public function offsetExists($offset)
      {
          return isset($this-&gt;data[$offset]);
      }
  
      /**
       * Unsets an offset.
       *
       * @param mixed $offset
       *
       * @return void
       */
      public function offsetUnset($offset)
      {
          if ($this-&gt;offsetExists($offset)) {
              unset($this-&gt;data[$offset]);
          }
      }
  
      /**
       * Returns the value at specified offset.
       *
       * @param mixed $offset
       *
       * @return mixed
       */
      public function offsetGet($offset)
      {
          return $this-&gt;offsetExists($offset) ? $this-&gt;data[$offset] : null;
      }
  
      /**
       * Count the number of items in the dataset.
       *
       * @return int
       */
      public function count()
      {
          return count($this-&gt;data);
      }
  
      /**
       * Get the instance as an array.
       *
       * @return array
       */
      public function toArray()
      {
          return $this-&gt;data;
      }
  
      /**
       * Returns the Feefo API endpoint.
       *
       * @param array $params
       *
       * @return string
       */
      protected function getRequestUrl(array $params)
      {
          $query = http_build_query($params);
  
          return sprintf('%s?%s', $this-&gt;config-&gt;get('feefo.baseuri'), $query);
      }
  }
  </code></pre>
  
  <p>And here is the code I'm using to try and use the fetch() method from the vendor class:</p>
  
  <p>
  
  <pre><code>use Cms\Classes\ComponentBase;
  use ArrayAccess;
  use Countable;
  use Exception;
  use GuzzleHttp\Client;
  use Illuminate\Contracts\Config\Repository;
  use Illuminate\Contracts\Support\Arrayable;
  use SimpleXMLElement;
  use BlueBayTravel\Feefo\Feefo;
  
  class Feedback extends ComponentBase
  {
  
      public $client;
  
      public $config;
  
      /**
       * Container used for display
       * @var BlueBayTravel\Feefo
       */
      public $feedback;
  
      public function componentDetails()
      {
          return [
              'name'        =&gt; 'Feedback Component',
              'description' =&gt; 'Adds Feefo feedback to the website'
          ];
      }
  
      public function defineProperties()
      {
          return [];
      }
  
      public function onRun()
      {
          $this-&gt;feedback = $this-&gt;page['feedback'] = $this-&gt;loadFeedback($this-&gt;client, $this-&gt;config);   
      }
  
      public function loadFeedback($client, $config)
      {
  
          $feefo = new Feefo($client, $config);
          $feedback = $feefo-&gt;fetch();
  
          return $feedback;
  
      }
  
  }
  </code></pre>
  
  <p>Won't allow me to call the Fetch() method statically so trying to instantiate and then use:</p>
  
  <pre><code>    public function loadFeedback($client, $config)
      {
  
          $feefo = new Feefo($client, $config);
          $feedback = $feefo-&gt;fetch();
  
          return $feedback;
  
      }
  </code></pre>
  
  <p>I've also tried type hinting the args like this:</p>
  
  <pre><code>    public function loadFeedback(Client $client, Repository $config)
      {
  
          $feefo = new Feefo($client, $config);
          $feedback = $feefo-&gt;fetch();
  
          return $feedback;
  
      }
  </code></pre>
  
  <p>But still I get the exception error above. I'm struggling to understand how to get past this. Any help for a newbie much appreciated :)</p>