Wajahat698 commited on
Commit
9aa25e9
·
verified ·
1 Parent(s): a476428

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -52
app.py CHANGED
@@ -35,58 +35,26 @@ def home():
35
 
36
  def create_ticket(issue):
37
 
38
- board_options = [
39
- {"name": "Help Desk"},
40
- {"name": "Service Desk"},
41
- {"name": "Support"}
42
- ]
43
-
44
- company_options = [
45
- {"identifier": "INTRINSIC"},
46
- {"identifier": "Intrinsic"},
47
- {"identifier": "Intrinsic Technology"},
48
- {"name": "Intrinsic Technology"}
49
- ]
50
-
51
- priority_options = [
52
- {"name": "Priority 1 - Emergency"},
53
- {"name": "Priority 2 - High"},
54
- {"name": "Priority 3 - Medium"},
55
- {"name": "Priority 4 - Low"},
56
- {"name": "High"},
57
- {"name": "Medium"},
58
- {"name": "Low"}
59
- ]
60
-
61
- for board in board_options:
62
- for company in company_options:
63
- for priority in priority_options:
64
-
65
- ticket = {
66
- "summary": issue[:100],
67
- "initialDescription": issue,
68
- "board": board,
69
- "company": company,
70
- "priority": priority
71
- }
72
-
73
- logger.info("Trying ticket payload: %s", ticket)
74
-
75
- r = requests.post(
76
- f"{BASE_URL}/service/tickets",
77
- headers=cw_headers,
78
- json=ticket
79
- )
80
-
81
- logger.info("ConnectWise status: %s", r.status_code)
82
- logger.info("ConnectWise response: %s", r.text)
83
-
84
- if r.status_code in [200, 201]:
85
- ticket_id = r.json().get("id")
86
- logger.info("Ticket created successfully: %s", ticket_id)
87
- return ticket_id
88
-
89
- logger.error("All ticket attempts failed")
90
  return "error"
91
  @app.route("/slack/events", methods=["POST"])
92
  def slack_events():
 
35
 
36
  def create_ticket(issue):
37
 
38
+ ticket = {
39
+ "summary": issue[:100],
40
+ "initialDescription": issue,
41
+ "board": {"id": 21},
42
+ "company": {"id": 250},
43
+ "priority": {"id": 8}
44
+ }
45
+
46
+ r = requests.post(
47
+ f"{BASE_URL}/service/tickets",
48
+ headers=cw_headers,
49
+ json=ticket
50
+ )
51
+
52
+ logger.info("ConnectWise status: %s", r.status_code)
53
+ logger.info("ConnectWise response: %s", r.text)
54
+
55
+ if r.status_code in [200, 201]:
56
+ return r.json().get("id")
57
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  return "error"
59
  @app.route("/slack/events", methods=["POST"])
60
  def slack_events():