<?php

namespace AuthStack\UserDirectory\Provider;

use AuthStack\UserDirectory\AUD;
use Illuminate\Support\ServiceProvider;

class AUDProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton('AUD', function($app)
        {
            $aud = new AUD(env('AUD_URL'), base64_encode(env('AUD_TOKEN')));

            if(request()->hasHeader('X-TimeZoneOffset') && request()->hasHeader('X-TimeZoneDST'))
            {
                $aud->setTimeZoneOffset((string)request()->header('X-TimeZoneOffset'));
                $aud->setTimeZoneDST((string)request()->header('X-TimeZoneDST'));
            }

            return $aud;
        });
    }
}