<?php

use Psr\Container\ContainerInterface;

return [
    Incoviba\Service\Login::class => function(ContainerInterface $container) {
        return new Incoviba\Service\Login(
            $container->get(Incoviba\Repository\Login::class),
            $container->get('COOKIE_NAME'),
            $container->get('MAX_LOGIN_HOURS'),
            $container->has('COOKIE_DOMAIN') ? $container->get('COOKIE_DOMAIN') : '',
            $container->has('COOKIE_PATH') ? $container->get('COOKIE_PATH') : ''
        );
    },
    Incoviba\Service\Money::class => function(ContainerInterface $container) {
        $mindicador = new Incoviba\Service\Money\MiIndicador(new GuzzleHttp\Client([
            'base_uri' => 'https://mindicador.cl/api/',
            'headers' => ['Accept' => 'application/json']
        ]));
        $ine = new Incoviba\Service\Money\Ine(new GuzzleHttp\Client([
            'base_uri' => 'https://api-calculadora.ine.cl/ServiciosCalculadoraVariacion'
        ]));
        return (new Incoviba\Service\Money($container->get(Psr\Log\LoggerInterface::class)))
            ->register('uf', $mindicador)
            ->register('usd', $mindicador)
            ->register('ipc', $ine);
    },
    Predis\Client::class => function(ContainerInterface $container) {
        return new Predis\Client([
            'scheme' => 'tcp',
            'host' => $container->get('REDIS_HOST'),
            'port' => $container->get('REDIS_PORT')
        ]);
    },
    Incoviba\Service\Cartola::class => function(ContainerInterface $container) {
        return (new Incoviba\Service\Cartola(
            $container->get(Psr\Log\LoggerInterface::class),
            $container->get(Psr\Http\Message\StreamFactoryInterface::class),
            $container->get(Incoviba\Common\Define\Contabilidad\Exporter::class),
            $container->get(Incoviba\Repository\Inmobiliaria::class),
            $container->get(Incoviba\Repository\Inmobiliaria\Cuenta::class),
            $container->get(Incoviba\Repository\Movimiento::class),
            $container->get(Incoviba\Service\Movimiento::class),
            $container->get(Incoviba\Repository\Cartola::class)
        ))
            ->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
            ->register('itau', $container->get(Incoviba\Service\Cartola\Itau::class))
            ->register('santander', $container->get(Incoviba\Service\Cartola\Santander::class));
    },
    Incoviba\Common\Define\Contabilidad\Exporter::class => function(ContainerInterface $container) {
        return $container->get(Incoviba\Service\Contabilidad\Exporter\Nubox::class);
    },
    Incoviba\Service\Contabilidad\Exporter\Nubox::class => function(ContainerInterface $container) {
        return new Incoviba\Service\Contabilidad\Exporter\Nubox($container->get(Incoviba\Repository\CentroCosto::class),
            $container->get('folders')->get('uploads'));
    },
    Incoviba\Service\Contabilidad\Nubox::class => function(ContainerInterface $container) {
        return new Incoviba\Service\Contabilidad\Nubox(
            $container->get(Psr\Log\LoggerInterface::class),
            $container->get(Incoviba\Repository\Nubox::class),
            $container->get(Incoviba\Service\Redis::class),
            new GuzzleHttp\Client(),
            $container->get(Psr\Http\Message\RequestFactoryInterface::class),
            $container->get('nubox')->get('url'));
    },
    Incoviba\Service\Informe::class => function(ContainerInterface $container) {
        return (new Incoviba\Service\Informe(
            $container->get(Psr\Log\LoggerInterface::class),
            $container->get('folders')->get('informes'))
        )
            ->register('xlsx', Incoviba\Service\Informe\Excel::class);
    },
    Incoviba\Service\Contabilidad\Informe\Tesoreria\Excel::class => function(ContainerInterface $container) {
        return new Incoviba\Service\Contabilidad\Informe\Tesoreria\Excel(
            $container->get(Psr\Log\LoggerInterface::class),
            $container->get('folders')->get('informes'),
            $container->get(Incoviba\Service\UF::class),
            $container->get(Incoviba\Service\USD::class)
        );
    }
];
