<?php declare(strict_types=1);

namespace Neusta\IntexClient\Connection\Model;


use Neusta\IntexClientConfig\Model\Config\Config;
use Neusta\IntexClientConfig\Provider\JsonConfigProvider;
use Psr\Log\LoggerInterface;

use function json_decode;

class CustomerConnection extends Connection
{
    /**
     * @var Config
     */
    private $customerConfig;

    public function __construct(JsonConfigProvider $configProvider, LoggerInterface $logger)
    {
        parent::__construct($configProvider, $logger);
        $this->customerConfig = $configProvider->getConfig('customer');
    }

    public function loadCustomerData(): array
    {
        $response = $this->createGet(
            $this->customerConfig->getCustomerUri()
        );

        return json_decode($response->getBody(), true);
    }
}
