Test Failed
Branch development (5e44f6)
by Robert
06:31
created

LiveEngageLaravel::refresh()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Root class file for all api wrappers.
4
 *
5
 * @package LivePersonInc\LiveEngageLaravel
6
 *
7
 */
8
9
namespace LivePersonInc\LiveEngageLaravel;
10
11
use Carbon\Carbon;
12
use GuzzleHttp\Client;
13
use GuzzleHttp\HandlerStack;
14
use GuzzleHttp\Subscriber\Oauth\Oauth1;
15
use LivePersonInc\LiveEngageLaravel\Models\Info;
16
use LivePersonInc\LiveEngageLaravel\Models\MetaData;
17
use LivePersonInc\LiveEngageLaravel\Models\AccountStatus;
18
use LivePersonInc\LiveEngageLaravel\Models\MessagingInfo;
19
use LivePersonInc\LiveEngageLaravel\Models\Payload;
20
use LivePersonInc\LiveEngageLaravel\Models\Visitor;
21
use LivePersonInc\LiveEngageLaravel\Models\Agent;
22
use LivePersonInc\LiveEngageLaravel\Models\Skill;
23
use LivePersonInc\LiveEngageLaravel\Models\Campaign;
24
use LivePersonInc\LiveEngageLaravel\Models\Engagement;
25
use LivePersonInc\LiveEngageLaravel\Models\Conversation;
26
use LivePersonInc\LiveEngageLaravel\Models\Message;
27
use LivePersonInc\LiveEngageLaravel\Collections\EngagementHistory;
28
use LivePersonInc\LiveEngageLaravel\Collections\Skills;
29
use LivePersonInc\LiveEngageLaravel\Collections\AgentParticipants;
30
use LivePersonInc\LiveEngageLaravel\Exceptions\LiveEngageException;
31
use LivePersonInc\LiveEngageLaravel\Collections\ConversationHistory;
32
33
/**
34
 * LiveEngageLaravel class holds all of the root package functions.
35
 *
36
 * All "setting" functions will return `$this` so method can be chained. Most methods will return a class object or Laravel collection.
37
 */
