Passed
Branch master (271180)
by Robert
04:31
created
src/LiveEngageLaravel.php 1 patch
Indentation   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -20,397 +20,397 @@
 block discarded – undo
20 20
 
21 21
 class LiveEngageLaravel
22 22
 {
23
-    private $account = false;
24
-    private $results = [];
25
-    private $skills = [];
26
-    private $next = false;
27
-    private $prev = false;
28
-    private $start;
29
-    private $end;
30
-    private $config = 'services.liveperson.default';
31
-    private $version = '1.0';
32
-    private $history_limit = 50;
33
-    private $history = false;
34
-    private $context = 'interactionHistoryRecords';
35
-    private $interactive = true;
36
-    private $ended = true;
37
-    private $bearer = false;
38
-
39
-    private $domain = false;
40
-
41
-    private $retry_limit = 5;
42
-    private $retry_counter = 0;
43
-
44
-    public function __get($attribute)
45
-    {
46
-        return $this->$attribute;
47
-    }
48
-
49
-    public function __set($attribute, $value)
50
-    {
51
-        return $this->$attribute = $value;
52
-    }
53
-
54
-    public function __construct()
55
-    {
56
-        $this->account = config("{$this->config}.account");
57
-        //$this->domain = config("{$this->config}.domain");
58
-        $this->version = config("{$this->config}.version") ?: $this->version;
59
-    }
60
-
61
-    public function key($key = 'default')
62
-    {
63
-        $this->config = "services.liveperson.$key";
64
-
65
-        return $this;
66
-    }
23
+	private $account = false;
24
+	private $results = [];
25
+	private $skills = [];
26
+	private $next = false;
27
+	private $prev = false;
28
+	private $start;
29
+	private $end;
30
+	private $config = 'services.liveperson.default';
31
+	private $version = '1.0';
32
+	private $history_limit = 50;
33
+	private $history = false;
34
+	private $context = 'interactionHistoryRecords';
35
+	private $interactive = true;
36
+	private $ended = true;
37
+	private $bearer = false;
38
+
39
+	private $domain = false;
40
+
41
+	private $retry_limit = 5;
42
+	private $retry_counter = 0;
43
+
44
+	public function __get($attribute)
45
+	{
46
+		return $this->$attribute;
47
+	}
48
+
49
+	public function __set($attribute, $value)
50
+	{
51
+		return $this->$attribute = $value;
52
+	}
53
+
54
+	public function __construct()
55
+	{
56
+		$this->account = config("{$this->config}.account");
57
+		//$this->domain = config("{$this->config}.domain");
58
+		$this->version = config("{$this->config}.version") ?: $this->version;
59
+	}
60
+
61
+	public function key($key = 'default')
62
+	{
63
+		$this->config = "services.liveperson.$key";
64
+
65
+		return $this;
66
+	}
67 67
     
68
-    public function nonInteractive()
69
-    {
70
-	    $this->interactive = false;
71
-	    return $this;
72
-    }
68
+	public function nonInteractive()
69
+	{
70
+		$this->interactive = false;
71
+		return $this;
72
+	}
73 73
     
74
-    public function active()
75
-    {
76
-	    $this->ended = false;
77
-	    return $this;
78
-    }
79
-
80
-    public function limit($limit)
81
-    {
82
-        $this->history_limit = $limit;
83
-
84
-        return $this;
85
-    }
86
-
87
-    public function skills($skills)
88
-    {
89
-        $this->skills = $skills;
90
-
91
-        return $this;
92
-    }
93
-
94
-    public function retry($limit)
95
-    {
96
-        $this->retry_limit = $limit;
97
-
98
-        return $this;
99
-    }
100
-
101
-    public function get()
102
-    {
103
-        return $this->results;
104
-    }
105
-
106
-    public function account($accountid)
107
-    {
108
-        $this->account = $accountid;
109
-
110
-        return $this;
111
-    }
112
-
113
-    public function domain($service)
114
-    {
115
-        $response = $this->requestV1("https://api.liveperson.net/api/account/{$this->account}/service/{$service}/baseURI.json?version={$this->version}", 'GET');
116
-        if (is_a($response, 'Exception')) {
117
-            throw new \Exception('Unable to get LivePerson account domain', 101);
118
-        } else {
119
-            $this->domain = $response->baseURI;
120
-
121
-            return $this;
122
-        }
123
-    }
124
-
125
-    public function visitor($visitorID, $sessionID, $setData = false)
126
-    {
127
-        $this->domain('smt');
128
-
129
-        if ($setData) {
130
-            $url = "https://{$this->domain}/api/account/{$this->account}/monitoring/visitors/{$visitorID}/visits/current/events?v=1&sid={$sessionID}";
131
-
132
-            return $this->requestV1($url, 'POST', $setData);
133
-        } else {
134
-            $url = "https://{$this->domain}/api/account/{$this->account}/monitoring/visitors/{$visitorID}/visits/current/state?v=1&sid={$sessionID}";
135
-
136
-            return $this->requestV1($url, 'GET');
137
-        }
138
-    }
139
-
140
-    final public function retrieveHistory(Carbon $start, Carbon $end, $url = false)
141
-    {
142
-        $this->domain('engHistDomain');
143
-
144
-        $url = $url ?: "https://{$this->domain}/interaction_history/api/account/{$this->account}/interactions/search?limit={$this->history_limit}&offset=0";
145
-
146
-        $start_str = $start->toW3cString();
147
-        $end_str = $end->toW3cString();
148
-
149
-        $data = [
150
-            'interactive' => $this->interactive,
151
-            'ended' => $this->ended,
152
-            'start' => [
153
-                'from' => strtotime($start_str).'000',
154
-                'to' => strtotime($end_str).'000',
155
-            ],
156
-        ];
157
-        if (count($this->skills)) {
158
-            $data['skillIds'] = $this->skills;
159
-        }
160
-
161
-        $data = new Payload($data);
162
-
163
-        return $this->requestV1($url, 'POST', $data);
164
-    }
165
-
166
-    final public function retrieveMsgHistory(Carbon $start, Carbon $end, $url = false)
167
-    {
168
-        $this->domain('msgHist');
169
-
170
-        $url = $url ?: "https://{$this->domain}/messaging_history/api/account/{$this->account}/conversations/search?limit={$this->history_limit}&offset=0";
171
-
172
-        $start_str = $start->toW3cString();
173
-        $end_str = $end->toW3cString();
174
-
175
-        $data = [
176
-            'interactive' => $this->interactive,
177
-            'ended' => $this->ended,
178
-            'start' => [
179
-                'from' => strtotime($start_str).'000',
180
-                'to' => strtotime($end_str).'000',
181
-            ],
182
-        ];
183
-        if (count($this->skills)) {
184
-            $data['skillIds'] = $this->skills;
185
-        }
186
-
187
-        $data = new Payload($data);
188
-
189
-        return $this->requestV1($url, 'POST', $data);
190
-    }
74
+	public function active()
75
+	{
76
+		$this->ended = false;
77
+		return $this;
78
+	}
79
+
80
+	public function limit($limit)
81
+	{
82
+		$this->history_limit = $limit;
83
+
84
+		return $this;
85
+	}
86
+
87
+	public function skills($skills)
88
+	{
89
+		$this->skills = $skills;
90
+
91
+		return $this;
92
+	}
93
+
94
+	public function retry($limit)
95
+	{
96
+		$this->retry_limit = $limit;
97
+
98
+		return $this;
99
+	}
100
+
101
+	public function get()
102
+	{
103
+		return $this->results;
104
+	}
105
+
106
+	public function account($accountid)
107
+	{
108
+		$this->account = $accountid;
109
+
110
+		return $this;
111
+	}
112
+
113
+	public function domain($service)
114
+	{
115
+		$response = $this->requestV1("https://api.liveperson.net/api/account/{$this->account}/service/{$service}/baseURI.json?version={$this->version}", 'GET');
116
+		if (is_a($response, 'Exception')) {
117
+			throw new \Exception('Unable to get LivePerson account domain', 101);
118
+		} else {
119
+			$this->domain = $response->baseURI;
120
+
121
+			return $this;
122
+		}
123
+	}
124
+
125
+	public function visitor($visitorID, $sessionID, $setData = false)
126
+	{
127
+		$this->domain('smt');
128
+
129
+		if ($setData) {
130
+			$url = "https://{$this->domain}/api/account/{$this->account}/monitoring/visitors/{$visitorID}/visits/current/events?v=1&sid={$sessionID}";
131
+
132
+			return $this->requestV1($url, 'POST', $setData);
133
+		} else {
134
+			$url = "https://{$this->domain}/api/account/{$this->account}/monitoring/visitors/{$visitorID}/visits/current/state?v=1&sid={$sessionID}";
135
+
136
+			return $this->requestV1($url, 'GET');
137
+		}
138
+	}
139
+
140
+	final public function retrieveHistory(Carbon $start, Carbon $end, $url = false)
141
+	{
142
+		$this->domain('engHistDomain');
143
+
144
+		$url = $url ?: "https://{$this->domain}/interaction_history/api/account/{$this->account}/interactions/search?limit={$this->history_limit}&offset=0";
145
+
146
+		$start_str = $start->toW3cString();
147
+		$end_str = $end->toW3cString();
148
+
149
+		$data = [
150
+			'interactive' => $this->interactive,
151
+			'ended' => $this->ended,
152
+			'start' => [
153
+				'from' => strtotime($start_str).'000',
154
+				'to' => strtotime($end_str).'000',
155
+			],
156
+		];
157
+		if (count($this->skills)) {
158
+			$data['skillIds'] = $this->skills;
159
+		}
160
+
161
+		$data = new Payload($data);
162
+
163
+		return $this->requestV1($url, 'POST', $data);
164
+	}
165
+
166
+	final public function retrieveMsgHistory(Carbon $start, Carbon $end, $url = false)
167
+	{
168
+		$this->domain('msgHist');
169
+
170
+		$url = $url ?: "https://{$this->domain}/messaging_history/api/account/{$this->account}/conversations/search?limit={$this->history_limit}&offset=0";
171
+
172
+		$start_str = $start->toW3cString();
173
+		$end_str = $end->toW3cString();
174
+
175
+		$data = [
176
+			'interactive' => $this->interactive,
177
+			'ended' => $this->ended,
178
+			'start' => [
179
+				'from' => strtotime($start_str).'000',
180
+				'to' => strtotime($end_str).'000',
181
+			],
182
+		];
183
+		if (count($this->skills)) {
184
+			$data['skillIds'] = $this->skills;
185
+		}
186
+
187
+		$data = new Payload($data);
188
+
189
+		return $this->requestV1($url, 'POST', $data);
190
+	}
191 191
     
192
-    public function getAgentStatus(array $skills)
193
-    {
192
+	public function getAgentStatus(array $skills)
193
+	{
194 194
 	
195
-	    $this->domain('msgHist');
195
+		$this->domain('msgHist');
196 196
         
197
-        $url = "https://{$this->domain}/messaging_history/api/account/{$this->account}/agent-view/status";
197
+		$url = "https://{$this->domain}/messaging_history/api/account/{$this->account}/agent-view/status";
198 198
         
199
-        $data['skillIds'] = $skills;
199
+		$data['skillIds'] = $skills;
200 200
         
201
-        $response = $this->requestV1($url, 'POST', $data);
202
-        $agents = [];
201
+		$response = $this->requestV1($url, 'POST', $data);
202
+		$agents = [];
203 203
         
204
-        foreach ($response->agentStatusRecords as $agent) {
205
-	        $agents[] = new Agent((array) $agent);
206
-        }
204
+		foreach ($response->agentStatusRecords as $agent) {
205
+			$agents[] = new Agent((array) $agent);
206
+		}
207 207
         
208
-        $collection = new Humans($agents);
209
-        $collection->metaData = $response->_metadata;
208
+		$collection = new Humans($agents);
209
+		$collection->metaData = $response->_metadata;
210 210
         
211
-        return $collection;
211
+		return $collection;
212 212
         
213
-    }
213
+	}
214 214
 
215
-    public function messagingHistory(Carbon $start = null, Carbon $end = null)
216
-    {
217
-        $this->retry_counter = 0;
215
+	public function messagingHistory(Carbon $start = null, Carbon $end = null)
216
+	{
217
+		$this->retry_counter = 0;
218 218
 
219
-        $start = $start ?: (new Carbon())->today();
220
-        $end = $end ?: (new Carbon())->today()->addHours(23)->addMinutes(59);
219
+		$start = $start ?: (new Carbon())->today();
220
+		$end = $end ?: (new Carbon())->today()->addHours(23)->addMinutes(59);
221 221
 
222
-        $this->start = $start;
223
-        $this->end = $end;
222
+		$this->start = $start;
223
+		$this->end = $end;
224 224
         
225
-        $results_object = $this->retrieveMsgHistory($start, $end);
225
+		$results_object = $this->retrieveMsgHistory($start, $end);
226 226
 
227 227
 		if (is_object($results_object)) {
228 228
 
229
-	        $results = $results_object->conversationHistoryRecords;
230
-	        if (property_exists($results_object->_metadata, 'next')) {
231
-	            $this->next = $results_object->_metadata->next->href;
232
-	        }
233
-	        if (property_exists($results_object->_metadata, 'prev')) {
234
-	            $this->prev = $results_object->_metadata->prev->href;
235
-	        }
229
+			$results = $results_object->conversationHistoryRecords;
230
+			if (property_exists($results_object->_metadata, 'next')) {
231
+				$this->next = $results_object->_metadata->next->href;
232
+			}
233
+			if (property_exists($results_object->_metadata, 'prev')) {
234
+				$this->prev = $results_object->_metadata->prev->href;
235
+			}
236 236
 	
237
-	        $history = [];
238
-	        foreach ($results as $item) {
239
-	            if (property_exists($item, 'info')) {
240
-	                $item->info = new Info((array) $item->info);
241
-	            }
237
+			$history = [];
238
+			foreach ($results as $item) {
239
+				if (property_exists($item, 'info')) {
240
+					$item->info = new Info((array) $item->info);
241
+				}
242 242
 	
243
-	            if (property_exists($item, 'visitorInfo')) {
244
-	                $item->visitorInfo = new Visitor((array) $item->visitorInfo);
245
-	            }
243
+				if (property_exists($item, 'visitorInfo')) {
244
+					$item->visitorInfo = new Visitor((array) $item->visitorInfo);
245
+				}
246 246
 	
247
-	            if (property_exists($item, 'campaign')) {
248
-	                $item->campaign = new Campaign((array) $item->campaign);
249
-	            }
247
+				if (property_exists($item, 'campaign')) {
248
+					$item->campaign = new Campaign((array) $item->campaign);
249
+				}
250 250
 	
251
-	            $history[] = new Conversation((array) $item);
252
-	        }
251
+				$history[] = new Conversation((array) $item);
252
+			}
253 253
 	
254
-	        $collection = new ConversationHistory($history, $this);
255
-	        $collection->metaData = $results_object->_metadata;
254
+			$collection = new ConversationHistory($history, $this);
255
+			$collection->metaData = $results_object->_metadata;
256 256
 	        
257
-	        return $collection;
257
+			return $collection;
258 258
 	        
259
-	    } else {
260
-		    return false;
261
-	    }
262
-    }
259
+		} else {
260
+			return false;
261
+		}
262
+	}
263 263
 
