<?php
/**
 * HttpService Configuration
 *
 * @version     1.0.$Revision:$
 * @version     SVN: $Id:$
 * @package     bplan-base/globals
 * @subpackage  Config
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025, 2026 bplan-solutions GmbH & Co. KG <https://www.bplan-solutions.de/>
 * /Δ\
 */


$defaults = [
    /*
    **  Defaults for all profiles. */
    'auth' => [
        'type' => env('HTTP_SERVICE_AUTH_TYPE', 'bearer'),
    ],
    'connect-timeout' => env('HTTP_SERVICE_CONNECT_TIMEOUT', 5),
    'headers' => [
        'accept' => env('HTTP_SERVICE_HEADERS_ACCEPT', 'application/json'),
        // 'content-type' => env('HTTP_SERVICE_HEADERS_CONTENT_TYPE', 'application/json'), // optionale Angabe, "accept" wird verwendet, wenn nicht angegeben
    ],
    'log' => [
        'incoming-request' => env('HTTP_SERVICE_LOG_INCOMING', false),
        'level'            => env('HTTP_SERVICE_LOG_LEVEL', 0),
        'map'              => [
            'Authorization',
            'password',
            'token',
        ],
    ],
    'retry' => [
        'sleep' => env('HTTP_SERVICE_RETRY_SLEEP', 500), // initiale Wartezeit in ms, verdoppelt sich mit jedem Versuch (500 → 1000 → 2000)
        'times' => env('HTTP_SERVICE_RETRY_TIMES', 3),   // initialer Versuch + 2 Wiederholungen
    ],
    'timeout' => env('HTTP_SERVICE_TIMEOUT', 10),
    'verify'  => env('HTTP_SERVICE_VERIFY', true),
];

return [
    'defaults' => $defaults,
    'profiles' => [
        'default' => [
            'auth' => [
                'token' => env('HTTP_SERVICE_PROFILE_DEFAULT_AUTH_TOKEN', null),
                'type'  => env('HTTP_SERVICE_PROFILE_DEFAULT_AUTH_TYPE', $defaults['auth']['type']),
            ],
            'base-url' => env('HTTP_SERVICE_PROFILE_DEFAULT_BASE_URL', null),
            'headers'  => $defaults['headers'],
            'log' => [
                'incoming-request' => env('HTTP_SERVICE_PROFILE_DEFAULT_LOG_INCOMING', $defaults['log']['incoming-request']),
                'level'            => env('HTTP_SERVICE_PROFILE_DEFAULT_LOG_LEVEL', $defaults['log']['level']),
                'map'              => $defaults['log']['map'],
            ],
            'retry' => [
                'sleep' => env('HTTP_SERVICE_PROFILE_DEFAULT_RETRY_SLEEP', $defaults['retry']['sleep']),
                'times' => env('HTTP_SERVICE_PROFILE_DEFAULT_RETRY_TIMES', $defaults['retry']['times']),
            ],
            'timeout' => env('HTTP_SERVICE_PROFILE_DEFAULT_TIMEOUT', $defaults['timeout']),
            'verify'  => env('HTTP_SERVICE_PROFILE_DEFAULT_VERIFY', $defaults['verify']),
        ],
        // add additional profiles
    ],

];
