@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | protected $userSession; |
13 | 13 | protected $TDinstance; |
14 | 14 | |
15 | - public function __invoke(){ |
|
15 | + public function __invoke() { |
|
16 | 16 | return $this->userSession; |
17 | 17 | } |
18 | 18 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if ($userSession != null) { |
29 | 29 | Log::info('CP_SessionManager: Found user session.'); |
30 | 30 | if ($userSession->td_token) { |
31 | - $TDinstance = new CP_TDinstance(env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env, (string) $userSession->td_token); |
|
31 | + $TDinstance = new CP_TDinstance(env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env, (string)$userSession->td_token); |
|
32 | 32 | Log::info('CP_SessionManager: CP_TDinstance initialized with existing JWT.'); |
33 | 33 | } else { |
34 | 34 | $TDinstance = new CP_TDinstance(env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function deleteSession($slackUID) |
75 | 75 | { |
76 | 76 | Log::info('CP_SessionManager: deleteSession method called.'); |
77 | - if($this->checkSession($slackUID)){ |
|
77 | + if ($this->checkSession($slackUID)) { |
|
78 | 78 | $userSession = TDsession::where('s_user_id', $slackUID)->first(); |
79 | 79 | $sid = $userSession->id; |
80 | 80 | $userSession->delete(); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | { |
22 | 22 | $a = func_get_args(); |
23 | 23 | $i = func_num_args(); |
24 | - if (method_exists($this, $f = '__construct'.$i)) { |
|
24 | + if (method_exists($this, $f = '__construct' . $i)) { |
|
25 | 25 | call_user_func_array([$this, $f], $a); |
26 | 26 | } |
27 | 27 | } |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | $this->appid = $i; |
51 | 51 | |
52 | 52 | $parts = explode('.', $a); |
53 | - if(count($parts) == 3) { |
|
53 | + if (count($parts) == 3) { |
|
54 | 54 | list($JWTheader, $JWTpayload, $JWTsig) = $parts; |
55 | 55 | $this->auth = $a; |
56 | 56 | $this->expires = json_decode(base64_decode($JWTpayload))->exp; |
57 | - $this->authstring = 'Authorization: Bearer '.$this->auth; |
|
57 | + $this->authstring = 'Authorization: Bearer ' . $this->auth; |
|
58 | 58 | $this->header = $JWTheader; |
59 | 59 | $this->authsig = $JWTsig; |
60 | 60 | return; |
@@ -66,20 +66,20 @@ discard block |
||
66 | 66 | { |
67 | 67 | if ($e == 'prod') { |
68 | 68 | Log::info('CP_TDauth: Setup for production.'); |
69 | - $this->urlroot = $u.'TDWebApi/api/'; |
|
70 | - $this->appsroot = $u.'TDNext/Apps/'; |
|
69 | + $this->urlroot = $u . 'TDWebApi/api/'; |
|
70 | + $this->appsroot = $u . 'TDNext/Apps/'; |
|
71 | 71 | } elseif ($e == 'sandbox') { |
72 | 72 | Log::info('CP_TDauth: Setup for sandbox.'); |
73 | - $this->urlroot = $u.'SBTDWebApi/api/'; |
|
74 | - $this->appsroot = $u.'SBTDNext/Apps/'; |
|
73 | + $this->urlroot = $u . 'SBTDWebApi/api/'; |
|
74 | + $this->appsroot = $u . 'SBTDNext/Apps/'; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | 78 | private function authorize($b, $w, $u) |
79 | 79 | { |
80 | 80 | Log::info('CP_TDauth: authorize method called.'); |
81 | - Log::info('CP_TDauth: authorize requesting at ['.$u.'auth/loginadmin].'); |
|
82 | - $ch = curl_init($u.'auth/loginadmin'); |
|
81 | + Log::info('CP_TDauth: authorize requesting at [' . $u . 'auth/loginadmin].'); |
|
82 | + $ch = curl_init($u . 'auth/loginadmin'); |
|
83 | 83 | $payload = json_encode(['BEID' => $b, 'WebServicesKey' => $w]); |
84 | 84 | curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); |
85 | 85 | curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:application/json']); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | list($JWTheader, $JWTpayload, $JWTsig) = explode('.', $bearer); |
94 | 94 | $this->auth = $bearer; |
95 | 95 | $this->expires = json_decode(base64_decode($JWTpayload))->exp; |
96 | - $this->authstring = 'Authorization: Bearer '.$this->auth; |
|
96 | + $this->authstring = 'Authorization: Bearer ' . $this->auth; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | Log::info('CP_TDauth: Token was expired. Replaced with new token.'); |
107 | 107 | } else { |
108 | 108 | $remain = $this->expires - time(); |
109 | - Log::info('CP_TDauth: Token ok, time remaining: '.$remain); |
|
109 | + Log::info('CP_TDauth: Token ok, time remaining: ' . $remain); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return true; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | Log::info('CP_TDinstance: connect method called.'); |
142 | 142 | $this->checkToken(); |
143 | - $ch = curl_init($this->urlroot.$point); |
|
143 | + $ch = curl_init($this->urlroot . $point); |
|
144 | 144 | curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:application/json', $this->authstring]); |
145 | 145 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
146 | 146 | if ($type == 'post') { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $check = substr($r, -3); |
162 | 162 | if (substr($check, 1, 1) == '-') { |
163 | 163 | $flag = substr($check, 1, 2); |
164 | - Log::info('CP_TDinstance: flagCheck given flag '.$flag); |
|
164 | + Log::info('CP_TDinstance: flagCheck given flag ' . $flag); |
|
165 | 165 | |
166 | 166 | return $flag; |
167 | 167 | } else { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | public function ticket($ticketno) |
173 | 173 | { |
174 | 174 | Log::info('CP_TDinstance: ticket method called.'); |
175 | - $ticket = $this->connect('get', $this->appid.'/tickets/'.$ticketno, ''); |
|
175 | + $ticket = $this->connect('get', $this->appid . '/tickets/' . $ticketno, ''); |
|
176 | 176 | |
177 | 177 | return $ticket; |
178 | 178 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | if ($flag = '-r') { |
199 | 199 | $data = ['RequestorNameSearch' => substr($search, 0, -3)]; |
200 | 200 | $data_string = json_encode($data); |
201 | - $tickets = $this->connect('post', $this->appid.'/tickets/search', $data_string); |
|
201 | + $tickets = $this->connect('post', $this->appid . '/tickets/search', $data_string); |
|
202 | 202 | |
203 | 203 | return $tickets; |
204 | 204 | } else { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | public function searchAssets($search) |
221 | 221 | { |
222 | 222 | Log::info('CP_TDinstance: searchAssets method called.'); |
223 | - $ticketids = [(int) $search]; |
|
223 | + $ticketids = [(int)$search]; |
|
224 | 224 | $data = ['TicketIDs' => $ticketids]; |
225 | 225 | $data_string = json_encode($data); |
226 | 226 | $assets = $this->connect('post', 'assets/search', $data_string); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | { |
233 | 233 | Log::info('CP_TDinstance: searchResponsibility method called.'); |
234 | 234 | if (!is_array($search)) { |
235 | - $search = [(string) $search]; |
|
235 | + $search = [(string)$search]; |
|
236 | 236 | } |
237 | 237 | $ResponsibilityUids = $search; |
238 | 238 | $data = ['ResponsibilityUids' => $ResponsibilityUids]; |
@@ -246,6 +246,6 @@ discard block |
||
246 | 246 | { |
247 | 247 | Log::info('CP_TDinstance: rootAppsUrl method called.'); |
248 | 248 | |
249 | - return $this->appsroot.$this->appid.'/'; |
|
249 | + return $this->appsroot . $this->appid . '/'; |
|
250 | 250 | } |
251 | 251 | } |
@@ -69,10 +69,10 @@ |
||
69 | 69 | |
70 | 70 | if ($opencount > 0) { |
71 | 71 | $this |
72 | - ->respondToSlack(' |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | if ($ticket['StatusName'] != 'Closed' && $ticket['StatusName'] != 'Cancelled') { |
43 | 43 | $opencount++; |
44 | 44 | $date = date('F jS, Y', strtotime($ticket['CreatedDate'])); |
45 | - $ticketURL = (string) $TDinstance->rootAppsUrl().'Tickets/TicketDet?TicketID='.$ticket['ID']; |
|
45 | + $ticketURL = (string)$TDinstance->rootAppsUrl() . 'Tickets/TicketDet?TicketID=' . $ticket['ID']; |
|
46 | 46 | $ticketDescription = $TDinstance->ticket($ticket['ID']); //Need to do this because in the TD API, searched ticket's desctiption is empty. |
47 | 47 | |
48 | 48 | $attachmentFields[] = AttachmentField::create('Opened On', $date); |
@@ -55,36 +55,36 @@ discard block |
||
55 | 55 | |
56 | 56 | $action = $attachmentAction->toArray(); |
57 | 57 | $ticketattachments[] = Attachment::create() |
58 | - ->setFallback('Ticket '.$ticket['ID']) |
|
59 | - ->setTitle(' |
@@ -53,17 +53,17 @@ |
||
53 | 53 | $attachmentFields[] = AttachmentField::create('Date Opened', $date)->displaySideBySide(); |
54 | 54 | |
55 | 55 | $this |
56 | - ->respondToSlack(" |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | if ($ticket && $auth) { |
32 | 32 | $date = date('F jS, Y', strtotime($ticket['CreatedDate'])); |
33 | - $ticketURL = (string) $TDinstance->rootAppsUrl().'Tickets/TicketDet?TicketID='.$ticket['ID']; |
|
33 | + $ticketURL = (string)$TDinstance->rootAppsUrl() . 'Tickets/TicketDet?TicketID=' . $ticket['ID']; |
|
34 | 34 | $assets = $TDinstance->searchAssets($ticket['ID']); |
35 | 35 | $assetnames = 'No Assets'; |
36 | 36 | $userSession()->increment('td_tickets'); |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | if (count($assets)) { |
39 | 39 | $assetnames = ''; |
40 | 40 | foreach ($assets as $asset) { |
41 | - $assetnames = $assetnames.$asset['Name'].', '; |
|
41 | + $assetnames = $assetnames . $asset['Name'] . ', '; |
|
42 | 42 | } |
43 | 43 | $assetnames = substr($assetnames, 0, -2); |
44 | 44 | } |
45 | 45 | |
46 | 46 | $attachmentFields[] = AttachmentField::create('Description', $ticket['Description']); |
47 | - $attachmentFields[] = AttachmentField::create('Requestor', $ticket['RequestorName']."\n".$ticket['RequestorEmail']."\n".$ticket['RequestorPhone'])->displaySideBySide(); |
|
48 | - $attachmentFields[] = AttachmentField::create('Location', $ticket['LocationName']."\n".$ticket['LocationRoomName'])->displaySideBySide(); |
|
47 | + $attachmentFields[] = AttachmentField::create('Requestor', $ticket['RequestorName'] . "\n" . $ticket['RequestorEmail'] . "\n" . $ticket['RequestorPhone'])->displaySideBySide(); |
|
48 | + $attachmentFields[] = AttachmentField::create('Location', $ticket['LocationName'] . "\n" . $ticket['LocationRoomName'])->displaySideBySide(); |
|
49 | 49 | $attachmentFields[] = AttachmentField::create('Service', $ticket['ServiceName'])->displaySideBySide(); |
50 | 50 | $attachmentFields[] = AttachmentField::create('Status', $ticket['StatusName'])->displaySideBySide(); |
51 | 51 | $attachmentFields[] = AttachmentField::create('Assets', $assetnames)->displaySideBySide(); |
52 | - $attachmentFields[] = AttachmentField::create('Assigned To', $ticket['ResponsibleFullName']."\n".$ticket['ResponsibleEmail'])->displaySideBySide(); |
|
52 | + $attachmentFields[] = AttachmentField::create('Assigned To', $ticket['ResponsibleFullName'] . "\n" . $ticket['ResponsibleEmail'])->displaySideBySide(); |
|
53 | 53 | $attachmentFields[] = AttachmentField::create('Date Opened', $date)->displaySideBySide(); |
54 | 54 | |
55 | 55 | $this |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | ->setTitle("{$ticket['Title']}") |
61 | 61 | ->setTitleLink("{$ticketURL}") |
62 | 62 | ->setFields($attachmentFields) |
63 | - ->setFooter('CP_TD/S API bot microservice v'.$TDinstance->getVersion().' | Build: '.$build) |
|
63 | + ->setFooter('CP_TD/S API bot microservice v' . $TDinstance->getVersion() . ' | Build: ' . $build) |
|
64 | 64 | ) |
65 | 65 | ->displayResponseToEveryoneOnChannel() |
66 | 66 | ->send(); |