@@ -26,26 +26,28 @@ public function __construct(array $data = [])
26
26
27
27
private function request ()
28
28
{
29
- $ this ->header [] = 'Content-Type: application/json ' ;
30
- $ ch = curl_init ();
31
- curl_setopt ($ ch , CURLOPT_URL , $ this ->server . $ this ->parth );
32
- curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
33
- curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , $ this ->method );
34
- if ($ this ->method === 'POST ' || $ this ->method === 'PUT ' ) {
35
- curl_setopt ($ ch , CURLOPT_POST , true );
36
- curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ this ->body );
37
- }
38
-
39
- curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ this ->header );
40
- $ result = curl_exec ($ ch );
41
-
42
- if (curl_errno ($ ch )) {
43
- $ errorMessage = curl_error ($ ch );
29
+ try {
30
+ $ this ->header [] = 'Content-Type: application/json ' ;
31
+ $ ch = curl_init ();
32
+ curl_setopt ($ ch , CURLOPT_URL , $ this ->server . $ this ->parth );
33
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
34
+ curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , $ this ->method );
35
+ if ($ this ->method === 'POST ' || $ this ->method === 'PUT ' ) {
36
+ curl_setopt ($ ch , CURLOPT_POST , true );
37
+ curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ this ->body );
38
+ }
39
+ curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ this ->header );
40
+ $ result = curl_exec ($ ch );
41
+ if (curl_errno ($ ch )) {
42
+ $ errorMessage = curl_error ($ ch );
43
+ curl_close ($ ch );
44
+ throw new \RuntimeException ("cURL Error: $ errorMessage " );
45
+ }
44
46
curl_close ($ ch );
45
- throw new \RuntimeException ("cURL Error: $ errorMessage " );
47
+ return $ result ;
48
+ } catch (\Throwable $ th ) {
49
+ return null ;
46
50
}
47
- curl_close ($ ch );
48
- return $ result ;
49
51
}
50
52
51
53
/**
@@ -63,6 +65,15 @@ public function connect()
63
65
return $ this ->request ();
64
66
}
65
67
68
+ public function updateSaveMediaMarkMessageRead (bool $ markMessageRead , bool $ saveMedia )
69
+ {
70
+ $ markMessageReadValue = json_encode ($ markMessageRead );
71
+ $ saveMediaValue = json_encode ($ saveMedia );
72
+ $ this ->parth = "/ {$ this ->key }/instance/?markMessageRead= {$ markMessageReadValue }&saveMedia= {$ saveMediaValue }" ;
73
+ $ this ->method = "PATCH " ;
74
+ return $ this ->request ();
75
+ }
76
+
66
77
/**
67
78
* Obtém informações sobre a instância atual.
68
79
*
0 commit comments