lokesh341 commited on
Commit
0ac4d0f
·
1 Parent(s): 2e67668

Update services/salesforce_dispatcher.py

Browse files
Files changed (1) hide show
  1. services/salesforce_dispatcher.py +5 -24
services/salesforce_dispatcher.py CHANGED
@@ -1,7 +1,7 @@
1
  import json
2
  import os
3
  import logging
4
- from datetime import datetime
5
 
6
  # Setup logging
7
  logging.basicConfig(
@@ -10,32 +10,13 @@ logging.basicConfig(
10
  format="%(asctime)s - %(levelname)s - %(message)s"
11
  )
12
 
13
- # Directory for Salesforce logs
14
- SALESFORCE_LOG_DIR = "salesforce_logs"
15
- os.makedirs(SALESFORCE_LOG_DIR, exist_ok=True)
16
-
17
- def dispatch_to_salesforce(detections, timestamp):
18
  """
19
- Dispatch detection data to Salesforce (simulated by logging to a JSON file).
20
  Args:
21
- detections: Dict containing detection data (items, metrics, etc.)
22
- timestamp: Timestamp of the detection
23
  """
24
  try:
25
- # Prepare data
26
- data = {
27
- "timestamp": timestamp,
28
- "detections": detections["items"],
29
- "metrics": detections["metrics"],
30
- "frame_count": detections["frame_count"],
31
- "gps_coordinates": detections["gps_coordinates"]
32
- }
33
-
34
- # Write to JSON file
35
- log_file = os.path.join(SALESFORCE_LOG_DIR, f"detections_{timestamp.replace(':', '-')}.json")
36
- with open(log_file, "w") as f:
37
- json.dump(data, f, indent=2)
38
-
39
- logging.info(f"Dispatched detections to Salesforce log: {log_file}")
40
  except Exception as e:
41
  logging.error(f"Error dispatching to Salesforce: {str(e)}")
 
1
  import json
2
  import os
3
  import logging
4
+ from typing import Dict, Any
5
 
6
  # Setup logging
7
  logging.basicConfig(
 
10
  format="%(asctime)s - %(levelname)s - %(message)s"
11
  )
12
 
13
+ def send_to_salesforce(payload: Dict[str, Any]) -> None:
 
 
 
 
14
  """
15
+ Simulated Salesforce integration by logging to console.
16
  Args:
17
+ payload: Dict containing detection data (items, metrics, etc.)
 
18
  """
19
  try:
20
+ logging.info(f"Salesforce Dispatch Simulated: {json.dumps(payload, indent=2)}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  except Exception as e:
22
  logging.error(f"Error dispatching to Salesforce: {str(e)}")