264
-    public function history(Carbon $start = null, Carbon $end = null)
265
-    {
266
-        $this->retry_counter = 0;
264
+	public function history(Carbon $start = null, Carbon $end = null)
265
+	{
266
+		$this->retry_counter = 0;
267 267
 
268
-        $start = $start ?: (new Carbon())->today();
269
-        $end = $end ?: (new Carbon())->today()->addHours(23)->addMinutes(59);
268
+		$start = $start ?: (new Carbon())->today();
269
+		$end = $end ?: (new Carbon())->today()->addHours(23)->addMinutes(59);
270 270
 
271
-        $this->start = $start;
272
-        $this->end = $end;
271
+		$this->start = $start;
272
+		$this->end = $end;
273 273
 
274
-        $results_object = $this->retrieveHistory($start, $end);
274
+		$results_object = $this->retrieveHistory($start, $end);
275 275
         
276
-        if (is_object($results_object)) {
276
+		if (is_object($results_object)) {
277 277
         
278
-	        $results = $results_object->interactionHistoryRecords;
279
-	        if (property_exists($results_object->_metadata, 'next')) {
280
-	            $this->next = $results_object->_metadata->next->href;
281
-	        }
282
-	        if (property_exists($results_object->_metadata, 'prev')) {
283
-	            $this->prev = $results_object->_metadata->prev->href;
284
-	        }
278
+			$results = $results_object->interactionHistoryRecords;
279
+			if (property_exists($results_object->_metadata, 'next')) {
280
+				$this->next = $results_object->_metadata->next->href;
281
+			}
282
+			if (property_exists($results_object->_metadata, 'prev')) {
283
+				$this->prev = $results_object->_metadata->prev->href;
284
+			}
285 285
 	
286
-	        $history = [];
287
-	        foreach ($results as $item) {
288
-	            if (property_exists($item, 'info')) {
289
-	                $item->info = new Info((array) $item->info);
290
-	            }
286
+			$history = [];
287
+			foreach ($results as $item) {
288
+				if (property_exists($item, 'info')) {
289
+					$item->info = new Info((array) $item->info);
290
+				}
291 291
 	
292
-	            if (property_exists($item, 'visitorInfo')) {
293
-	                $item->visitorInfo = new Visitor((array) $item->visitorInfo);
294
-	            }
292
+				if (property_exists($item, 'visitorInfo')) {
293
+					$item->visitorInfo = new Visitor((array) $item->visitorInfo);
294
+				}
295 295
 	
296
-	            if (property_exists($item, 'campaign')) {
297
-	                $item->campaign = new Campaign((array) $item->campaign);
298
-	            }
296
+				if (property_exists($item, 'campaign')) {
297
+					$item->campaign = new Campaign((array) $item->campaign);
298
+				}
299 299
 	
300
-	            $history[] = new Engagement((array) $item);
301
-	        }
300
+				$history[] = new Engagement((array) $item);
301
+			}
302 302
 	        
303
-	        $collection = new EngagementHistory($history, $this);
304
-	        $collection->metaData = $results_object->_metadata;
303
+			$collection = new EngagementHistory($history, $this);
304
+			$collection->metaData = $results_object->_metadata;
305 305
 	        
306
-	        return $collection;
306
+			return $collection;
307 307
 	        
308
-        } else {
309
-	        return false;
310
-        }
311
-    }
308
+		} else {
309
+			return false;
310
+		}
311
+	}
312 312
     
