<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class IntegrationSetting extends Model
{
    protected $fillable = [
        'business_id', 'provider', 'credentials', 'configuration', 'enabled',
        'last_synced_at', 'last_error',
        'health_status', 'last_health_checked_at', 'credentials_expires_at',
        'last_refreshed_at', 'refresh_error',
    ];

    protected function casts(): array
    {
        return [
            'credentials' => 'encrypted:array',
            'configuration' => 'array',
            'enabled' => 'boolean',
            'last_synced_at' => 'datetime',
            'last_health_checked_at' => 'datetime',
            'credentials_expires_at' => 'datetime',
            'last_refreshed_at' => 'datetime',
        ];
    }
}
