-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPartner.php
More file actions
80 lines (70 loc) · 2.43 KB
/
Partner.php
File metadata and controls
80 lines (70 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
namespace GreenApi\RestApi\tools;
use GreenApi\RestApi\GreenApiClient;
use stdClass;
class Partner {
/**
* @param GreenApiClient $greenApi
*/
private $greenApi;
/**
* @param GreenApiClient $greenApi
*/
public function __construct(GreenApiClient $greenApi) {
$this->greenApi = $greenApi;
}
/**
* The method is used to getting all the account instances created by the partner.
*
* @return stdClass
* @link https://green-api.com/en/docs/partners/getInstances/
*/
public function getInstances(): stdClass {
return $this->greenApi->request('GET',
'{{host}}/partner/getInstances/{{partnerToken}}');
}
/**
* The method is used to creating a messenger account instance on the partner's part
*
* @param $payload
* @return stdClass
* @link https://green-api.com/en/docs/partners/createInstance/
*/
public function createInstance($payload): stdClass {
$defaultParameters = [
'name' => null,
'webhookUrl' => null,
'webhookUrlToken' => null,
'delaySendMessagesMilliseconds' => null,
'markIncomingMessagesReaded' => null,
'markIncomingMessagesReadedOnReply' => null,
'outgoingWebhook' => null,
'outgoingMessageWebhook' => null,
'outgoingAPIMessageWebhook' => null,
'stateWebhook' => null,
'incomingWebhook' => 'yes',
'deviceWebhook' => null,
'keepOnlineStatus' => null,
'pollMessageWebhook' => null,
'incomingBlockWebhook' => null,
'incomingCallWebhook' => null,
'editedMessageWebhook' => null,
'deletedMessageWebhook' => null,
];
$requestParameters = array_filter(array_merge($defaultParameters, $payload));
return $this->greenApi->request('POST',
'{{host}}/partner/createInstance/{{partnerToken}}', $requestParameters);
}
/**
*
* The method is used to deleting an instance of the partner's account.
*
* @param $idInstance
* @return stdClass
* @link https://green-api.com/en/docs/partners/deleteInstanceAccount/
*/
public function deleteInstanceAccount($idInstance): stdClass {
return $this->greenApi->request('POST',
'{{host}}/partner/deleteInstanceAccount/{{partnerToken}}', ['idInstance' => $idInstance]);
}
}