313
-    public function login()
314
-    {
315
-	    $this->domain('agentVep');
313
+	public function login()
314
+	{
315
+		$this->domain('agentVep');
316 316
 	    
317
-	    $consumer_key = config("{$this->config}.key");
318
-        $consumer_secret = config("{$this->config}.secret");
319
-        $token = config("{$this->config}.token");
320
-        $secret = config("{$this->config}.token_secret");
321
-        $username = config("{$this->config}.user_name");
317
+		$consumer_key = config("{$this->config}.key");
318
+		$consumer_secret = config("{$this->config}.secret");
319
+		$token = config("{$this->config}.token");
320
+		$secret = config("{$this->config}.token_secret");
321
+		$username = config("{$this->config}.user_name");
322 322
         
323
-        $auth = [
324
-	        'username'          => $username,
325
-            'appKey'            => $consumer_key,
326
-            'secret'            => $consumer_secret,
327
-            'accessToken'		=> $token,
328
-            'accessTokenSecret' => $secret,
329
-        ];
323
+		$auth = [
324
+			'username'          => $username,
325
+			'appKey'            => $consumer_key,
326
+			'secret'            => $consumer_secret,
327
+			'accessToken'		=> $token,
328
+			'accessTokenSecret' => $secret,
329
+		];
330 330
         
331
-        $url = "https://{$this->domain}/api/account/{$this->account}/login?v=1.3";
331
+		$url = "https://{$this->domain}/api/account/{$this->account}/login?v=1.3";
332 332
         
333
-        $response = $this->requestV1($url, 'POST', $auth);
333
+		$response = $this->requestV1($url, 'POST', $auth);
334 334
         
335
-        $this->bearer = $response->bearer;
335
+		$this->bearer = $response->bearer;
336 336
         
337
-        return $this;
338
-    }
337
+		return $this;
338
+	}
339 339
     
