-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtext.txt
More file actions
56 lines (47 loc) · 2.05 KB
/
text.txt
File metadata and controls
56 lines (47 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Inject default company_id if needed
if (!isset($data['company_id']) || empty($data['company_id'])) {
$data['company_id'] = current_company()->id ?? null;
}
// ✨ Process with model-specific logic
if (method_exists($modelClass, 'processImportRow')) {
$data = $modelClass::processImportRow($data);
}
public function checkNdakoAppKey($ndakoKey){
// Validate the APP key format
if (empty($ndakoKey) || !is_string($ndakoKey)) {
Log::warning('Invalid APP key format: ' . $ndakoKey);
return [
'status' => 'error',
'message' => 'APP key must be a non-empty string',
'status_code' => 400,
];
}
// Make HTTP request to the API
try {
$response = Http::post(config('app.api_url', 'http://localhost:8000') . '/api/check-ndako-app', [
'app_key' => $ndakoKey,
]);
if ($response->successful()) {
Log::info('APP key verification successful: ' . $ndakoKey);
return [
'status' => 'success',
'message' => 'Ndako App Key exists and is active',
'data' => $response->json()['data'],
'status_code' => 200,
];
}
Log::warning('APP key verification failed: ' . $ndakoKey . ' - ' . $response->body());
return [
'status' => 'error',
'message' => $response->json()['message'] ?? 'Failed to verify APP key',
'status_code' => $response->status(),
];
} catch (Exception $e) {
Log::error('Error verifying APP key: ' . $e->getMessage());
return [
'status' => 'error',
'message' => 'An error occurred while verifying the APP key: ' . $e->getMessage(),
'status_code' => 500,
];
}
}