38
class LiveEngageLaravel
39
{
40
	/**
41
	 * account - LiveEngage account number, usually set by configuration
42
	 *
43
	 * (default value: false)
44
	 *
45
	 * @var long
0 ignored issues
show
Bug introduced by
The type LivePersonInc\LiveEngageLaravel\long was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
46
	 * @access private
47
	 */
48
	private $account = false;
49
	/**
50
	 * skills - holds the skills for history retrieval
51
	 *
52
	 * (default value: [])
53
	 *
54
	 * @var array
55
	 * @access private
56
	 */
57
	private $skills = [];
58
	/**
59
	 * config - holds the configuration key where keyset is stored in config/services.php
60
	 *
61
	 * (default value: 'services.liveperson.default')
62
	 *
63
	 * @var string
64
	 * @access private
65
	 */
66
	private $config = 'services.liveperson.default';
67
	/**
68
	 * version - api version
69
	 *
70
	 * (default value: '1.0')
71
	 *
72
	 * @var string
73
	 * @access private
74
	 */
75
	private $version = '1.0';
76
	/**
77
	 * history_limit - stores the history page limit
78
	 *
79
	 * (default value: 50)
80
	 *
81
	 * @var int
82
	 * @access private
83
	 */
84
	private $history_limit = 50;
85
	private $interactive = true;
86
	private $ended = true;
87
	/**
88
	 * bearer - bearer token for V2 authentication
89
	 *
90
	 * (default value: false)
91
	 *
92
	 * @var string
93
	 * @access private
94
	 */
95
	private $bearer = false;
96
	/**
97
	 * revision
98
	 *
99
	 * (default value: 0)
100
	 *
101
	 * @var int
102
	 * @access private
103
	 */
104
	private $revision = 0;
105
106
	/**
107
	 * domain - api domain storage
108
	 *
109
	 * (default value: false)
110
	 *
111
	 * @var bool
112
	 * @access private
113
	 */
114
	private $domain = false;
115
116
	/**
117
	 * retry_limit - number of times the request will attempt before it throws the exception.
118
	 *
119
	 * (default value: 5)
120
	 *
121
	 * @var int
122
	 * @access private
123
	 */
124
	private $retry_limit = 5;
125
	/**
126
	 * retry_counter - stores current count of retries.
127
	 *
128
	 * (default value: 0)
129
	 *
130
	 * @var int
131
	 * @access private
132
	 */
133
	private $retry_counter = 0;
134
135
	private $request_version = 'V1';
136
137
	/**
138
	 * __get magic function to retrieve private properties of the class.
139
	 *
140
	 * @access public
141
	 * @param mixed $attribute
142 5
	 * @return mixed
143
	 */
144 5
	public function __get($attribute)
145
	{
146
		return $this->$attribute;
147
	}
148
149
	private $request;
150
151
	/**
152
	 * __construct function.
153 8
	 *
154
	 * @access public
155 8
	 * @return void
156
	 */
157 8
	public function __construct()
158 8
	{
159
		$this->account = config("{$this->config}.account");
160
		$this->version = config("{$this->config}.version") ?: $this->version;
161
		$this->request = new LiveEngageRequest($this->config);
162
	}
163
164
	/**
165
	 * key function sets the keyset the class should use. Setting this once will be stored for script execution, but not for the session.
166
	 *
167 1
	 * @access public
168
	 * @param string $key (default: 'default')
169 1
	 * @return this
170 1
	 */
171
	public function key($key = 'default')
172 1
	{
173
		$this->config = "services.liveperson.$key";
174
		$this->__construct();
175
176
		return $this;
177
	}
178
179
	/**
180
	 * version function.
181 1
	 *
182
	 * @access public
183 1
	 * @param string $version (default: 'V1')
184 1
	 * @return void
185
	 */
186
	public function version($version = 'V1') {
0 ignored issues
show
Unused Code introduced by
The parameter $version is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

186
	public function version(/** @scrutinizer ignore-unused */ $version = 'V1') {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
187
		$this->request_version = 'V2';
188
189
		return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type LivePersonInc\LiveEngageLaravel\LiveEngageLaravel which is incompatible with the documented return type void.
Loading history...
190
	}
191
192
	/**
193 1
	 * nonInteractive function.
194
	 *
195 1
	 * @access public
196 1
	 * @return void
197
	 */
198
	public function nonInteractive()
199
	{
200
		$this->interactive = false;
201
		return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type LivePersonInc\LiveEngageLaravel\LiveEngageLaravel which is incompatible with the documented return type void.
Loading history...
202
	}
203
204
	/**
205
	 * active function.
206 1
	 *
207
	 * @access public
208 1
	 * @return void
209
	 */
210 1
	public function active()
211
	{
212
		$this->ended = false;
213
		return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type LivePersonInc\LiveEngageLaravel\LiveEngageLaravel which is incompatible with the documented return type void.
Loading history...
214
	}
215
216
	/**
217
	 * limit function.
218
	 *
219
	 * @access public
220 1
	 * @param mixed $limit
221
	 * @return void
222 1
	 */
223
	public function limit($limit)
224 1
	{
225
		$this->history_limit = $limit;
226
227
		return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type LivePersonInc\LiveEngageLaravel\LiveEngageLaravel which is incompatible with the documented return type void.
Loading history...
228
	}
229
230
	/**
231
	 * retry function.
232
	 *
233
	 * @access public
234 1
	 * @param mixed $limit
235
	 * @return void
236 1
	 */
237
	public function retry($limit)
238 1
	{
239
		$this->retry_limit = $limit;
240
241
		return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type LivePersonInc\LiveEngageLaravel\LiveEngageLaravel which is incompatible with the documented return type void.
Loading history...
242
	}
243
244
	/**
245
	 * account function.
246
	 *
247
	 * @access public
248 1
	 * @param mixed $accountid
249
	 * @return void
250 1
	 */
251
	public function account($accountid)
252 1
	{
253
		$this->account = $accountid;
254 1
255
		return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type LivePersonInc\LiveEngageLaravel\LiveEngageLaravel which is incompatible with the documented return type void.
Loading history...
256
	}
257
258
	/**
259
	 * domain function sets the LivePerson domain for the secified service. Like `key` it is set for the execution script, but not session. It must be run each time.
260
	 *
261
	 * @access public
262
	 * @param mixed $service
263
	 * @return this
264
	 */
265
	public function domain($service)
266
	{
267
		$response = $this->request->get('V1', "https://api.liveperson.net/api/account/{$this->account}/service/{$service}/baseURI.json?version={$this->version}", 'GET');
268
269
		$this->domain = $response->body->baseURI;
270
271
		return $this;
272
	}
273
274
	/**
275
	 * visitor function gets or sets visitor attribute information - this only works for CHAT, not messaging.
276
	 *
277
	 * @access public
278
	 * @param string $visitorID
279
	 * @param string $sessionID
280
	 * @param mixed $setData (default: false)
281
	 * @return mixed
282
	 * @codeCoverageIgnore
283
	 */
284
	public function visitor($visitorID, $sessionID, $setData = false)
285
	{
286
		$this->domain('smt');
287
288
		if ($setData) {
289
			$url = "https://{$this->domain}/api/account/{$this->account}/monitoring/visitors/{$visitorID}/visits/current/events?v=1&sid={$sessionID}";
290
291
			return $this->request->get($this->request_version, $url, 'POST', $setData)->body;
292
		} else {
293
			$url = "https://{$this->domain}/api/account/{$this->account}/monitoring/visitors/{$visitorID}/visits/current/state?v=1&sid={$sessionID}";
294
295
			return $this->request->get($this->request_version, $url, 'GET')->body;
296
		}
297
	}
298
299
	/**
300
	 * chat function
301
	 *
302
     * @codeCoverageIgnore
303
     *
304
     * @todo connect this to the server chat api - this function currently does nothing.
305
     */
306
	public function chat()
307
	{
308
		$this->domain('conversationVep');
309
310
		$url = "https://{$this->domain}/api/account/{$this->account}/chat/request?v=1&NC=true";
311
312
		$args = [
313
314
		];
315 1
		$payload = new Payload($args);
316
317 1
		$response = $this->request->get($this->request_version, $url, 'POST', $payload)->body;
318
319 1
		return $response;
320
	}
321 1
322 1
	/**
323
	 * retrieveHistory function.
324 1
	 *
325 1
	 * @access public
326 1
	 * @final
327
	 * @param Carbon $start
328 1
	 * @param Carbon $end
329 1
	 * @param string $url (default: false)
330
	 * @return mixed
331 1
	 */
332
	final public function retrieveHistory(Carbon $start, Carbon $end, $url = false)
333
	{
334 1
		$this->domain('engHistDomain');
335 1
336 1
		$url = $url ?: "https://{$this->domain}/interaction_history/api/account/{$this->account}/interactions/search?limit={$this->history_limit}&offset=0";
337
338 1
		$start_str = $start->toW3cString();
339
		$end_str = $end->toW3cString();
340
341
		$data = new Payload([
342
			'interactive' => $this->interactive,
343
			'ended' => $this->ended,
344
			'start' => [
345
				'from' => strtotime($start_str) . '000',
346
				'to' => strtotime($end_str) . '000',
347
			],
348
			'skillIds' => $this->skills
349
		]);
350
351 1
		$result = $this->request->get($this->request_version, $url, 'POST', $data)->body;
352
		$result->records = $result->interactionHistoryRecords;
353 1
		$result->interactionHistoryRecords = null;
354
355 1
		return $result;
356
	}
357 1
358 1
	/**
359
	 * retrieveMsgHistory function.
360 1
	 *
361 1
	 * @access public
362
	 * @final
363 1
	 * @param Carbon $start
364 1
	 * @param Carbon $end
365
	 * @param string $url (default: false)
366 1
	 * @return mixed
367
	 */
368
	final public function retrieveMsgHistory(Carbon $start, Carbon $end, $url = false, $parameters = [])
369 1
	{
370 1
		$this->domain('msgHist');
371 1
		$version = $this->request_version;
372
373 1
		$url = $url ?: "https://{$this->domain}/messaging_history/api/account/{$this->account}/conversations/search?limit={$this->history_limit}&offset=0&sort=start:desc&v=2";
374
375
		$start_str = $start->toW3cString();
376
		$end_str = $end->toW3cString();
377
378
		$data = new Payload(array_merge([
379
			'status' => $this->ended ? ['CLOSE'] : ['OPEN', 'CLOSE'],
380
			'start' => [
381
				'from' => strtotime($start_str) . '000',
382 1
				'to' => strtotime($end_str) . '000',
383
			],
384 1
			'skillIds' => $this->skills,
385
			'contentToRetrieve' => [
386 1
				'campaign',
387
				'messageRecords',
388 1
				'agentParticipants',
389
				'agentParticipantsLeave',
390
				'agentParticipantsActive',
391
				'consumerParticipants',
392
				'transfers',
393
				'interactions',
394
				'messageScores',
395
				'messageStatuses',
396
				'conversationSurveys',
397
				'coBrowseSessions',
398 1
				'summary',
399
				'sdes',
400 1
				'unAuthSdes',
401
				'monitoring'
402 1
			]
403
		], $parameters));
404 1
405
		$result = $this->request->get($version, $url, 'POST', $data)->body;
406
407
		$result->records = $result->conversationHistoryRecords;
408
		$result->conversationHistoryRecords = null;
409
410
		return $result;
411
	}
412
413
	/**
414 1
	 * skills function gets collection of skills associated with the account.
415
	 *
416 1
	 * @access public
417
	 * @return Collections\Skills
418 1
	 */
419
	public function skills()
420 1
	{
421
		$this->domain('accountConfigReadOnly');
422
423
		$url = "https://{$this->domain}/api/account/{$this->account}/configuration/le-users/skills?v=4.0";
424
425
		return new Skills($this->request->get($this->request_version, $url, 'GET')->body);
426
	}
427
428
	/**
429
	 * getSkill function gets skill object based on ID.
430
	 *
431
	 * @access public
432
	 * @param int $skillId
433
	 * @return Models\Skill
434
	 */
435
	public function getSkill($skillId)
436
	{
437
		$this->domain('accountConfigReadOnly');
438
439
		$url = "https://{$this->domain}/api/account/{$this->account}/configuration/le-users/skills/{$skillId}?v=4.0";
440
441
		return new Skill((array) $this->request->get($this->request_version, $url, 'GET')->body);
442
	}
443
444
	/**
445
	 * getAgent function gets agent object based on ID.
446
	 *
447
	 * @access public
448
	 * @param int $userId
449
	 * @return Models\Agent
450
	 */
451
	public function getAgent($userId)
452
	{
453 1
		$this->domain('accountConfigReadOnly');
454
455 1
		$url = "https://{$this->domain}/api/account/{$this->account}/configuration/le-users/users/{$userId}?v=4.0";
456
457 1
		$content = $this->request->get($this->request_version, $url, 'GET');
458 1
459
		$agent = new Agent((array) $content->body);
460
		$agent->revision = $content->headers['ac-revision'];
0 ignored issues
show
Bug introduced by
The property revision does not seem to exist on LivePersonInc\LiveEngageLaravel\Models\Agent. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
461
462
		return $agent;
463
	}
464
465
	public function getSettings($filters = [])
466
	{
467
		$url = "https://z1-a.houston.int.liveperson.net/a/{$this->account}/module/sitesettings/doc/siteSettingsDictionary.json";
468
469
		$content = $this->request->get('V2', $url, 'GET');
470
471
		$settings = collect($content->body);
472
		foreach ($filters as $filter => $value) {
473
			$settings = $settings->filter(function($item, $key) use ($filter, $value) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

473
			$settings = $settings->filter(function($item, /** @scrutinizer ignore-unused */ $key) use ($filter, $value) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
474
				return str_contains($item->$filter, $value);
475
			});
476
		}
477
478
		return $settings;
479
	}
480
481
	/**
482
	 * updateAgent function.
483
	 *
484
	 * @access public
485
	 * @param mixed $userId
486 1
	 * @param mixed $properties
487
	 * @return void
488 1
	 * @codeCoverageIgnore
489
	 */
490
	public function updateAgent($userId, $properties)
491
	{
492
		$agent = $this->getAgent($userId);
493
494
		$this->domain('accountConfigReadWrite');
495
496
		$url = "https://{$this->domain}/api/account/{$this->account}/configuration/le-users/users/{$userId}?v=4.0";
497
		$headers = [
498 1
			'X-HTTP-Method-Override' => 'PUT',
499
			'If-Match' => $agent->revision
0 ignored issues
show
Bug introduced by
The property revision does not seem to exist on LivePersonInc\LiveEngageLaravel\Models\Agent. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
500 1
		];
501
502 1
		$content = $this->request->get($this->request_version, $url, 'PUT', $properties, $headers);
503
504 1
		return new Agent((array) $content->body);
0 ignored issues
show
Bug Best Practice introduced by
The expression return new LivePersonInc...((array)$content->body) returns the type LivePersonInc\LiveEngageLaravel\Models\Agent which is incompatible with the documented return type void.
Loading history...
505
	}
506 1
507
	/**
508 1
	 * agents function gets collection of agents from account.
509 1
	 *
510 1
	 * @access public
511
	 * @return Collections\AgentParticipants
512 1
	 */
513
	public function agents()
514
	{
515
		$this->domain('accountConfigReadOnly');
516
517
		$select = implode(',', [
518
			'id',
519
			'pid',
520
			'deleted',
521
			'loginName',
522
			'skills',
523
			'nickname',
524
			'dateCreated',
525 1
			'userTypeId',
526
			'isApiUser',
527 1
			'profileIds',
528 1
			'permissionGroups',
529
			'allowedAppKeys',
530 1
			'changePwdNextLogin',
531 1
			'maxChats',
532
			'skillIds',
533 1
			'lpaCreatedUser',
534
			'email',
535 1
			'lobs',
536 1
			'profiles',
537
			'fullName',
538 1
			'employeeId',
539
			'managedAgentGroups',
540 1
			'dateUpdated',
541 1
			'isEnabled',
542
			'lastPwdChangeDate',
543 1
			'pictureUrl'
544
		]);
545
546
		$url = "https://{$this->domain}/api/account/{$this->account}/configuration/le-users/users?v=4.0&select=$select";
547
548
		return new AgentParticipants((array) $this->request->get($this->request_version, $url, 'GET')->body);
549
	}
550
551
	/**
552
	 * getAgentStatus function gets status of agents based on provided Skill IDs.
553
	 *
554 1
	 * @access public
555
	 * @param int/array $skills
0 ignored issues
show
Documentation Bug introduced by
The doc comment int/array at position 0 could not be parsed: Unknown type name 'int/array' at position 0 in int/array.
Loading history...
556 1
	 * @return Collections\AgentParticipants
557
	 */
558 1
	public function getAgentStatus($skills)
559
	{
560 1
		$skills = is_array($skills) ? $skills : [$skills];
561 1
562
		$this->domain('msgHist');
563
564 1
		$url = "https://{$this->domain}/messaging_history/api/account/{$this->account}/agent-view/status";
565 1
566
		$data = ['skillIds' => $skills];
567
568
		$response = $this->request->get($this->request_version, $url, 'POST', $data)->body;
569 1
		$collection = new AgentParticipants($response->agentStatusRecords);
570
		$collection->metaData = new MetaData((array) $response->_metadata);
571
572
		return $collection;
573
574
	}
575
576
	/**
577
	 * conversationHistory function.
578
	 *
579
	 * @access public
580
	 * @param Carbon $start (default: null)
581 1
	 * @param Carbon $end (default: null)
582
	 * @param int/array $skills (default: [])
0 ignored issues
show
Documentation Bug introduced by
The doc comment int/array at position 0 could not be parsed: Unknown type name 'int/array' at position 0 in int/array.
Loading history...
583 1
	 * @return Collections\ConversationHistory
584 1
	 */
585
	public function conversationHistory(Carbon $start = null, Carbon $end = null, $skills = [], $parameters = [])
586 1
	{
587 1
		$this->retry_counter = 0;
588
		$this->skills = $skills;
589 1
590
		$start = $start ?: (new Carbon())->today();
591 1
		$end = $end ?: (new Carbon())->today()->addHours(23)->addMinutes(59);
592 1
593
		$results_object = $this->retrieveMsgHistory($start, $end, false, $parameters);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string expected by parameter $url of LivePersonInc\LiveEngage...l::retrieveMsgHistory(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

593
		$results_object = $this->retrieveMsgHistory($start, $end, /** @scrutinizer ignore-type */ false, $parameters);
Loading history...
594 1
595
		$results_object->_metadata->start = $start;
596 1
		$results_object->_metadata->end = $end;
597 1
598
		$meta = new MetaData((array) $results_object->_metadata);
599 1
600
		$collection = new ConversationHistory($results_object->records);
601
		$collection->metaData = $meta;
602
603
		return $collection;
604
605
	}
606
607
	/**
608
	 * getConversation function.
609 1
	 *
610
	 * @access public
611 1
	 * @param mixed $conversationId
612
	 * @return Models\Conversation
613 1
	 */
614
	public function getConversation($conversationId)
615 1
	{
616
		$this->domain('msgHist');
617
618
		$url = "https://{$this->domain}/messaging_history/api/account/{$this->account}/conversations/conversation/search?v=2";
619
620
		$data = new Payload([
621
			'conversationId' => $conversationId,
622
			'contentToRetrieve' => [
623
				'campaign',
624 1
				'messageRecords',
625
				'agentParticipants',
626 1
				'agentParticipantsLeave',
627
				'agentParticipantsActive',
628 1
				'consumerParticipants',
629 1
				'transfers',
630 1
				'interactions',
631 1
				//'messageScores',
632 1
				//'messageStatuses',
633
				'conversationSurveys',
634
				//'coBrowseSessions',
635 1
				'summary',
636 1
				'sdes',
637 1
				'unAuthSdes',
638 1
				'monitoring'
639 1
			]
640
		]);
641
642 1
		$result = $this->request->get($this->request_version, $url, 'POST', $data)->body;
643
		if (!count($result->conversationHistoryRecords)) {
644 1
			return null; // @codeCoverageIgnore
645
		}
646 1
647
648 1
		return new Conversation((array) $result->conversationHistoryRecords[0]);
649
	}
650
651
	/**
652
	 * engagementHistory function.
653
	 *
654
	 * @access public
655
	 * @param Carbon $start (default: null)
656
	 * @param Carbon $end (default: null)
657
	 * @param int/array $skills (default: [])
0 ignored issues
show
Documentation Bug introduced by
The doc comment int/array at position 0 could not be parsed: Unknown type name 'int/array' at position 0 in int/array.
Loading history...
658
	 * @return Collections\EngagementHistory
659
	 */
660
	public function engagementHistory(Carbon $start = null, Carbon $end = null, $skills = [])
661 1
	{
662
		$this->retry_counter = 0;
663 1
		$this->skills = $skills;
664
665 1
		$start = $start ?: (new Carbon())->today();
666
		$end = $end ?: (new Carbon())->today()->addHours(23)->addMinutes(59);
667 1
668 1
		$results_object = $this->retrieveHistory($start, $end);
669 1
670 1
		$results_object->_metadata->start = $start;
671 1
		$results_object->_metadata->end = $end;
672
673
		$meta = new MetaData((array) $results_object->_metadata);
674
675
		$collection = new EngagementHistory($results_object->records);
676
		$collection->metaData = $meta;
677
678
		return $collection;
679
680
	}
681
682 1
	/**
683
	 * status function gets status of the account.
684
	 *
685
	 * @access public
686
	 * @return Models\AccountStatus
687
	 */
688
	public function status()
689
	{
690
		$url = "https://status.liveperson.com/json?site={$this->account}";
691 2
692
		$response = $this->request->get('V1', $url, 'GET')->body;
693 2
694 2
		return new AccountStatus((array) $response);
695 2
	}
696 2
697
	public function refresh()
698 2
	{
699 2
		$this->request->refresh();
700 2
		return $this;
701 2
	}
702
}
703