340
-    private function requestV2($url, $method, $payload = false)
341
-    {
342
-	    if (!$this->bearer) $this->login();
340
+	private function requestV2($url, $method, $payload = false)
341
+	{
342
+		if (!$this->bearer) $this->login();
343 343
 	    
344
-	    $client = new Client();
345
-	    $args = [
346
-		    'headers' => [
347
-			    'Authorization' => $this->bearer
348
-		    ]
349
-	    ];
344
+		$client = new Client();
345
+		$args = [
346
+			'headers' => [
347
+				'Authorization' => $this->bearer
348
+			]
349
+		];
350 350
 	    
351
-	    if ($payload !== false) {
352
-            $args['body'] = json_encode($payload);
353
-        }
351
+		if ($payload !== false) {
352
+			$args['body'] = json_encode($payload);
353
+		}
354 354
 	    
355
-	    try {
356
-		    $res = $client->request($method, $url, $args);
357
-	    } catch (\Exception $e) {
358
-		    throw $e;
359
-	    } 
355
+		try {
356
+			$res = $client->request($method, $url, $args);
357
+		} catch (\Exception $e) {
358
+			throw $e;
359
+		} 
360 360
 	    
361
-	    return json_decode($res->getBody());
362
-    }
363
-
364
-    private function requestV1($url, $method, $payload = false)
365
-    {
366
-        $consumer_key = config("{$this->config}.key");
367
-        $consumer_secret = config("{$this->config}.secret");
368
-        $token = config("{$this->config}.token");
369
-        $secret = config("{$this->config}.token_secret");
370
-
371
-        $stack = HandlerStack::create();
372
-        $auth = new Oauth1([
373
-            'consumer_key'    => $consumer_key,
374
-            'consumer_secret' => $consumer_secret,
375
-            'token'           => $token,
376
-            'token_secret'    => $secret,
377
-            'signature_method'=> Oauth1::SIGNATURE_METHOD_HMAC,
378
-        ]);
379
-        $stack->push($auth);
380
-
381
-        $client = new Client([
382
-            'handler' => $stack,
383
-        ]);
384
-
385
-        $args = [
386
-            'auth' => 'oauth',
387
-            'headers' => [
388
-                'content-type' => 'application/json',
389
-            ],
390
-        ];
391
-
392
-        if ($payload !== false) {
393
-            $args['body'] = json_encode($payload);
394
-        }
395
-
396
-        try {
397
-            $res = $client->request($method, $url, $args);
398
-
399
-            $response = json_decode($res->getBody());
400
-        } catch (\GuzzleHttp\Exception\ConnectException $connection) {
401
-            return $connection;
402
-        } catch (\GuzzleHttp\Exception\ClientException $clientException) {
403
-	        return $clientException;
404
-        } catch (\Exception $e) {
405
-            if ($this->retry_counter < $this->retry_limit || $this->retry_limit == -1) {
406
-                usleep(1500);
407
-                $this->retry_counter++;
408
-                $response = $this->requestV1($url, $payload);
409
-            } else {
410
-                throw $e; //new LiveEngageException("Retry limit has been exceeded ($this->retry_limit)", 100);
411
-            }
412
-        }
413
-
414
-        return $response;
415
-    }
361
+		return json_decode($res->getBody());
362
+	}
363
+
364
+	private function requestV1($url, $method, $payload = false)
365
+	{
366
+		$consumer_key = config("{$this->config}.key");
367
+		$consumer_secret = config("{$this->config}.secret");
368
+		$token = config("{$this->config}.token");
369
+		$secret = config("{$this->config}.token_secret");
370
+
371
+		$stack = HandlerStack::create();
372
+		$auth = new Oauth1([
373
+			'consumer_key'    => $consumer_key,
374
+			'consumer_secret' => $consumer_secret,
375
+			'token'           => $token,
376
+			'token_secret'    => $secret,
377
+			'signature_method'=> Oauth1::SIGNATURE_METHOD_HMAC,
378
+		]);
379
+		$stack->push($auth);
380
+
381
+		$client = new Client([
382
+			'handler' => $stack,
383
+		]);
384
+
385
+		$args = [
386
+			'auth' => 'oauth',
387
+			'headers' => [
388
+				'content-type' => 'application/json',
389
+			],
390
+		];
391
+
392
+		if ($payload !== false) {
393
+			$args['body'] = json_encode($payload);
394
+		}
395
+
396
+		try {
397
+			$res = $client->request($method, $url, $args);
398
+
399
+			$response = json_decode($res->getBody());
400
+		} catch (\GuzzleHttp\Exception\ConnectException $connection) {
401
+			return $connection;
402
+		} catch (\GuzzleHttp\Exception\ClientException $clientException) {
403
+			return $clientException;
404
+		} catch (\Exception $e) {
405
+			if ($this->retry_counter < $this->retry_limit || $this->retry_limit == -1) {
406
+				usleep(1500);
407
+				$this->retry_counter++;
408
+				$response = $this->requestV1($url, $payload);
409
+			} else {
410
+				throw $e; //new LiveEngageException("Retry limit has been exceeded ($this->retry_limit)", 100);
411
+			}
412
+		}
413
+
414
+		return $response;
415
+	}
416 416
 }
Please login to merge, or discard this patch.