<?php
defined('BASEPATH') or exit('No direct script access allowed');

class SyncService
{
    public function updateSyncStatus($docId, $fieldName, $value)
    {
        $payload = [
            'collection' => 'LawFirm',
            'docId' => $docId,
            'data' => [
                $fieldName => $value
            ]
        ];

        $ch = curl_init('https://us-central1-freeme-6e63a.cloudfunctions.net/widgetsforusa/documents/update');
        curl_setopt_array($ch, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST => true,
            CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
            CURLOPT_POSTFIELDS => json_encode($payload)
        ]);

        $response = curl_exec($ch);
        $error    = curl_error($ch);

        curl_close($ch);

        return $error ? $error : $response;
    }
}
