# GPlay Central AI — Laravel Integration Blueprint & SDK Guide Panduan integrasi resmi GPlay Central AI Engine untuk framework **Laravel 10 / 11**. --- ## 1. Konfigurasi Kredensial `.env` Tambahkan kredensial berikut pada file `.env` di aplikasi Laravel kamu: ```env GPLAY_AI_BASE_URL=http://localhost:5000/api/v1 GPLAY_AI_API_KEY=kunci_api_tenant_kamu ``` --- ## 2. Membuat Service Client (`app/Services/GPlayAiService.php`) Buat file baru `app/Services/GPlayAiService.php`: ```php baseUrl = config('services.gplay_ai.base_url', env('GPLAY_AI_BASE_URL')); $this->apiKey = config('services.gplay_ai.api_key', env('GPLAY_AI_API_KEY')); } /** * Ekstraksi Faktur / Invoice Otomatis */ public function extractInvoice(string $invoiceText): array { $response = Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/finance/extract-invoice", [ 'invoiceText' => $invoiceText, ]); return $response->json(); } /** * Audit Kepatuhan ISO / UU PDP */ public function analyzeCompliance(string $title, string $text, string $standard = 'ISO 27001'): array { $response = Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/compliance/analyze", [ 'documentTitle' => $title, 'documentText' => $text, 'standard' => $standard, ]); return $response->json(); } /** * AI Coding Assistant & Bug Auditor (v2.0) */ public function codeAssistant(string $code, string $language = 'php', string $task = 'audit_and_unit_test'): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/devops/code-assistant", [ 'sourceCode' => $code, 'language' => $language, 'task' => $task, ])->json(); } /** * IT Security & CyberDefense Threat Analyzer (v2.0) */ public function threatAnalyzer(string $targetEndpoint, string $trafficLog, string $attackVector = 'DDoS_AND_RANSOMWARE'): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/security/threat-analyzer", [ 'targetEndpoint' => $targetEndpoint, 'trafficLog' => $trafficLog, 'attackVector' => $attackVector, ])->json(); } /** * Predictive HR Turnover & Retention AI (v2.0) */ public function predictTurnover(string $empId, string $dept, int $tenureMonths, int $overtimeHours): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/hr/predict-turnover", [ 'employeeId' => $empId, 'department' => $dept, 'tenureMonths' => $tenureMonths, 'recentOvertimeHours' => $overtimeHours, ])->json(); } /** * Legal Contract Expiry & Dispute Litigation AI (v2.0) */ public function disputeAnalyzer(string $contractId, string $title, string $expiryDate): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/legal/dispute-analyzer", [ 'contractId' => $contractId, 'contractTitle' => $title, 'expiryDate' => $expiryDate, ])->json(); } /** * AI Content & Plagiarism Detector (Milestone 83) */ public function detectAiPlagiarism(string $text, float $sensitivity = 0.85): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/content/detect-ai-plagiarism", [ 'text' => $text, 'sensitivity' => $sensitivity, ])->json(); } /** * Web3 & Smart Contract Auditor (Milestone 84) */ public function auditSmartContract(string $sourceCode, string $language = 'solidity', array $checkRules = ['reentrancy', 'overflow', 'access_control']): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/web3/audit-smart-contract", [ 'sourceCode' => $sourceCode, 'language' => $language, 'checkRules' => $checkRules, ])->json(); } /** * Enterprise Workspace Slack/Teams AI Alerting (Milestone 85) */ public function sendSlackAlert(string $channel, string $eventTitle, string $alertLevel = 'critical', array $payload = []): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/workspace/slack-notifier", [ 'channel' => $channel, 'eventTitle' => $eventTitle, 'alertLevel' => $alertLevel, 'payload' => $payload, ])->json(); } /** * Real-Time API Usage Anomaly Detector (Milestone 91) */ public function detectApiAnomaly(string $apiKeyId, int $requestRatePerMin, string $endpointTarget = '/api/v1/data/query'): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/security/api-anomaly-detector", [ 'apiKeyId' => $apiKeyId, 'requestRatePerMin' => $requestRatePerMin, 'endpointTarget' => $endpointTarget, ])->json(); } /** * Real-Time Indirect Prompt Injection Shield (Milestone 104) */ public function shieldPromptInjection(string $prompt, array $contextDocuments = []): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/guardrails/prompt-injection-shield", [ 'prompt' => $prompt, 'contextDocuments' => $contextDocuments, ])->json(); } /** * Deep Document Forgery & Digital Stamp Authenticator (Milestone 114) */ public function checkInvoiceTamper(string $documentHash, string $eMeteraiSerial): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/finsec/invoice-tamper-check", [ 'documentHash' => $documentHash, 'eMeteraiSerial' => $eMeteraiSerial, ])->json(); } /** * AIDC Power Infrastructure & PUE/Thermal Optimizer (Milestone 115) */ public function optimizeAidcPower(float $itComputeLoadKw, float $coolingFacilityLoadKw, string $coolingMethod = 'DIRECT_LIQUID_COOLING', string $facilityName = 'Jakarta AIDC'): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/energy/aidc-power-optimizer", [ 'itComputeLoadKw' => $itComputeLoadKw, 'coolingFacilityLoadKw' => $coolingFacilityLoadKw, 'coolingMethod' => $coolingMethod, 'facilityName' => $facilityName, ])->json(); } /** * Grid-Scale BESS & Smart Micro-Grid EMS Controller (Milestone 116) */ public function manageBessMicrogrid(string $clusterId, float $currentSocPct, float $targetDischargeKw = 0.0, string $gridTariffMode = 'PEAK_HOUR'): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/energy/bess-microgrid-ems", [ 'clusterId' => $clusterId, 'currentSocPct' => $currentSocPct, 'targetDischargeKw' => $targetDischargeKw, 'gridTariffMode' => $gridTariffMode, ])->json(); } /** * Central Bank AI Hardware Supply Chain KB (Milestone 117) */ public function getHardwareSupplyChain(string $queryCategory = 'BESS_BATTERY_STORAGE', bool $includePatents = true): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/intel/hardware-supply-chain", [ 'queryCategory' => $queryCategory, 'includePatents' => $includePatents, ])->json(); } /** * Industrial IoT Edge Power & PVSpectra Dual-Probe Telemetry (Milestone 118 - IMPI No. 5960) */ public function ingestPowerTelemetry(string $deviceId, string $deviceSource = 'PVSPECTRA_SOLAR', float $voltageV = 480.0, float $currentA = 84.5, float $thdNoisePct = 1.8, float $noiseAttenuationPct = 91.8): array { return Http::withHeaders([ 'X-API-KEY' => $this->apiKey, 'Content-Type' => 'application/json', ])->post("{$this->baseUrl}/iot/server-power-telemetry", [ 'deviceId' => $deviceId, 'deviceSource' => $deviceSource, 'voltageV' => $voltageV, 'currentA' => $currentA, 'thdNoisePct' => $thdNoisePct, 'noiseAttenuationPct' => $noiseAttenuationPct, ])->json(); } } ``` --- ## 3. Penggunaan di Controller (`InvoiceController.php`) ```php use App\Services\GPlayAiService; class InvoiceController extends Controller { public function store(Request $request, GPlayAiService $aiService) { $result = $aiService->extractInvoice($request->input('ocr_text')); $extracted = $result['data']; // Simpan ke database Invoice::create([ 'vendor_name' => $extracted['vendorName'], 'total_amount' => $extracted['totalAmount'], ]); return back()->with('success', 'Faktur diekstraksi oleh GPlay AI!'); } } ```