<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Channel order (fallback policy)
    |--------------------------------------------------------------------------
    | Channels are tried in order until one succeeds. "whatsapp,sms" means try
    | WhatsApp first and fall back to SMS. Use "log" in dev — it writes to the
    | Laravel log and never calls a real provider.
    */
    'channels' => env('NOTIFY_CHANNELS', 'log'),

    /*
    | Queue connection for non-urgent (order/delivery) notifications.
    | 'sync' runs them inline (works with no worker — good for dev/MVP).
    | Set NOTIFY_QUEUE=database (and run `php artisan queue:work`) for true async.
    | OTPs always send synchronously regardless of this.
    */
    'queue' => env('NOTIFY_QUEUE', 'sync'),

    /*
    | How phone numbers are formatted before sending.
    | as_is | local (03XXXXXXXXX) | pk (923XXXXXXXX) | e164 (+923XXXXXXXX)
    */
    'number_format' => env('NOTIFY_NUMBER_FORMAT', 'as_is'),

    'drivers' => [

        'log' => [
            'class' => \App\Notifications\Channels\LogDriver::class,
        ],

        /*
        | Firebase Cloud Messaging push. Fill the server key once the Firebase
        | project exists (admin Settings → Notifications, or FCM_SERVER_KEY).
        | Until then isConfigured() is false and push is skipped.
        */
        'push' => [
            'class' => \App\Notifications\Channels\FcmPushDriver::class,
            'url'   => env('FCM_URL', 'https://fcm.googleapis.com/fcm/send'),
            'key'   => env('FCM_SERVER_KEY'),
        ],

        /*
        | Generic HTTP SMS gateway — fits most Pakistani aggregators
        | (Veevo Tech, Branded SMS Pakistan, BizSMS, Roundsms, …).
        | Set the URL/key and map your provider's parameter names below.
        */
        'sms' => [
            'class'   => \App\Notifications\Channels\HttpSmsDriver::class,
            'url'     => env('SMS_API_URL'),
            'method'  => env('SMS_API_METHOD', 'GET'),
            'api_key' => env('SMS_API_KEY'),
            'sender'  => env('SMS_SENDER_MASK', 'Malakand'),
            'headers' => [],
            // Map provider param names. Placeholders: {to} {message} {sender} {key}
            'params'  => [
                'to'      => env('SMS_PARAM_TO', '{to}'),
                'message' => env('SMS_PARAM_MESSAGE', '{message}'),
                'sender'  => env('SMS_PARAM_SENDER', '{sender}'),
                'api_key' => env('SMS_PARAM_KEY', '{key}'),
            ],
            'extra'            => [], // static extra params, e.g. ['type' => 'text']
            'success_contains' => env('SMS_SUCCESS_CONTAINS'), // optional substring marking success
            'timeout'          => 15,
        ],

        /*
        | Generic WhatsApp gateway.
        |  format=meta    -> official WhatsApp Cloud API (graph.facebook.com)
        |  format=generic -> a BSP/aggregator's simple HTTP endpoint
        | WhatsApp business-initiated messages require pre-approved templates.
        */
        'whatsapp' => [
            'class'   => \App\Notifications\Channels\HttpWhatsAppDriver::class,
            'format'  => env('WHATSAPP_FORMAT', 'meta'),
            'url'     => env('WHATSAPP_API_URL'),   // meta: https://graph.facebook.com/v21.0/<PHONE_NUMBER_ID>/messages
            'api_key' => env('WHATSAPP_API_KEY'),   // meta: permanent access token
            'sender'  => env('WHATSAPP_SENDER'),    // generic: sender id, if the BSP needs it
            'headers' => [],
            // generic-mode param names. Placeholders: {to} {template} {lang} {params} {message} {key}
            'params'  => [
                'to'       => env('WA_PARAM_TO', '{to}'),
                'template' => env('WA_PARAM_TEMPLATE', '{template}'),
                'params'   => env('WA_PARAM_PARAMS', '{params}'),
            ],
            'extra'   => [],
            'timeout' => 15,
        ],
    ],
];
