<?php

namespace App\Services\Graph;

class NullGraphClient implements GraphClientInterface
{
    public function listPolicies(string $policyType, array $options = []): GraphResponse
    {
        return new GraphResponse(
            success: true,
            data: [],
            warnings: ['Graph client not configured; returning empty policy list']
        );
    }

    public function getPolicy(string $policyType, string $policyId, array $options = []): GraphResponse
    {
        return new GraphResponse(
            success: true,
            data: [
                'payload' => [
                    'id' => $policyId,
                    'type' => $policyType,
                    'source' => 'null-graph',
                ],
                'warnings' => ['Graph client not configured; using stub payload'],
            ],
            warnings: ['Graph client not configured; using stub payload'],
        );
    }

    public function getOrganization(array $options = []): GraphResponse
    {
        return new GraphResponse(
            success: true,
            data: ['id' => $options['tenant'] ?? 'unset'],
            warnings: ['Graph client not configured; returning stub organization']
        );
    }

    public function applyPolicy(string $policyType, string $policyId, array $payload, array $options = []): GraphResponse
    {
        return new GraphResponse(
            success: true,
            data: ['status' => 'skipped', 'source' => 'null-graph'],
            warnings: ['Graph client not configured; apply operation skipped']
        );
    }

    public function getServicePrincipalPermissions(array $options = []): GraphResponse
    {
        // Return stub permissions from config
        $grantedStub = config('intune_permissions.granted_stub', []);

        return new GraphResponse(
            success: true,
            data: ['permissions' => $grantedStub],
            warnings: ['Graph client not configured; using stub permissions from config']
        );
    }

    public function request(string $method, string $path, array $options = []): GraphResponse
    {
        return new GraphResponse(
            success: true,
            data: [
                'method' => strtoupper($method),
                'path' => $path,
                'options' => $options,
            ],
            warnings: ['Graph client not configured; returning stub response'],
        );
    }
}
