1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kerox\Messenger\Api; |
4
|
|
|
|
5
|
|
|
use GuzzleHttp\ClientInterface; |
6
|
|
|
use Kerox\Messenger\Model\ThreadControl; |
7
|
|
|
use Kerox\Messenger\Request\ThreadRequest; |
8
|
|
|
use Kerox\Messenger\Response\ThreadResponse; |
9
|
|
|
|
10
|
|
|
class Thread extends AbstractApi |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var null|\Kerox\Messenger\Api\User |
14
|
|
|
*/ |
15
|
|
|
private static $_instance; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Send constructor. |
19
|
|
|
* |
20
|
|
|
* @param string $pageToken |
21
|
|
|
* @param \GuzzleHttp\ClientInterface $client |
22
|
|
|
*/ |
23
|
3 |
|
public function __construct(string $pageToken, ClientInterface $client) |
24
|
|
|
{ |
25
|
3 |
|
parent::__construct($pageToken, $client); |
26
|
3 |
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param string $pageToken |
30
|
|
|
* @param \GuzzleHttp\ClientInterface $client |
31
|
|
|
* |
32
|
|
|
* @return \Kerox\Messenger\Api\Thread |
33
|
|
|
*/ |
34
|
1 |
|
public static function getInstance(string $pageToken, ClientInterface $client): Thread |
35
|
|
|
{ |
36
|
1 |
|
if (self::$_instance === null) { |
37
|
1 |
|
self::$_instance = new self($pageToken, $client); |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
1 |
|
return self::$_instance; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param \Kerox\Messenger\Model\ThreadControl $threadControl |
45
|
|
|
* |
46
|
|
|
* @return \Kerox\Messenger\Response\ThreadResponse |
47
|
|
|
*/ |
48
|
1 |
|
public function pass(ThreadControl $threadControl): ThreadResponse |
49
|
|
|
{ |
50
|
1 |
|
$request = new ThreadRequest($this->pageToken, $threadControl); |
51
|
1 |
|
$response = $this->client->post('me/pass_thread_control', $request->build()); |
52
|
|
|
|
53
|
1 |
|
return new ThreadResponse($response); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param \Kerox\Messenger\Model\ThreadControl $threadControl |
58
|
|
|
* |
59
|
|
|
* @return \Kerox\Messenger\Response\ThreadResponse |
60
|
|
|
*/ |
61
|
1 |
|
public function take(ThreadControl $threadControl): ThreadResponse |
62
|
|
|
{ |
63
|
1 |
|
$request = new ThreadRequest($this->pageToken, $threadControl); |
64
|
1 |
|
$response = $this->client->post('me/take_thread_control', $request->build()); |
65
|
|
|
|
66
|
1 |
|
return new ThreadResponse($response); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..