���� ������������������������������������ apiKey = config('services.foreign_api.api_key'); } public function getClientPointUser($email) { $response = Http::withoutVerifying()->get('https://api.clientpoint.net/v5/users', [ 'api_key' => $this->apiKey, ]); if (!$response->successful()) { return false; } $users = $response->json()['data']['users']; foreach ($users as $user) { if ($user['email'] === $email) { return true; } } return false; } public function getClientPointUserName($email) { $response = Http::withoutVerifying()->get('https://api.clientpoint.net/v5/users', [ 'api_key' => $this->apiKey, ]); if (!$response->successful()) { return false; } $users = $response->json()['data']['users']; foreach ($users as $user) { if ($user['email'] === $email) { return $user['name']; } } return ''; } public function getCurl($url) { $response = Http::get($url); return $response->json(); } public function sendEmail($data) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://solutions.clientpoint.net/email-service/SendGrid/souciehorner.php', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $data, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, )); $response = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($response === false) { $error = curl_error($curl); curl_close($curl); \Log::error('Email sending failed - cURL error: ' . $error); return false; } curl_close($curl); // Log the response for debugging \Log::info('Email API Response: ' . $response . ' | HTTP Code: ' . $httpCode); return $response; } public function executeCurl($url, $method, $data = null){ $curlOptions = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, // Increase the timeout if needed CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => $method, ); if($data!=null){ $curlOptions[CURLOPT_POSTFIELDS] = json_encode($data); $curlOptions[CURLOPT_HTTPHEADER][] = 'Content-Type: application/json'; } $curl = curl_init(); curl_setopt_array($curl, $curlOptions); $response = curl_exec($curl); if ($response === false) { $errorDetails = 'cURL error: ' . curl_error($curl); throw new Exception($errorDetails); } curl_close($curl); return $response; } // Other methods for PUT, DELETE, etc. }